diff options
Diffstat (limited to 'src/mesa/drivers')
224 files changed, 0 insertions, 85772 deletions
diff --git a/src/mesa/drivers/dri/i810/Makefile b/src/mesa/drivers/dri/i810/Makefile deleted file mode 100644 index edc6dd21732..00000000000 --- a/src/mesa/drivers/dri/i810/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# src/mesa/drivers/dri/i810/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = i810_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - i810context.c \ - i810ioctl.c \ - i810render.c \ - i810screen.c \ - i810span.c \ - i810state.c \ - i810tex.c \ - i810texmem.c \ - i810texstate.c \ - i810tris.c \ - i810vb.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/i810/i810_3d_reg.h b/src/mesa/drivers/dri/i810/i810_3d_reg.h deleted file mode 100644 index 2fbeb64978e..00000000000 --- a/src/mesa/drivers/dri/i810/i810_3d_reg.h +++ /dev/null @@ -1,630 +0,0 @@ - -#ifndef I810_3D_REG_H -#define I810_3D_REG_H - -#include "i810_reg.h" - -/* Registers not used in the X server - */ - -#define I810_NOP_ID 0x2094 -#define I810_NOP_ID_MASK ((1<<22)-1) - - -/* 3D instructions - */ - - -/* GFXRENDERSTATE_PV_PIXELIZATION_RULE, p149 - * - * Format: - * 0: GFX_OP_PV_RULE | PV_* - * - */ -#define GFX_OP_PV_RULE ((0x3<<29)|(0x7<<24)) -#define PV_SMALL_TRI_FILTER_ENABLE (0x1<<11) -#define PV_UPDATE_PIXRULE (0x1<<10) -#define PV_PIXRULE_ENABLE (0x1<<9) -#define PV_UPDATE_LINELIST (0x1<<8) -#define PV_LINELIST_MASK (0x3<<6) -#define PV_LINELIST_PV0 (0x0<<6) -#define PV_LINELIST_PV1 (0x1<<6) -#define PV_UPDATE_TRIFAN (0x1<<5) -#define PV_TRIFAN_MASK (0x3<<3) -#define PV_TRIFAN_PV0 (0x0<<3) -#define PV_TRIFAN_PV1 (0x1<<3) -#define PV_TRIFAN_PV2 (0x2<<3) -#define PV_UPDATE_TRISTRIP (0x1<<2) -#define PV_TRISTRIP_MASK (0x3<<0) -#define PV_TRISTRIP_PV0 (0x0<<0) -#define PV_TRISTRIP_PV1 (0x1<<0) -#define PV_TRISTRIP_PV2 (0x2<<0) - - -/* GFXRENDERSTATE_SCISSOR_ENABLE, p146 - * - * Format: - * 0: GFX_OP_SCISSOR | SC_* - */ -#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) -#define SC_UPDATE_SCISSOR (0x1<<1) -#define SC_ENABLE_MASK (0x1<<0) -#define SC_ENABLE (0x1<<0) - -/* GFXRENDERSTATE_SCISSOR_INFO, p147 - * - * Format: - * 0: GFX_OP_SCISSOR_INFO - * 1: SCI_MIN_* - * 2: SCI_MAX_* - */ -#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1)) -#define SCI_YMIN_MASK (0xffff<<16) -#define SCI_XMIN_MASK (0xffff<<0) -#define SCI_YMAX_MASK (0xffff<<16) -#define SCI_XMAX_MASK (0xffff<<0) - -/* GFXRENDERSTATE_DRAWING_RECT_INFO, p144 - * - * Format: - * 0: GFX_OP_DRAWRECT_INFO - * 1: DR1_* - * 2: DR2_* - * 3: DR3_* - * 4: DR4_* - */ -#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3)) -#define DR1_RECT_CLIP_ENABLE (0x0<<31) -#define DR1_RECT_CLIP_DISABLE (0x1<<31) -#define DR1_X_DITHER_BIAS_MASK (0x3<<26) -#define DR1_X_DITHER_BIAS_SHIFT 26 -#define DR1_Y_DITHER_BIAS_MASK (0x3<<24) -#define DR1_Y_DITHER_BIAS_SHIFT 24 -#define DR2_YMIN_MASK (0xffff<<16) -#define DR2_XMIN_MASK (0xffff<<0) -#define DR3_YMAX_MASK (0xffff<<16) -#define DR3_XMAX_MASK (0xffff<<0) -#define DR4_YORG_MASK (0x3ff<<16) -#define DR4_XORG_MASK (0x7ff<<0) - - -/* GFXRENDERSTATE_LINEWIDTH_CULL_SHADE_MODE, p140 - * - * Format: - * 0: GFX_OP_LINEWIDTH_CULL_SHADE_MODE | LCS_* - */ -#define GFX_OP_LINEWIDTH_CULL_SHADE_MODE ((0x3<<29)|(0x2<<24)) -#define LCS_UPDATE_ZMODE (0x1<<20) -#define LCS_Z_MASK (0xf<<16) -#define LCS_Z_NEVER (0x1<<16) -#define LCS_Z_LESS (0x2<<16) -#define LCS_Z_EQUAL (0x3<<16) -#define LCS_Z_LEQUAL (0x4<<16) -#define LCS_Z_GREATER (0x5<<16) -#define LCS_Z_NOTEQUAL (0x6<<16) -#define LCS_Z_GEQUAL (0x7<<16) -#define LCS_Z_ALWAYS (0x8<<16) -#define LCS_UPDATE_LINEWIDTH (0x1<<15) -#define LCS_LINEWIDTH_MASK (0x7<<12) -#define LCS_LINEWIDTH_SHIFT 12 -#define LCS_LINEWIDTH_0_5 (0x1<<12) -#define LCS_LINEWIDTH_1_0 (0x2<<12) -#define LCS_LINEWIDTH_2_0 (0x4<<12) -#define LCS_LINEWIDTH_3_0 (0x6<<12) -#define LCS_UPDATE_ALPHA_INTERP (0x1<<11) -#define LCS_ALPHA_FLAT (0x1<<10) -#define LCS_ALPHA_INTERP (0x0<<10) -#define LCS_UPDATE_FOG_INTERP (0x1<<9) -#define LCS_FOG_INTERP (0x0<<8) -#define LCS_FOG_FLAT (0x1<<8) -#define LCS_UPDATE_SPEC_INTERP (0x1<<7) -#define LCS_SPEC_INTERP (0x0<<6) -#define LCS_SPEC_FLAT (0x1<<6) -#define LCS_UPDATE_RGB_INTERP (0x1<<5) -#define LCS_RGB_INTERP (0x0<<4) -#define LCS_RGB_FLAT (0x1<<4) -#define LCS_UPDATE_CULL_MODE (0x1<<3) -#define LCS_CULL_MASK (0x7<<0) -#define LCS_CULL_DISABLE (0x1<<0) -#define LCS_CULL_CW (0x2<<0) -#define LCS_CULL_CCW (0x3<<0) -#define LCS_CULL_BOTH (0x4<<0) - -#define LCS_INTERP_FLAT (LCS_ALPHA_FLAT|LCS_RGB_FLAT|LCS_SPEC_FLAT) -#define LCS_UPDATE_INTERP (LCS_UPDATE_ALPHA_INTERP| \ - LCS_UPDATE_RGB_INTERP| \ - LCS_UPDATE_SPEC_INTERP) - - -/* GFXRENDERSTATE_BOOLEAN_ENA_1, p142 - * - */ -#define GFX_OP_BOOL_1 ((0x3<<29)|(0x3<<24)) -#define B1_UPDATE_SPEC_SETUP_ENABLE (1<<19) -#define B1_SPEC_SETUP_ENABLE (1<<18) -#define B1_UPDATE_ALPHA_SETUP_ENABLE (1<<17) -#define B1_ALPHA_SETUP_ENABLE (1<<16) -#define B1_UPDATE_CI_KEY_ENABLE (1<<15) -#define B1_CI_KEY_ENABLE (1<<14) -#define B1_UPDATE_CHROMAKEY_ENABLE (1<<13) -#define B1_CHROMAKEY_ENABLE (1<<12) -#define B1_UPDATE_Z_BIAS_ENABLE (1<<11) -#define B1_Z_BIAS_ENABLE (1<<10) -#define B1_UPDATE_SPEC_ENABLE (1<<9) -#define B1_SPEC_ENABLE (1<<8) -#define B1_UPDATE_FOG_ENABLE (1<<7) -#define B1_FOG_ENABLE (1<<6) -#define B1_UPDATE_ALPHA_TEST_ENABLE (1<<5) -#define B1_ALPHA_TEST_ENABLE (1<<4) -#define B1_UPDATE_BLEND_ENABLE (1<<3) -#define B1_BLEND_ENABLE (1<<2) -#define B1_UPDATE_Z_TEST_ENABLE (1<<1) -#define B1_Z_TEST_ENABLE (1<<0) - -/* GFXRENDERSTATE_BOOLEAN_ENA_2, p143 - * - */ -#define GFX_OP_BOOL_2 ((0x3<<29)|(0x4<<24)) -#define B2_UPDATE_MAP_CACHE_ENABLE (1<<17) -#define B2_MAP_CACHE_ENABLE (1<<16) -#define B2_UPDATE_ALPHA_DITHER_ENABLE (1<<15) -#define B2_ALPHA_DITHER_ENABLE (1<<14) -#define B2_UPDATE_FOG_DITHER_ENABLE (1<<13) -#define B2_FOG_DITHER_ENABLE (1<<12) -#define B2_UPDATE_SPEC_DITHER_ENABLE (1<<11) -#define B2_SPEC_DITHER_ENABLE (1<<10) -#define B2_UPDATE_RGB_DITHER_ENABLE (1<<9) -#define B2_RGB_DITHER_ENABLE (1<<8) -#define B2_UPDATE_FB_WRITE_ENABLE (1<<3) -#define B2_FB_WRITE_ENABLE (1<<2) -#define B2_UPDATE_ZB_WRITE_ENABLE (1<<1) -#define B2_ZB_WRITE_ENABLE (1<<0) - - -/* GFXRENDERSTATE_FOG_COLOR, p144 - */ -#define GFX_OP_FOG_COLOR ((0x3<<29)|(0x15<<24)) -#define FOG_RED_SHIFT 16 -#define FOG_GREEN_SHIFT 8 -#define FOG_BLUE_SHIFT 0 -#define FOG_RESERVED_MASK ((0x7<<16)|(0x3<<8)|(0x3)) - - -/* GFXRENDERSTATE_Z_BIAS_ALPHA_FUNC_REF, p139 - */ -#define GFX_OP_ZBIAS_ALPHAFUNC ((0x3<<29)|(0x14<<24)) -#define ZA_UPDATE_ZBIAS (1<<22) -#define ZA_ZBIAS_SHIFT 14 -#define ZA_ZBIAS_MASK (0xff<<14) -#define ZA_UPDATE_ALPHAFUNC (1<<13) -#define ZA_ALPHA_MASK (0xf<<9) -#define ZA_ALPHA_NEVER (1<<9) -#define ZA_ALPHA_LESS (2<<9) -#define ZA_ALPHA_EQUAL (3<<9) -#define ZA_ALPHA_LEQUAL (4<<9) -#define ZA_ALPHA_GREATER (5<<9) -#define ZA_ALPHA_NOTEQUAL (6<<9) -#define ZA_ALPHA_GEQUAL (7<<9) -#define ZA_ALPHA_ALWAYS (8<<9) -#define ZA_UPDATE_ALPHAREF (1<<8) -#define ZA_ALPHAREF_MASK (0xff<<0) -#define ZA_ALPHAREF_SHIFT 0 -#define ZA_ALPHAREF_RESERVED (0x7<<0) - - -/* GFXRENDERSTATE_SRC_DST_BLEND_MONO, p136 - */ -#define GFX_OP_SRC_DEST_MONO ((0x3<<29)|(0x8<<24)) -#define SDM_UPDATE_MONO_ENABLE (1<<13) -#define SDM_MONO_ENABLE (1<<12) -#define SDM_UPDATE_SRC_BLEND (1<<11) -#define SDM_SRC_MASK (0xf<<6) -#define SDM_SRC_ZERO (0x1<<6) -#define SDM_SRC_ONE (0x2<<6) -#define SDM_SRC_SRC_COLOR (0x3<<6) -#define SDM_SRC_INV_SRC_COLOR (0x4<<6) -#define SDM_SRC_SRC_ALPHA (0x5<<6) -#define SDM_SRC_INV_SRC_ALPHA (0x6<<6) -#define SDM_SRC_DST_COLOR (0x9<<6) -#define SDM_SRC_INV_DST_COLOR (0xa<<6) -#define SDM_SRC_BOTH_SRC_ALPHA (0xc<<6) -#define SDM_SRC_BOTH_INV_SRC_ALPHA (0xd<<6) -#define SDM_UPDATE_DST_BLEND (1<<5) -#define SDM_DST_MASK (0xf<<0) -#define SDM_DST_ZERO (0x1<<0) -#define SDM_DST_ONE (0x2<<0) -#define SDM_DST_SRC_COLOR (0x3<<0) -#define SDM_DST_INV_SRC_COLOR (0x4<<0) -#define SDM_DST_SRC_ALPHA (0x5<<0) -#define SDM_DST_INV_SRC_ALPHA (0x6<<0) -#define SDM_DST_DST_COLOR (0x9<<0) -#define SDM_DST_INV_DST_COLOR (0xa<<0) -#define SDM_DST_BOTH_SRC_ALPHA (0xc<<0) -#define SDM_DST_BOTH_INV_SRC_ALPHA (0xd<<0) - - -/* GFXRENDERSTATE_COLOR_FACTOR, p134 - * - * Format: - * 0: GFX_OP_COLOR_FACTOR - * 1: ARGB8888 color factor - */ -#define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0) - -/* GFXRENDERSTATE_MAP_ALPHA_BLEND_STAGES, p132 - */ -#define GFX_OP_MAP_ALPHA_STAGES ((0x3<<29)|(0x1<<24)) -#define MA_STAGE_SHIFT 20 -#define MA_STAGE_0 (0<<20) -#define MA_STAGE_1 (1<<20) -#define MA_STAGE_2 (2<<20) - -#define MA_ARG_ONE (0x0<<2) -#define MA_ARG_ALPHA_FACTOR (0x1<<2) -#define MA_ARG_ITERATED_ALPHA (0x3<<2) -#define MA_ARG_CURRENT_ALPHA (0x5<<2) -#define MA_ARG_TEX0_ALPHA (0x6<<2) -#define MA_ARG_TEX1_ALPHA (0x7<<2) -#define MA_ARG_INVERT (0x1) -#define MA_ARG_DONT_INVERT (0x0) - -#define MA_UPDATE_ARG1 (1<<18) -#define MA_ARG1_SHIFT 13 -#define MA_ARG1_MASK (0x1d << MA_ARG1_SHIFT) - -#define MA_UPDATE_ARG2 (1<<12) -#define MA_ARG2_SHIFT 6 -#define MA_ARG2_MASK (0x1d << MA_ARG2_SHIFT) - -#define MA_UPDATE_OP (1<<5) -#define MA_OP_MASK (0xf) -#define MA_OP_ARG1 (0x1) -#define MA_OP_ARG2 (0x2) -#define MA_OP_MODULATE (0x3) -#define MA_OP_MODULATE_X2 (0x4) -#define MA_OP_MODULATE_X4 (0x5) -#define MA_OP_ADD (0x6) -#define MA_OP_ADD_SIGNED (0x7) -#define MA_OP_LIN_BLEND_ITER_ALPHA (0x8) -#define MA_OP_LIN_BLEND_ALPHA_FACTOR (0xa) -#define MA_OP_LIN_BLEND_TEX0_ALPHA (0x10) -#define MA_OP_LIN_BLEND_TEX1_ALPHA (0x11) -#define MA_OP_SUBTRACT (0x14) - - -/* GFXRENDERSTATE_MAP_COLOR_BLEND_STAGES, p129 - */ -#define GFX_OP_MAP_COLOR_STAGES ((0x3<<29)|(0x0<<24)) -#define MC_STAGE_SHIFT 20 -#define MC_STAGE_0 (0<<20) -#define MC_STAGE_1 (1<<20) -#define MC_STAGE_2 (2<<20) -#define MC_UPDATE_DEST (1<<19) -#define MC_DEST_MASK (1<<18) -#define MC_DEST_CURRENT (0<<18) -#define MC_DEST_ACCUMULATOR (1<<18) - -#define MC_ARG_ONE (0x0<<2) -#define MC_ARG_COLOR_FACTOR (0x1<<2) -#define MC_ARG_ACCUMULATOR (0x2<<2) -#define MC_ARG_ITERATED_COLOR (0x3<<2) -#define MC_ARG_SPECULAR_COLOR (0x4<<2) -#define MC_ARG_CURRENT_COLOR (0x5<<2) -#define MC_ARG_TEX0_COLOR (0x6<<2) -#define MC_ARG_TEX1_COLOR (0x7<<2) -#define MC_ARG_DONT_REPLICATE_ALPHA (0x0<<1) -#define MC_ARG_REPLICATE_ALPHA (0x1<<1) -#define MC_ARG_DONT_INVERT (0x0) -#define MC_ARG_INVERT (0x1) - -#define MC_UPDATE_ARG1 (1<<17) -#define MC_ARG1_SHIFT 12 -#define MC_ARG1_MASK (0x1f << MC_ARG1_SHIFT) - -#define MC_UPDATE_ARG2 (1<<11) -#define MC_ARG2_SHIFT 6 -#define MC_ARG2_MASK (0x1f << MC_ARG2_SHIFT) - -#define MC_UPDATE_OP (1<<5) -#define MC_OP_MASK (0xf) -#define MC_OP_DISABLE (0x0) -#define MC_OP_ARG1 (0x1) -#define MC_OP_ARG2 (0x2) -#define MC_OP_MODULATE (0x3) -#define MC_OP_MODULATE_X2 (0x4) -#define MC_OP_MODULATE_X4 (0x5) -#define MC_OP_ADD (0x6) -#define MC_OP_ADD_SIGNED (0x7) -#define MC_OP_LIN_BLEND_ITER_ALPHA (0x8) -#define MC_OP_LIN_BLEND_ALPHA_FACTOR (0xa) -#define MC_OP_LIN_BLEND_TEX0_ALPHA (0x10) -#define MC_OP_LIN_BLEND_TEX1_ALPHA (0x11) -#define MC_OP_LIN_BLEND_TEX0_COLOR (0x12) -#define MC_OP_LIN_BLEND_TEX1_COLOR (0x13) -#define MC_OP_SUBTRACT (0x14) - -/* GFXRENDERSTATE_MAP_PALETTE_LOAD, p128 - * - * Format: - * 0: GFX_OP_MAP_PALETTE_LOAD - * 1: 16bpp color[0] - * ... - * 256: 16bpp color[255] - */ -#define GFX_OP_MAP_PALETTE_LOAD ((0x3<<29)|(0x1d<<24)|(0x82<<16)|0xff) - -/* GFXRENDERSTATE_MAP_LOD_CONTROL, p127 - */ -#define GFX_OP_MAP_LOD_CTL ((0x3<<29)|(0x1c<<24)|(0x4<<19)) -#define MLC_MAP_ID_SHIFT 16 -#define MLC_MAP_0 (0<<16) -#define MLC_MAP_1 (1<<16) -#define MLC_UPDATE_DITHER_WEIGHT (1<<10) -#define MLC_DITHER_WEIGHT_MASK (0x3<<8) -#define MLC_DITHER_WEIGHT_FULL (0x0<<8) -#define MLC_DITHER_WEIGHT_50 (0x1<<8) -#define MLC_DITHER_WEIGHT_25 (0x2<<8) -#define MLC_DITHER_WEIGHT_12 (0x3<<8) -#define MLC_UPDATE_LOD_BIAS (1<<7) -#define MLC_LOD_BIAS_MASK ((1<<7)-1) - -/* GFXRENDERSTATE_MAP_LOD_LIMITS, p126 - */ -#define GFX_OP_MAP_LOD_LIMITS ((0x3<<29)|(0x1c<<24)|(0x3<<19)) -#define MLL_MAP_ID_SHIFT 16 -#define MLL_MAP_0 (0<<16) -#define MLL_MAP_1 (1<<16) -#define MLL_UPDATE_MAX_MIP (1<<13) -#define MLL_MAX_MIP_SHIFT 5 -#define MLL_MAX_MIP_MASK (0xff<<5) -#define MLL_MAX_MIP_ONE (0x10<<5) -#define MLL_UPDATE_MIN_MIP (1<<4) -#define MLL_MIN_MIP_SHIFT 0 -#define MLL_MIN_MIP_MASK (0xf<<0) - -/* GFXRENDERSTATE_MAP_FILTER, p124 - */ -#define GFX_OP_MAP_FILTER ((0x3<<29)|(0x1c<<24)|(0x2<<19)) -#define MF_MAP_ID_SHIFT 16 -#define MF_MAP_0 (0<<16) -#define MF_MAP_1 (1<<16) -#define MF_UPDATE_ANISOTROPIC (1<<12) -#define MF_ANISOTROPIC_MASK (1<<10) -#define MF_ANISOTROPIC_ENABLE (1<<10) -#define MF_UPDATE_MIP_FILTER (1<<9) -#define MF_MIP_MASK (0x3<<6) -#define MF_MIP_NONE (0x0<<6) -#define MF_MIP_NEAREST (0x1<<6) -#define MF_MIP_DITHER (0x2<<6) -#define MF_MIP_LINEAR (0x3<<6) -#define MF_UPDATE_MAG_FILTER (1<<5) -#define MF_MAG_MASK (1<<3) -#define MF_MAG_LINEAR (1<<3) -#define MF_MAG_NEAREST (0<<3) -#define MF_UPDATE_MIN_FILTER (1<<2) -#define MF_MIN_MASK (1<<0) -#define MF_MIN_LINEAR (1<<0) -#define MF_MIN_NEAREST (0<<0) - -/* GFXRENDERSTATE_MAP_INFO, p118 - */ -#define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x2) -#define MI1_MAP_ID_SHIFT 28 -#define MI1_MAP_0 (0<<28) -#define MI1_MAP_1 (1<<28) -#define MI1_FMT_MASK (0x7<<24) -#define MI1_FMT_8CI (0x0<<24) -#define MI1_FMT_8BPP (0x1<<24) -#define MI1_FMT_16BPP (0x2<<24) -#define MI1_FMT_422 (0x5<<24) -#define MI1_PF_MASK (0x3<<21) -#define MI1_PF_8CI_RGB565 (0x0<<21) -#define MI1_PF_8CI_ARGB1555 (0x1<<21) -#define MI1_PF_8CI_ARGB4444 (0x2<<21) -#define MI1_PF_8CI_AY88 (0x3<<21) -#define MI1_PF_16BPP_RGB565 (0x0<<21) -#define MI1_PF_16BPP_ARGB1555 (0x1<<21) -#define MI1_PF_16BPP_ARGB4444 (0x2<<21) -#define MI1_PF_16BPP_AY88 (0x3<<21) -#define MI1_PF_422_YCRCB_SWAP_Y (0x0<<21) -#define MI1_PF_422_YCRCB (0x1<<21) -#define MI1_PF_422_YCRCB_SWAP_UV (0x2<<21) -#define MI1_PF_422_YCRCB_SWAP_YUV (0x3<<21) -#define MI1_OUTPUT_CHANNEL_MASK (0x3<<19) -#define MI1_COLOR_CONV_ENABLE (1<<18) -#define MI1_VERT_STRIDE_MASK (1<<17) -#define MI1_VERT_STRIDE_1 (1<<17) -#define MI1_VERT_OFFSET_MASK (1<<16) -#define MI1_VERT_OFFSET_1 (1<<16) -#define MI1_ENABLE_FENCE_REGS (1<<10) -#define MI1_TILED_SURFACE (1<<9) -#define MI1_TILE_WALK_X (0<<8) -#define MI1_TILE_WALK_Y (1<<8) -#define MI1_PITCH_MASK (0xf<<0) -#define MI2_DIMENSIONS_ARE_LOG2 (1<<31) -#define MI2_DIMENSIONS_ARE_EXACT (0<<31) -#define MI2_HEIGHT_SHIFT 16 -#define MI2_HEIGHT_MASK (0x1ff<<16) -#define MI2_WIDTH_SHIFT 0 -#define MI2_WIDTH_MASK (0x1ff<<0) -#define MI3_BASE_ADDR_MASK (~0xf) - -/* GFXRENDERSTATE_MAP_COORD_SETS, p116 - */ -#define GFX_OP_MAP_COORD_SETS ((0x3<<29)|(0x1c<<24)|(0x1<<19)) -#define MCS_COORD_ID_SHIFT 16 -#define MCS_COORD_0 (0<<16) -#define MCS_COORD_1 (1<<16) -#define MCS_UPDATE_NORMALIZED (1<<15) -#define MCS_NORMALIZED_COORDS_MASK (1<<14) -#define MCS_NORMALIZED_COORDS (1<<14) -#define MCS_UPDATE_V_STATE (1<<7) -#define MCS_V_STATE_MASK (0x3<<4) -#define MCS_V_WRAP (0x0<<4) -#define MCS_V_MIRROR (0x1<<4) -#define MCS_V_CLAMP (0x2<<4) -#define MCS_V_WRAP_SHORTEST (0x3<<4) -#define MCS_UPDATE_U_STATE (1<<3) -#define MCS_U_STATE_MASK (0x3<<0) -#define MCS_U_WRAP (0x0<<0) -#define MCS_U_MIRROR (0x1<<0) -#define MCS_U_CLAMP (0x2<<0) -#define MCS_U_WRAP_SHORTEST (0x3<<0) - -/* GFXRENDERSTATE_MAP_TEXELS, p115 - */ -#define GFX_OP_MAP_TEXELS ((0x3<<29)|(0x1c<<24)|(0x0<<19)) -#define MT_UPDATE_TEXEL1_STATE (1<<15) -#define MT_TEXEL1_DISABLE (0<<14) -#define MT_TEXEL1_ENABLE (1<<14) -#define MT_TEXEL1_COORD0 (0<<11) -#define MT_TEXEL1_COORD1 (1<<11) -#define MT_TEXEL1_MAP0 (0<<8) -#define MT_TEXEL1_MAP1 (1<<8) -#define MT_UPDATE_TEXEL0_STATE (1<<7) -#define MT_TEXEL0_DISABLE (0<<6) -#define MT_TEXEL0_ENABLE (1<<6) -#define MT_TEXEL0_COORD0 (0<<3) -#define MT_TEXEL0_COORD1 (1<<3) -#define MT_TEXEL0_MAP0 (0<<0) -#define MT_TEXEL0_MAP1 (1<<0) - -/* GFXRENDERSTATE_VERTEX_FORMAT, p110 - */ -#define GFX_OP_VERTEX_FMT ((0x3<<29)|(0x5<<24)) -#define VF_TEXCOORD_COUNT_SHIFT 8 -#define VF_TEXCOORD_COUNT_0 (0<<8) -#define VF_TEXCOORD_COUNT_1 (1<<8) -#define VF_TEXCOORD_COUNT_2 (2<<8) -#define VF_SPEC_FOG_ENABLE (1<<7) -#define VF_RGBA_ENABLE (1<<6) -#define VF_Z_OFFSET_ENABLE (1<<5) -#define VF_XYZ (0x1<<1) -#define VF_XYZW (0x2<<1) -#define VF_XY (0x3<<1) -#define VF_XYW (0x4<<1) - - -#define VERT_X_MASK (~0xf) -#define VERT_X_EDGE_V2V0 (1<<2) -#define VERT_X_EDGE_V1V2 (1<<1) -#define VERT_X_EDGE_V0V1 (1<<0) - -/* Not enabled fields should not be sent to hardware: - */ -typedef struct { - union { - float x; - unsigned int edge_flags; - } x; - float y; - float z; - float z_bias; - float oow; - unsigned int argb; - unsigned int fog_spec_rgb; /* spec g and r ignored. */ - float tu0; - float tv0; - float tu1; - float tv1; -} i810_full_vertex; - - - -/* GFXCMDPARSER_BATCH_BUFFER, p105 - * - * Not clear whether start address must be shifted or not. Not clear - * whether address is physical system memory, or subject to GTT - * translation. Because the address appears to be 32 bits long, - * perhaps it refers to physical system memory... - */ -#define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1) -#define BB1_START_ADDR_MASK (~0x7) -#define BB1_PROTECTED (1<<0) -#define BB1_UNPROTECTED (0<<0) -#define BB2_END_ADDR_MASK (~0x7) - -/* Hardware seems to barf on buffers larger than this (in strange ways)... - */ -#define MAX_BATCH (512*1024) - - -/* GFXCMDPARSER_Z_BUFFER_INFO, p98 - * - * Base address is in GTT space, and must be 4K aligned - */ -#define CMD_OP_Z_BUFFER_INFO ((0x0<<29)|(0x16<<23)) -#define ZB_BASE_ADDR_SHIFT 0 -#define ZB_BASE_ADDR_MASK (~((1<<12)-1)) -#define ZB_PITCH_512B (0x0<<0) -#define ZB_PITCH_1K (0x1<<0) -#define ZB_PITCH_2K (0x2<<0) -#define ZB_PITCH_4K (0x3<<0) - -/* GFXCMDPARSER_FRONT_BUFFER_INFO, p97 - * - * Format: - * 0: CMD_OP_FRONT_BUFFER_INFO | (pitch<<FB0_PITCH_SHIFT) | FB0_* - * 1: FB1_* - */ -#define CMD_OP_FRONT_BUFFER_INFO ((0x0<<29)|(0x14<<23)) -#define FB0_PITCH_SHIFT 8 -#define FB0_FLIP_SYNC (0<<6) -#define FB0_FLIP_ASYNC (1<<6) -#define FB0_BASE_ADDR_SHIFT 0 -#define FB0_BASE_ADDR_MASK 0x03FFFFF8 - -/* GFXCMDPARSER_DEST_BUFFER_INFO, p96 - * - * Format: - */ -#define CMD_OP_DESTBUFFER_INFO ((0x0<<29)|(0x15<<23)) -#define DB1_BASE_ADDR_SHIFT 0 -#define DB1_BASE_ADDR_MASK 0x03FFF000 -#define DB1_PITCH_512B (0x0<<0) -#define DB1_PITCH_1K (0x1<<0) -#define DB1_PITCH_2K (0x2<<0) -#define DB1_PITCH_4K (0x4<<0) - - -/* GFXRENDERSTATE_DEST_BUFFER_VARIABLES, p152 - * - * Format: - * 0: GFX_OP_DESTBUFFER_VARS - * 1: DEST_* - */ -#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0) -#define DV_HORG_BIAS_MASK (0xf<<20) -#define DV_HORG_BIAS_OGL (0x0<<20) -#define DV_VORG_BIAS_MASK (0xf<<16) -#define DV_VORG_BIAS_OGL (0x0<<16) -#define DV_PF_MASK (0x7<<8) -#define DV_PF_INDEX (0x0<<8) -#define DV_PF_555 (0x1<<8) -#define DV_PF_565 (0x2<<8) - -#define GFX_OP_ANTIALIAS ((0x3<<29)|(0x6<<24)) -#define AA_UPDATE_EDGEFLAG (1<<13) -#define AA_ENABLE_EDGEFLAG (1<<12) -#define AA_UPDATE_POLYWIDTH (1<<11) -#define AA_POLYWIDTH_05 (1<<9) -#define AA_POLYWIDTH_10 (2<<9) -#define AA_POLYWIDTH_20 (3<<9) -#define AA_POLYWIDTH_40 (4<<9) -#define AA_UPDATE_LINEWIDTH (1<<8) -#define AA_LINEWIDTH_05 (1<<6) -#define AA_LINEWIDTH_10 (2<<6) -#define AA_LINEWIDTH_20 (3<<6) -#define AA_LINEWIDTH_40 (4<<6) -#define AA_UPDATE_BB_EXPANSION (1<<5) -#define AA_BB_EXPANSION_SHIFT 2 -#define AA_UPDATE_AA_ENABLE (1<<1) -#define AA_ENABLE (1<<0) - -#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16)) -#define ST1_ENABLE (1<<16) -#define ST1_MASK (0xffff) - -#define I810_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value) - -#endif diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c deleted file mode 100644 index 604b1e36f97..00000000000 --- a/src/mesa/drivers/dri/i810/i810context.c +++ /dev/null @@ -1,570 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/simple_list.h" -#include "main/imports.h" -#include "main/points.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "vbo/vbo.h" - -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.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 "drirenderbuffer.h" -#include "utils.h" - -#ifndef I810_DEBUG -int I810_DEBUG = (0); -#endif - -PUBLIC const char __driConfigOptions[] = { 0 }; -const GLuint __driNConfigOptions = 0; - -static const GLubyte *i810GetString( struct gl_context *ctx, GLenum name ) -{ - static char buffer[128]; - - switch (name) { - case GL_VENDOR: - return (GLubyte *)"Keith Whitwell"; - case GL_RENDERER: { - i810ContextPtr imesa = I810_CONTEXT(ctx); - const char * chipset; - - switch (imesa->i810Screen->deviceID) { - case PCI_CHIP_I810: chipset = "i810"; break; - case PCI_CHIP_I810_DC100: chipset = "i810 DC-100"; break; - case PCI_CHIP_I810_E: chipset = "i810E"; break; - case PCI_CHIP_I815: chipset = "i815"; break; - default: chipset = "Unknown i810-class Chipset"; break; - } - - (void) driGetRendererString( buffer, chipset, 0 ); - return (GLubyte *) buffer; - } - default: - return 0; - } -} - -static void i810BufferSize(struct gl_framebuffer *buffer, GLuint *width, GLuint *height) -{ - GET_CURRENT_CONTEXT(ctx); - 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); -} - -/* Extension strings exported by the i810 driver. - */ -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_env_combine", NULL }, - { "GL_ARB_texture_env_crossbar", NULL }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_EXT_texture_edge_clamp", NULL }, - { "GL_EXT_texture_env_combine", NULL }, - { "GL_EXT_texture_lod_bias", NULL }, - { "GL_EXT_texture_rectangle", NULL }, - { "GL_MESA_ycbcr_texture", NULL }, - { "GL_NV_blend_square", NULL }, - { NULL, NULL } -}; - -extern const struct tnl_pipeline_stage _i810_render_stage; - -static const struct tnl_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, -}; - -static const struct dri_debug_control debug_control[] = -{ - { "fall", DEBUG_FALLBACKS }, - { "tex", DEBUG_TEXTURE }, - { "ioctl", DEBUG_IOCTL }, - { "prim", DEBUG_PRIMS }, - { "vert", DEBUG_VERTS }, - { "state", DEBUG_STATE }, - { "verb", DEBUG_VERBOSE }, - { "dri", DEBUG_DRI }, - { "dma", DEBUG_DMA }, - { "san", DEBUG_SANITY }, - { "sync", DEBUG_SYNC }, - { "sleep", DEBUG_SLEEP }, - { NULL, 0 } -}; - -GLboolean -i810CreateContext( gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - struct gl_context *ctx, *shareCtx; - i810ContextPtr imesa; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private; - I810SAREAPtr saPriv = (I810SAREAPtr) - (((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset); - struct dd_function_table functions; - - /* Allocate i810 context */ - imesa = (i810ContextPtr) CALLOC_STRUCT(i810_context_t); - if (!imesa) { - return GL_FALSE; - } - - driContextPriv->driverPrivate = imesa; - - imesa->i810Screen = i810Screen; - imesa->driScreen = sPriv; - imesa->sarea = saPriv; - imesa->glBuffer = NULL; - - /* Init default driver functions then plug in our I810-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions( &functions ); - i810InitIoctlFuncs( &functions ); - i810InitTextureFuncs( &functions ); - - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((i810ContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - imesa->glCtx = _mesa_create_context(API_OPENGL, mesaVis, shareCtx, - &functions, (void*) imesa); - if (!imesa->glCtx) { - FREE(imesa); - return GL_FALSE; - } - - (void) memset( imesa->texture_heaps, 0, sizeof( imesa->texture_heaps ) ); - make_empty_list( & imesa->swapped ); - - imesa->nr_heaps = 1; - imesa->texture_heaps[0] = driCreateTextureHeap( 0, imesa, - i810Screen->textureSize, - 12, - I810_NR_TEX_REGIONS, - imesa->sarea->texList, - (unsigned *) & imesa->sarea->texAge, /* XXX we shouldn't cast! */ - & imesa->swapped, - sizeof( struct i810_texture_object_t ), - (destroy_texture_object_t *) i810DestroyTexObj ); - - - - /* 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; - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureImageUnits = 2; - ctx->Const.MaxTextureCoordUnits = 2; - - - /* FIXME: driCalcualteMaxTextureLevels assumes that mipmaps are tightly - * FIXME: packed, but they're not in Intel graphics hardware. - */ - driCalculateMaxTextureLevels( imesa->texture_heaps, - imesa->nr_heaps, - & ctx->Const, - 4, - 11, /* max 2D texture size is 2048x2048 */ - 0, /* 3D textures unsupported */ - 0, /* cube textures unsupported. */ - 0, /* texture rectangles unsupported. */ - 12, - GL_FALSE, - 0 ); - - 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; - - /* reinitialize the context point state. - * It depend on constants in __struct gl_contextRec::Const - */ - _mesa_init_point(ctx); - - 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 ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, i810_pipeline ); - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - _tnl_allow_pixel_fog( ctx, GL_FALSE ); - _tnl_allow_vertex_fog( ctx, GL_TRUE ); - - /* Dri stuff - */ - imesa->hHWContext = driContextPriv->hHWContext; - imesa->driFd = sPriv->fd; - imesa->driHwLock = &sPriv->pSAREA->lock; - - imesa->stipple_in_hw = 1; - imesa->RenderIndex = ~0; - imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS; - imesa->upload_cliprects = GL_TRUE; - - imesa->CurrentTexObj[0] = 0; - imesa->CurrentTexObj[1] = 0; - - _math_matrix_ctr( &imesa->ViewportMatrix ); - - driInitExtensions( ctx, card_extensions, GL_TRUE ); - /* XXX these should really go right after _mesa_init_driver_functions() */ - i810InitStateFuncs( ctx ); - i810InitTriFuncs( ctx ); - i810InitSpanFuncs( ctx ); - i810InitVB( ctx ); - i810InitState( ctx ); - -#if DO_DEBUG - I810_DEBUG = driParseDebugString( getenv( "I810_DEBUG" ), - debug_control ); - I810_DEBUG |= driParseDebugString( getenv( "INTEL_DEBUG" ), - debug_control ); -#endif - - return GL_TRUE; -} - -void -i810DestroyContext(__DRIcontext *driContextPriv) -{ - i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate; - - assert(imesa); /* should never be null */ - if (imesa) { - GLboolean release_texture_heaps; - - - release_texture_heaps = (imesa->glCtx->Shared->RefCount == 1); - _swsetup_DestroyContext( imesa->glCtx ); - _tnl_DestroyContext( imesa->glCtx ); - _vbo_DestroyContext( imesa->glCtx ); - _swrast_DestroyContext( imesa->glCtx ); - - i810FreeVB( imesa->glCtx ); - - /* free the Mesa context */ - imesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(imesa->glCtx); - if ( release_texture_heaps ) { - /* This share group is about to go away, free our private - * texture object data. - */ - unsigned int i; - - for ( i = 0 ; i < imesa->nr_heaps ; i++ ) { - driDestroyTextureHeap( imesa->texture_heaps[ i ] ); - imesa->texture_heaps[ i ] = NULL; - } - - assert( is_empty_list( & imesa->swapped ) ); - } - - FREE(imesa); - } -} - - -void i810XMesaSetFrontClipRects( i810ContextPtr imesa ) -{ - __DRIdrawable *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 ) -{ - __DRIdrawable *dPriv = imesa->driDrawable; - - if (imesa->sarea->pf_enabled == 0 && 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 ) -{ - /* Determine current color drawing buffer */ - switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0]) { - case BUFFER_FRONT_LEFT: - i810XMesaSetFrontClipRects( imesa ); - break; - case BUFFER_BACK_LEFT: - i810XMesaSetBackClipRects( imesa ); - break; - default: - /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */ - i810XMesaSetFrontClipRects( imesa ); - } -} - - -GLboolean -i810UnbindContext(__DRIcontext *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(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv) -{ - if (driContextPriv) { - i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate; - - /* Shouldn't the readbuffer be stored also? - */ - imesa->driDrawable = driDrawPriv; - - _mesa_make_current(imesa->glCtx, - (struct gl_framebuffer *) driDrawPriv->driverPrivate, - (struct gl_framebuffer *) driReadPriv->driverPrivate); - - /* Are these necessary? - */ - i810XMesaWindowMoved( imesa ); - } - else { - _mesa_make_current(NULL, NULL, NULL); - } - - return GL_TRUE; -} - -static void -i810UpdatePageFlipping( i810ContextPtr imesa ) -{ - struct gl_context *ctx = imesa->glCtx; - int front = 0; - - /* Determine current color drawing buffer */ - switch (ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) { - case BUFFER_FRONT_LEFT: - front = 1; - break; - case BUFFER_BACK_LEFT: - front = 0; - break; - default: - return; - } - - if ( imesa->sarea->pf_current_page == 1 ) - front ^= 1; - - driFlipRenderbuffers(ctx->WinSysDrawBuffer, front); - - if (front) { - imesa->BufferSetup[I810_DESTREG_DI1] = imesa->i810Screen->fbOffset | imesa->i810Screen->backPitchBits; - } else { - imesa->BufferSetup[I810_DESTREG_DI1] = imesa->i810Screen->backOffset | imesa->i810Screen->backPitchBits; - } - - imesa->dirty |= I810_UPLOAD_BUFFERS; -} - -void i810GetLock( i810ContextPtr imesa, GLuint flags ) -{ - __DRIdrawable *dPriv = imesa->driDrawable; - __DRIscreen *sPriv = imesa->driScreen; - I810SAREAPtr sarea = imesa->sarea; - int me = imesa->hHWContext; - unsigned i; - - 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(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) { - driUpdateFramebufferSize(imesa->glCtx, dPriv); - 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. - */ - for ( i = 0 ; i < imesa->nr_heaps ; i++ ) { - DRI_AGE_TEXTURES( imesa->texture_heaps[ i ] ); - } - - if (imesa->lastStamp != dPriv->lastStamp) { - i810UpdatePageFlipping( imesa ); - i810XMesaWindowMoved( imesa ); - imesa->lastStamp = dPriv->lastStamp; - } -} - - -void -i810SwapBuffers( __DRIdrawable *dPriv ) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - i810ContextPtr imesa; - struct gl_context *ctx; - imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = imesa->glCtx; - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - if ( imesa->sarea->pf_active ) { - 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/src/mesa/drivers/dri/i810/i810context.h b/src/mesa/drivers/dri/i810/i810context.h deleted file mode 100644 index 93c7eda7b38..00000000000 --- a/src/mesa/drivers/dri/i810/i810context.h +++ /dev/null @@ -1,249 +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. - * - */ - -#ifndef I810CONTEXT_INC -#define I810CONTEXT_INC - -typedef struct i810_context_t i810Context; -typedef struct i810_context_t *i810ContextPtr; -typedef struct i810_texture_object_t *i810TextureObjectPtr; - -#include "drm.h" -#include "main/mtypes.h" -#include "main/mm.h" - -#include "i810screen.h" -#include "i810tex.h" - - -/* 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_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 - - -#ifndef PCI_CHIP_I810 -#define PCI_CHIP_I810 0x7121 -#define PCI_CHIP_I810_DC100 0x7123 -#define PCI_CHIP_I810_E 0x7125 -#define PCI_CHIP_I815 0x1132 -#endif - -#define IS_I810(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I810 || \ - imesa->i810Screen->deviceID == PCI_CHIP_I810_DC100 || \ - imesa->i810Screen->deviceID == PCI_CHIP_I810_E) -#define IS_I815(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I815) - - -#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; - struct gl_context *glCtx; - - /* Texture object bookkeeping - */ - unsigned nr_heaps; - driTexHeap * texture_heaps[1]; - driTextureObject swapped; - - struct i810_texture_object_t *CurrentTexObj[2]; - - - /* Bit flag to keep track of fallbacks. - */ - GLuint Fallback; - - /* 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; - GLubyte *verts; - - drmBufPtr vertex_buffer; - char *vertex_addr; - GLuint vertex_low; - GLuint vertex_high; - GLuint vertex_last_prim; - - GLboolean upload_cliprects; - - - /* Fallback rasterization functions - */ - i810_point_func draw_point; - i810_line_func draw_line; - i810_tri_func draw_tri; - - /* Hardware state - */ - GLuint dirty; /* I810_UPLOAD_* */ - GLuint Setup[I810_CTX_SETUP_SIZE]; - GLuint BufferSetup[I810_DEST_SETUP_SIZE]; - int vertex_size; - int vertex_stride_shift; - unsigned int lastStamp; - GLboolean stipple_in_hw; - - GLenum TexEnvImageFmt[2]; - - /* State which can't be computed completely on the fly: - */ - GLuint LcsCullMode; - GLuint LcsLineWidth; - GLuint LcsPointSize; - - /* Funny mesa mirrors - */ - GLushort ClearColor; - - /* DRI stuff - */ - GLuint needClip; - struct gl_framebuffer *glBuffer; - GLboolean doPageFlip; - - /* These refer to the current draw (front vs. back) buffer: - */ - int drawX; /* origin of drawable in draw buffer */ - int drawY; - GLuint numClipRects; /* cliprects for that buffer */ - drm_clip_rect_t *pClipRects; - - int lastSwap; - int texAge; - int ctxAge; - int dirtyAge; - - - GLboolean scissor; - drm_clip_rect_t draw_rect; - drm_clip_rect_t scissor_rect; - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - - __DRIdrawable *driDrawable; - __DRIscreen *driScreen; - i810ScreenPrivate *i810Screen; - I810SAREAPtr sarea; -}; - - -#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 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 SUBPIXEL_X -.5 -#define SUBPIXEL_Y -.5 - -/* ================================================================ - * Debugging: - */ -#define DO_DEBUG 1 -#if DO_DEBUG -extern int I810_DEBUG; -#else -#define I810_DEBUG 0 -#endif - -#define DEBUG_TEXTURE 0x1 -#define DEBUG_STATE 0x2 -#define DEBUG_IOCTL 0x4 -#define DEBUG_PRIMS 0x8 -#define DEBUG_VERTS 0x10 -#define DEBUG_FALLBACKS 0x20 -#define DEBUG_VERBOSE 0x40 -#define DEBUG_DRI 0x80 -#define DEBUG_DMA 0x100 -#define DEBUG_SANITY 0x200 -#define DEBUG_SYNC 0x400 -#define DEBUG_SLEEP 0x800 - -#endif diff --git a/src/mesa/drivers/dri/i810/i810ioctl.c b/src/mesa/drivers/dri/i810/i810ioctl.c deleted file mode 100644 index 4b004d54c65..00000000000 --- a/src/mesa/drivers/dri/i810/i810ioctl.c +++ /dev/null @@ -1,519 +0,0 @@ - -#include <unistd.h> /* for usleep() */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/dd.h" -#include "swrast/swrast.h" -#include "main/mm.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "main/context.h" -#include "i810ioctl.h" -#include "i810state.h" - -static drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa ) -{ - drmI810DMA dma; - drmBufPtr buf; - int retcode, i = 0; - - while (1) { - retcode = drmCommandWriteRead(imesa->driFd, DRM_I810_GETBUF, - &dma, sizeof(drmI810DMA)); - - if (dma.granted == 1 && retcode == 0) - break; - - if (++i > 1000) { - drmCommandNone(imesa->driFd, DRM_I810_FLUSH); - i = 0; - } - } - - buf = &(imesa->i810Screen->bufs->list[dma.request_idx]); - buf->idx = dma.request_idx; - buf->used = 0; - buf->total = dma.request_size; - buf->address = (drmAddress)dma.virtual; - - return buf; -} - - - -#define DEPTH_SCALE ((1<<16)-1) - -static void i810Clear( struct gl_context *ctx, GLbitfield mask ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - __DRIdrawable *dPriv = imesa->driDrawable; - const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask[0]); - drmI810Clear clear; - unsigned int i; - - clear.flags = 0; - clear.clear_color = imesa->ClearColor; - clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE); - - I810_FIREVERTICES( imesa ); - - if ((mask & BUFFER_BIT_FRONT_LEFT) && colorMask == ~0U) { - clear.flags |= I810_FRONT; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if ((mask & BUFFER_BIT_BACK_LEFT) && colorMask == ~0U) { - clear.flags |= I810_BACK; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if (mask & BUFFER_BIT_DEPTH) { - if (ctx->Depth.Mask) - clear.flags |= I810_DEPTH; - mask &= ~BUFFER_BIT_DEPTH; - } - - if (clear.flags) { - GLint cx, cy, cw, ch; - - LOCK_HARDWARE( imesa ); - - /* compute region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - - /* flip top to bottom */ - cy = dPriv->h-cy-ch; - cx += imesa->drawX; - cy += imesa->drawY; - - for (i = 0 ; i < imesa->numClipRects ; ) - { - unsigned int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, imesa->numClipRects); - drm_clip_rect_t *box = imesa->pClipRects; - drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes; - int n = 0; - - if (cw != dPriv->w || ch != dPriv->h) { - /* clear sub region */ - 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 { - /* clear whole buffer */ - for ( ; i < nr ; i++) { - *b++ = box[i]; - n++; - } - } - - imesa->sarea->nbox = n; - drmCommandWrite(imesa->driFd, DRM_I810_CLEAR, - &clear, sizeof(drmI810Clear)); - } - - UNLOCK_HARDWARE( imesa ); - imesa->upload_cliprects = GL_TRUE; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - - - - -/* - * Copy the back buffer to the front buffer. - */ -void i810CopyBuffer( const __DRIdrawable *dPriv ) -{ - i810ContextPtr imesa; - drm_clip_rect_t *pbox; - int nbox, i, tmp; - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate; - - I810_FIREVERTICES( imesa ); - LOCK_HARDWARE( imesa ); - - pbox = (drm_clip_rect_t *)dPriv->pClipRects; - nbox = dPriv->numClipRects; - - for (i = 0 ; i < nbox ; ) - { - int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, dPriv->numClipRects); - drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes; - - imesa->sarea->nbox = nr - i; - - for ( ; i < nr ; i++) - *b++ = pbox[i]; - - drmCommandNone(imesa->driFd, DRM_I810_SWAP); - } - - tmp = GET_ENQUEUE_AGE(imesa); - UNLOCK_HARDWARE( imesa ); - - /* 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->upload_cliprects = GL_TRUE; -} - - -/* - * XXX implement when full-screen extension is done. - */ -void i810PageFlip( const __DRIdrawable *dPriv ) -{ - i810ContextPtr imesa; - int tmp, ret; - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate; - - I810_FIREVERTICES( imesa ); - LOCK_HARDWARE( imesa ); - - if (dPriv->pClipRects) { - memcpy(&(imesa->sarea->boxes[0]), &(dPriv->pClipRects[0]), - sizeof(drm_clip_rect_t)); - imesa->sarea->nbox = 1; - } - ret = drmCommandNone(imesa->driFd, DRM_I810_FLIP); - if (ret) { - fprintf(stderr, "%s: %d\n", __FUNCTION__, ret); - UNLOCK_HARDWARE( imesa ); - exit(1); - } - - tmp = GET_ENQUEUE_AGE(imesa); - UNLOCK_HARDWARE( imesa ); - - /* multiarb will suck the life out of the server without this throttle: - */ - if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) { - i810WaitAge(imesa, imesa->lastSwap); - } - - /* i810SetDrawBuffer( imesa->glCtx, imesa->glCtx->Color.DriverDrawBuffer );*/ - i810DrawBuffer( imesa->glCtx, imesa->glCtx->Color.DrawBuffer[0] ); - imesa->upload_cliprects = GL_TRUE; - imesa->lastSwap = tmp; - return; -} - - -/* This waits for *everybody* to finish rendering -- overkill. - */ -void i810DmaFinish( i810ContextPtr imesa ) -{ - I810_FIREVERTICES( imesa ); - - LOCK_HARDWARE( imesa ); - i810RegetLockQuiescent( imesa ); - UNLOCK_HARDWARE( imesa ); -} - - -void i810RegetLockQuiescent( i810ContextPtr imesa ) -{ - drmUnlock(imesa->driFd, imesa->hHWContext); - i810GetLock( imesa, DRM_LOCK_QUIESCENT ); -} - -void i810WaitAgeLocked( i810ContextPtr imesa, int age ) -{ - int i = 0, j; - - while (++i < 5000) { - drmCommandNone(imesa->driFd, DRM_I810_GETAGE); - if (GET_DISPATCH_AGE(imesa) >= age) - return; - for (j = 0 ; j < 1000 ; j++) - ; - } - - drmCommandNone(imesa->driFd, DRM_I810_FLUSH); -} - - -void i810WaitAge( i810ContextPtr imesa, int age ) -{ - int i = 0, j; - - while (++i < 5000) { - drmCommandNone(imesa->driFd, DRM_I810_GETAGE); - if (GET_DISPATCH_AGE(imesa) >= age) - return; - for (j = 0 ; j < 1000 ; j++) - ; - } - - i = 0; - while (++i < 1000) { - drmCommandNone(imesa->driFd, DRM_I810_GETAGE); - if (GET_DISPATCH_AGE(imesa) >= age) - return; - usleep(1000); - } - - LOCK_HARDWARE(imesa); - drmCommandNone(imesa->driFd, DRM_I810_FLUSH); - UNLOCK_HARDWARE(imesa); -} - - - - -static int intersect_rect( drm_clip_rect_t *out, - drm_clip_rect_t *a, - drm_clip_rect_t *b ) -{ - *out = *a; - if (b->x1 > out->x1) out->x1 = b->x1; - if (b->x2 < out->x2) out->x2 = b->x2; - 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; - I810SAREAPtr 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]->base.timestamp = age; - if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->base.timestamp = age; -} - - -void i810FlushPrimsLocked( i810ContextPtr imesa ) -{ - drm_clip_rect_t *pbox = imesa->pClipRects; - int nbox = imesa->numClipRects; - drmBufPtr buffer = imesa->vertex_buffer; - I810SAREAPtr sarea = imesa->sarea; - drmI810Vertex vertex; - int i; - - if (I810_DEBUG & DEBUG_STATE) - i810PrintDirty( __FUNCTION__, imesa->dirty ); - - if (imesa->dirty) - emit_state( imesa ); - - vertex.idx = buffer->idx; - vertex.used = imesa->vertex_low; - vertex.discard = 0; - sarea->vertex_prim = imesa->hw_primitive; - - if (!nbox) { - vertex.used = 0; - } - else if (nbox > I810_NR_SAREA_CLIPRECTS) { - imesa->upload_cliprects = GL_TRUE; - } - - if (!nbox || !imesa->upload_cliprects) - { - if (nbox == 1) - sarea->nbox = 0; - else - sarea->nbox = nbox; - - vertex.discard = 1; - drmCommandWrite(imesa->driFd, DRM_I810_VERTEX, - &vertex, sizeof(drmI810Vertex)); - 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 = (drm_clip_rect_t *)sarea->boxes; - - if (imesa->scissor) { - sarea->nbox = 0; - - for ( ; i < nr ; i++) { - b->x1 = pbox[i].x1 - imesa->drawX; - b->y1 = pbox[i].y1 - imesa->drawY; - b->x2 = pbox[i].x2 - imesa->drawX; - b->y2 = pbox[i].y2 - imesa->drawY; - - if (intersect_rect(b, b, &imesa->scissor_rect)) { - sarea->nbox++; - b++; - } - } - - /* Culled? - */ - if (!sarea->nbox) { - if (nr < nbox) continue; - vertex.used = 0; - } - } else { - sarea->nbox = nr - i; - for ( ; i < nr ; i++, b++) { - b->x1 = pbox[i].x1 - imesa->drawX; - b->y1 = pbox[i].y1 - imesa->drawY; - b->x2 = pbox[i].x2 - imesa->drawX; - b->y2 = pbox[i].y2 - imesa->drawY; - } - } - - /* Finished with the buffer? - */ - if (nr == nbox) - vertex.discard = 1; - - drmCommandWrite(imesa->driFd, DRM_I810_VERTEX, - &vertex, sizeof(drmI810Vertex)); - 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; - imesa->upload_cliprects = GL_FALSE; -} - -void i810FlushPrimsGetBuffer( i810ContextPtr imesa ) -{ - LOCK_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); -} - - -void i810FlushPrims( i810ContextPtr imesa ) -{ - if (imesa->vertex_buffer) { - LOCK_HARDWARE( imesa ); - i810FlushPrimsLocked( imesa ); - UNLOCK_HARDWARE( imesa ); - } -} - - - -int i810_check_copy(int fd) -{ - return(drmCommandNone(fd, DRM_I810_DOCOPY)); -} - -static void i810Flush( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - I810_FIREVERTICES( imesa ); -} - -static void i810Finish( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - i810DmaFinish( imesa ); -} - -void i810InitIoctlFuncs( struct dd_function_table *functions ) -{ - functions->Flush = i810Flush; - functions->Clear = i810Clear; - functions->Finish = i810Finish; -} diff --git a/src/mesa/drivers/dri/i810/i810ioctl.h b/src/mesa/drivers/dri/i810/i810ioctl.h deleted file mode 100644 index 926e38ce51c..00000000000 --- a/src/mesa/drivers/dri/i810/i810ioctl.h +++ /dev/null @@ -1,48 +0,0 @@ - -#ifndef I810_IOCTL_H -#define I810_IOCTL_H - -#include "i810context.h" - -void i810EmitPrim( i810ContextPtr imesa ); -void i810FlushPrims( i810ContextPtr mmesa ); -void i810FlushPrimsLocked( i810ContextPtr mmesa ); -void i810FlushPrimsGetBuffer( i810ContextPtr imesa ); - -void i810WaitAgeLocked( i810ContextPtr imesa, int age ); -void i810WaitAge( i810ContextPtr imesa, int age ); -void i810DmaFinish( i810ContextPtr imesa ); -void i810RegetLockQuiescent( i810ContextPtr imesa ); -void i810InitIoctlFuncs( struct dd_function_table *functions ); -void i810CopyBuffer( const __DRIdrawable *dpriv ); -void i810PageFlip( const __DRIdrawable *dpriv ); -int i810_check_copy(int fd); - -#define I810_STATECHANGE(imesa, flag) \ -do { \ - if (imesa->vertex_low != imesa->vertex_last_prim) \ - i810FlushPrims(imesa); \ - imesa->dirty |= flag; \ -} while (0) \ - - -#define I810_FIREVERTICES(imesa) \ -do { \ - if (imesa->vertex_buffer) { \ - i810FlushPrims(imesa); \ - } \ -} while (0) - -static INLINE GLuint *i810AllocDmaLow( i810ContextPtr imesa, int bytes ) -{ - if (imesa->vertex_low + bytes > imesa->vertex_high) - i810FlushPrimsGetBuffer( imesa ); - - { - GLuint *start = (GLuint *)(imesa->vertex_addr + imesa->vertex_low); - imesa->vertex_low += bytes; - return start; - } -} - -#endif diff --git a/src/mesa/drivers/dri/i810/i810render.c b/src/mesa/drivers/dri/i810/i810render.c deleted file mode 100644 index 45f0954bbe2..00000000000 --- a/src/mesa/drivers/dri/i810/i810render.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 <[email protected]> - */ - - -/* - * Render unclipped vertex buffers by emitting vertices directly to - * dma buffers. Use strip/fan hardware acceleration where possible. - * - */ -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "math/m_xform.h" - -#include "tnl/t_context.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "i810context.h" -#include "i810tris.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 -}; - - - - -#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 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 ALLOC_VERTS( nr ) \ - i810AllocDmaLow( imesa, (nr) * imesa->vertex_size * 4) -#define EMIT_VERTS( ctx, j, nr, buf ) \ - i810_emit_contiguous_verts(ctx, j, (j)+(nr), buf) - -#define FLUSH() I810_FIREVERTICES( imesa ) - - -#define TAG(x) i810_##x -#include "tnl_dd/t_dd_dmatmp.h" - - -/**********************************************************************/ -/* Render pipeline stage */ -/**********************************************************************/ - - -static GLboolean i810_run_render( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - /* Don't handle clipping or indexed vertices. - */ - if (imesa->RenderIndex != 0 || - !i810_validate_render( ctx, VB )) { - return GL_TRUE; - } - - imesa->SetupNewInputs = VERT_BIT_POS; - - tnl->Driver.Render.Start( ctx ); - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { - GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - - if (!length) - continue; - - i810_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length, - prim ); - } - - tnl->Driver.Render.Finish( ctx ); - - return GL_FALSE; /* finished the pipe */ -} - - - -const struct tnl_pipeline_stage _i810_render_stage = -{ - "i810 render", - NULL, - NULL, - NULL, - NULL, - i810_run_render /* run */ -}; diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c deleted file mode 100644 index fc56b61b4e6..00000000000 --- a/src/mesa/drivers/dri/i810/i810screen.c +++ /dev/null @@ -1,361 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - */ - - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/simple_list.h" -#include "utils.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "i810state.h" -#include "i810tex.h" -#include "i810span.h" - -#include "GL/internal/dri_interface.h" - -static const __DRIconfig ** -i810FillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - struct gl_config * m; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - unsigned i; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const __DRIconfig **) configs; -} - - -/* static int i810_malloc_proxy_buf(drmBufMapPtr buffers) */ -/* { */ -/* char *buffer; */ -/* drmBufPtr buf; */ -/* int i; */ - -/* buffer = CALLOC(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)_mesa_align_malloc(sizeof(drmBufMap), 32); - if(retval == NULL) return NULL; - memset(retval, 0, sizeof(drmBufMap)); - retval->list = (drmBufPtr)_mesa_align_malloc(sizeof(drmBuf) * I810_DMA_BUF_NR, 32); - if(retval->list == NULL) { - _mesa_align_free(retval); - return NULL; - } - memset(retval->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR); - return retval; -} - - -static const __DRIconfig ** -i810InitScreen(__DRIscreen *sPriv) -{ - static const __DRIversion ddx_expected = { 1, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 2, 0 }; - i810ScreenPrivate *i810Screen; - I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions2( "i810", - &sPriv->dri_version, & dri_expected, - &sPriv->ddx_version, & ddx_expected, - &sPriv->drm_version, & drm_expected ) ) { - return NULL; - } - - if (sPriv->devPrivSize != sizeof(I810DRIRec)) { - fprintf(stderr,"\nERROR! sizeof(I810DRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - i810Screen = (i810ScreenPrivate *)CALLOC(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"); - FREE(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) { - FREE(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) { - drmUnmap(i810Screen->back.map, i810Screen->back.size); - FREE(i810Screen); - 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) { - drmUnmap(i810Screen->back.map, i810Screen->back.size); - drmUnmap(i810Screen->depth.map, i810Screen->depth.size); - FREE(i810Screen); - sPriv->private = NULL; - __driUtilMessage("i810InitDriver: drmMap (3) failed"); - return GL_FALSE; - } - - i810Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; - - return i810FillInModes(sPriv, 16, 16, 0, 1); -} - -static void -i810DestroyScreen(__DRIscreen *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); - - FREE(i810Screen); - sPriv->private = NULL; -} - - -/** - * Create a buffer which corresponds to the window. - */ -static GLboolean -i810CreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap ) -{ - i810ScreenPrivate *screen = (i810ScreenPrivate *) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - driScrnPriv->pFB, - screen->cpp, - /*screen->frontOffset*/0, screen->backPitch, - driDrawPriv); - i810SetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - screen->back.map, - screen->cpp, - screen->backOffset, screen->backPitch, - driDrawPriv); - i810SetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, - screen->depth.map, - screen->cpp, - screen->depthOffset, screen->backPitch, - driDrawPriv); - i810SetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -i810DestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = i810InitScreen, - .DestroyScreen = i810DestroyScreen, - .CreateContext = i810CreateContext, - .DestroyContext = i810DestroyContext, - .CreateBuffer = i810CreateBuffer, - .DestroyBuffer = i810DestroyBuffer, - .SwapBuffers = i810SwapBuffers, - .MakeCurrent = i810MakeCurrent, - .UnbindContext = i810UnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = NULL, - .WaitForMSC = NULL, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/i810/i810screen.h b/src/mesa/drivers/dri/i810/i810screen.h deleted file mode 100644 index 25c1072ce06..00000000000 --- a/src/mesa/drivers/dri/i810/i810screen.h +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - */ - -#ifndef _I810_INIT_H_ -#define _I810_INIT_H_ - -#include <sys/time.h> -#include "dri_util.h" - -typedef struct { - drm_handle_t handle; - drmSize size; - char *map; -} i810Region, *i810RegionPtr; - -typedef struct { - i810Region front; - i810Region back; - i810Region depth; - i810Region tex; - - int deviceID; - int width; - int height; - int mem; - - int cpp; /* for front and back buffers */ - int bitsPerPixel; - - int fbFormat; - int fbOffset; - int fbStride; - - int backOffset; - int depthOffset; - - int backPitch; - int backPitchBits; - - int textureOffset; - int textureSize; - int logTextureGranularity; - - __DRIscreen *driScrnPriv; - drmBufMapPtr bufs; - unsigned int sarea_priv_offset; -} i810ScreenPrivate; - - -extern GLboolean -i810CreateContext( gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ); - -extern void -i810DestroyContext(__DRIcontext *driContextPriv); - -extern GLboolean -i810UnbindContext(__DRIcontext *driContextPriv); - -extern GLboolean -i810MakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv); - -extern void -i810SwapBuffers(__DRIdrawable *driDrawPriv); - -#endif diff --git a/src/mesa/drivers/dri/i810/i810span.c b/src/mesa/drivers/dri/i810/i810span.c deleted file mode 100644 index dddab8bb51e..00000000000 --- a/src/mesa/drivers/dri/i810/i810span.c +++ /dev/null @@ -1,138 +0,0 @@ -#include "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "swrast/swrast.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "i810span.h" -#include "i810ioctl.h" - - -#define DBG 0 - -#define LOCAL_VARS \ - i810ContextPtr imesa = I810_CONTEXT(ctx); \ - __DRIdrawable *dPriv = imesa->driDrawable; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - GLushort p; \ - char *buf = (char *)(drb->flippedData + \ - dPriv->x * 2 + \ - dPriv->y * pitch); \ - (void) buf; (void) p - -#define LOCAL_DEPTH_VARS \ - i810ContextPtr imesa = I810_CONTEXT(ctx); \ - __DRIdrawable *dPriv = imesa->driDrawable; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(drb->Base.Data + \ - dPriv->x * 2 + \ - dPriv->y * pitch) - -#define INIT_MONO_PIXEL(p, color) \ - p = PACK_COLOR_565( color[0], color[1], color[2] ) - -#define Y_FLIP(_y) (height - _y - 1) - -#define HW_LOCK() - -#define HW_UNLOCK() - -/* 16 bit, 565 rgb color spanline and pixel functions - */ -#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 *)(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 -#include "spantmp.h" - -/* 16 bit depthbuffer functions. - */ -#define VALUE_TYPE GLushort - -#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) i810##x##_z16 -#include "depthtmp.h" - - -/* Move locking out to get reasonable span performance. - */ -void i810SpanRenderStart( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - I810_FIREVERTICES(imesa); - LOCK_HARDWARE(imesa); - i810RegetLockQuiescent( imesa ); -} - -void i810SpanRenderFinish( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - _swrast_flush( ctx ); - UNLOCK_HARDWARE( imesa ); -} - -void i810InitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = i810SpanRenderStart; - swdd->SpanRenderFinish = i810SpanRenderFinish; -} - - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -i810SetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis) -{ - if (drb->Base.InternalFormat == GL_RGBA) { - /* always 565 RGB */ - i810InitPointers_565(&drb->Base); - } - else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) { - i810InitDepthPointers_z16(&drb->Base); - } - else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { - /* should never get here */ - drb->Base.GetRow = NULL; - drb->Base.GetValues = NULL; - drb->Base.PutRow = NULL; - drb->Base.PutMonoRow = NULL; - drb->Base.PutValues = NULL; - drb->Base.PutMonoValues = NULL; - } - else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { - drb->Base.GetRow = NULL; - drb->Base.GetValues = NULL; - drb->Base.PutRow = NULL; - drb->Base.PutMonoRow = NULL; - drb->Base.PutValues = NULL; - drb->Base.PutMonoValues = NULL; - } -} diff --git a/src/mesa/drivers/dri/i810/i810span.h b/src/mesa/drivers/dri/i810/i810span.h deleted file mode 100644 index 184a37a103b..00000000000 --- a/src/mesa/drivers/dri/i810/i810span.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _I810_SPAN_H -#define _I810_SPAN_H - -#include "drirenderbuffer.h" - -extern void i810InitSpanFuncs( struct gl_context *ctx ); - -extern void i810SpanRenderFinish( struct gl_context *ctx ); -extern void i810SpanRenderStart( struct gl_context *ctx ); - -extern void -i810SetSpanFunctions(driRenderbuffer *rb, const struct gl_config *vis); - -#endif diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c deleted file mode 100644 index 6040abf7fac..00000000000 --- a/src/mesa/drivers/dri/i810/i810state.c +++ /dev/null @@ -1,1002 +0,0 @@ - -#include <stdio.h> - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/dd.h" -#include "main/colormac.h" -#include "swrast/swrast.h" -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" -#include "vbo/vbo.h" -#include "swrast_setup/swrast_setup.h" - -#include "texmem.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "i810context.h" -#include "i810state.h" -#include "i810tex.h" -#include "i810ioctl.h" - - -static INLINE GLuint i810PackColor(GLuint format, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a) -{ - - if (I810_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s\n", __FUNCTION__); - - switch (format) { - case DV_PF_555: - return PACK_COLOR_1555( a, r, g, b ); - case DV_PF_565: - return PACK_COLOR_565( r, g, b ); - default: - fprintf(stderr, "unknown format %d\n", (int)format); - return 0; - } -} - - -static void i810AlphaFunc(struct gl_context *ctx, GLenum func, GLfloat ref) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLuint a = (ZA_UPDATE_ALPHAFUNC|ZA_UPDATE_ALPHAREF); - GLubyte refByte; - - CLAMPED_FLOAT_TO_UBYTE(refByte, ref); - - switch (ctx->Color.AlphaFunc) { - case GL_NEVER: a |= ZA_ALPHA_NEVER; break; - case GL_LESS: a |= ZA_ALPHA_LESS; break; - case GL_GEQUAL: a |= ZA_ALPHA_GEQUAL; break; - case GL_LEQUAL: a |= ZA_ALPHA_LEQUAL; break; - case GL_GREATER: a |= ZA_ALPHA_GREATER; break; - case GL_NOTEQUAL: a |= ZA_ALPHA_NOTEQUAL; break; - case GL_EQUAL: a |= ZA_ALPHA_EQUAL; break; - case GL_ALWAYS: a |= ZA_ALPHA_ALWAYS; break; - default: return; - } - - a |= ((refByte & 0xfc) << ZA_ALPHAREF_SHIFT); - - 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 i810BlendEquationSeparate(struct gl_context *ctx, - GLenum modeRGB, GLenum modeA) -{ - assert( modeRGB == modeA ); - - /* Can only do GL_ADD equation in hardware */ - FALLBACK( I810_CONTEXT(ctx), I810_FALLBACK_BLEND_EQ, - modeRGB != GL_FUNC_ADD); - - /* BlendEquation sets ColorLogicOpEnabled in an unexpected - * manner. - */ - FALLBACK( I810_CONTEXT(ctx), I810_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); -} - -static void i810BlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLuint a = SDM_UPDATE_SRC_BLEND | SDM_UPDATE_DST_BLEND; - GLboolean fallback = GL_FALSE; - - switch (ctx->Color.Blend[0].SrcRGB) { - case GL_ZERO: a |= SDM_SRC_ZERO; break; - case GL_ONE: a |= SDM_SRC_ONE; break; - case GL_SRC_COLOR: a |= SDM_SRC_SRC_COLOR; break; - case GL_ONE_MINUS_SRC_COLOR: a |= SDM_SRC_INV_SRC_COLOR; break; - case GL_SRC_ALPHA: a |= SDM_SRC_SRC_ALPHA; break; - 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_DST_COLOR: a |= SDM_SRC_DST_COLOR; break; - case GL_ONE_MINUS_DST_COLOR: a |= SDM_SRC_INV_DST_COLOR; break; - - /* (f, f, f, 1), f = min(As, 1 - Ad) = min(As, 1 - 1) = 0 - * So (f, f, f, 1) = (0, 0, 0, 1). Since there is no destination alpha and - * the only supported alpha operation is GL_FUNC_ADD, the result modulating - * the source alpha with the alpha factor is largely irrelevant. - */ - case GL_SRC_ALPHA_SATURATE: a |= SDM_SRC_ZERO; 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.Blend[0].DstRGB) { - case GL_ZERO: a |= SDM_DST_ZERO; break; - case GL_ONE: a |= SDM_DST_ONE; break; - case GL_SRC_COLOR: a |= SDM_DST_SRC_COLOR; break; - case GL_ONE_MINUS_SRC_COLOR: a |= SDM_DST_INV_SRC_COLOR; break; - case GL_SRC_ALPHA: a |= SDM_DST_SRC_ALPHA; break; - case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_DST_INV_SRC_ALPHA; break; - case GL_DST_ALPHA: a |= SDM_DST_ONE; break; - case GL_ONE_MINUS_DST_ALPHA: a |= SDM_DST_ZERO; break; - case GL_DST_COLOR: a |= SDM_DST_DST_COLOR; break; - case GL_ONE_MINUS_DST_COLOR: a |= SDM_DST_INV_DST_COLOR; 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; - } - - 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; - } -} - - - -static void i810DepthFunc(struct gl_context *ctx, GLenum func) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - int zmode; - - 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_LEQUAL: zmode = LCS_Z_LEQUAL; break; - case GL_EQUAL: zmode = LCS_Z_EQUAL; break; - case GL_GREATER: zmode = LCS_Z_GREATER; break; - case GL_GEQUAL: zmode = LCS_Z_GEQUAL; break; - 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] |= zmode; -} - -static void i810DepthMask(struct gl_context *ctx, GLboolean flag) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - - if (flag) - 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. - */ -static void i810PolygonStipple( struct gl_context *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 && - imesa->reduced_primitive == GL_TRIANGLES); - GLuint newMask; - - if (active) { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE; - } - - p[0] = mask[12] & 0xf; p[0] |= p[0] << 4; - p[1] = mask[8] & 0xf; p[1] |= p[1] << 4; - p[2] = mask[4] & 0xf; p[2] |= p[2] << 4; - 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++) - if (*m++ != p[j]) { - imesa->stipple_in_hw = 0; - return; - } - - newMask = ((p[0] & 0xf) << 0) | - ((p[1] & 0xf) << 4) | - ((p[2] & 0xf) << 8) | - ((p[3] & 0xf) << 12); - - if (newMask == 0xffff) { - /* 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; -} - - - -/* ============================================================= - * Hardware clipping - */ - - -static void i810Scissor( struct gl_context *ctx, GLint x, GLint y, - GLsizei w, GLsizei h ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - - 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.y2 = imesa->driDrawable->h - y; -} - - -static void i810LogicOp( struct gl_context *ctx, GLenum opcode ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - FALLBACK( imesa, I810_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && opcode != GL_COPY) ); -} - -/* Fallback to swrast for select and feedback. - */ -static void i810RenderMode( struct gl_context *ctx, GLenum mode ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - FALLBACK( imesa, I810_FALLBACK_RENDERMODE, (mode != GL_RENDER) ); -} - - -void i810DrawBuffer(struct gl_context *ctx, GLenum mode ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - int front = 0; - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ - FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) { - case BUFFER_FRONT_LEFT: - front = 1; - break; - case BUFFER_BACK_LEFT: - front = 0; - break; - default: - FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - if ( imesa->sarea->pf_current_page == 1 ) - front ^= 1; - - FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_FALSE ); - I810_FIREVERTICES(imesa); - I810_STATECHANGE(imesa, I810_UPLOAD_BUFFERS); - - if (front) - { - imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->fbOffset | - imesa->i810Screen->backPitchBits); - i810XMesaSetFrontClipRects( imesa ); - } - else - { - imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->backOffset | - imesa->i810Screen->backPitchBits); - i810XMesaSetBackClipRects( imesa ); - } -} - - -static void i810ReadBuffer(struct gl_context *ctx, GLenum mode ) -{ - /* XXX anything? */ -} - - -static void i810ClearColor(struct gl_context *ctx, const GLfloat color[4] ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - imesa->ClearColor = i810PackColor( imesa->i810Screen->fbFormat, - c[0], c[1], c[2], c[3] ); -} - - -/* ============================================================= - * Culling - the i810 isn't quite as clean here as the rest of - * its interfaces, but it's not bad. - */ -static void i810CullFaceFrontFace(struct gl_context *ctx, GLenum unused) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLuint mode = LCS_CULL_BOTH; - - if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) { - mode = LCS_CULL_CW; - if (ctx->Polygon.CullFaceMode == GL_FRONT) - mode ^= (LCS_CULL_CW ^ LCS_CULL_CCW); - if (ctx->Polygon.FrontFace != GL_CCW) - mode ^= (LCS_CULL_CW ^ LCS_CULL_CCW); - } - - imesa->LcsCullMode = mode; - - if (ctx->Polygon.CullFlag) - { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK; - imesa->Setup[I810_CTXREG_LCS] |= mode; - } -} - - -static void i810LineWidth( struct gl_context *ctx, GLfloat widthf ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - /* AA, non-AA limits are same */ - const int width = (int) CLAMP(ctx->Line.Width, - ctx->Const.MinLineWidth, - ctx->Const.MaxLineWidth); - - 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 i810PointSize( struct gl_context *ctx, GLfloat sz ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - /* AA, non-AA limits are same */ - const int size = (int) CLAMP(ctx->Point.Size, - ctx->Const.MinPointSize, - ctx->Const.MaxPointSize); - - imesa->LcsPointSize = 0; - if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0; - if (size & 2) imesa->LcsPointSize |= LCS_LINEWIDTH_2_0; - - 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 - */ - -static void i810ColorMask(struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - 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]) { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_B2] = tmp; - imesa->dirty |= I810_UPLOAD_CTX; - } -} - -/* Seperate specular not fully implemented on the i810. - */ -static void i810LightModelfv(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) - { - i810ContextPtr imesa = I810_CONTEXT( ctx ); - FALLBACK( imesa, I810_FALLBACK_SPECULAR, - (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)); - } -} - -/* But the 815 has it... - */ -static void i810LightModelfv_i815(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) - { - i810ContextPtr imesa = I810_CONTEXT( ctx ); - - 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(struct gl_context *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 i810Fogfv(struct gl_context *ctx, GLenum pname, const GLfloat *param) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - - if (pname == GL_FOG_COLOR) { - GLuint color = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) | - ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) | - ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0)); - - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_FOG] = ((GFX_OP_FOG_COLOR | color) & - ~FOG_RESERVED_MASK); - } -} - - -/* ============================================================= - */ -static void i810Enable(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - - switch(cap) { - case GL_ALPHA_TEST: - 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: - 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. - */ - FALLBACK( imesa, I810_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - break; - case GL_DEPTH_TEST: - 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: - /* 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; - break; - case GL_POLYGON_STIPPLE: - if (imesa->stipple_in_hw && imesa->reduced_primitive == GL_TRIANGLES) - { - 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: - /* 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) { - imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE; - imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5; - } - } - break; - case GL_POINT_SMOOTH: - if (imesa->reduced_primitive == GL_POINTS) { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE; - 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 (imesa->reduced_primitive == GL_TRIANGLES) { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE; - if (state) - imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE; - } - break; - case GL_FOG: - 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: - 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: - case GL_TEXTURE_RECTANGLE_NV: - 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_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_COLOR_LOGIC_OP: - 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 i810EmitDrawingRectangle( i810ContextPtr imesa ) -{ - __DRIdrawable *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. - */ - dr4 = imesa->BufferSetup[I810_DESTREG_DR4] = ((y0<<16) | - (((unsigned)x0)&0xFFFF)); - - /* Clip to screen. - */ - if (x0 < 0) x0 = 0; - if (y0 < 0) y0 = 0; - if (x1 > i810Screen->width-1) x1 = i810Screen->width-1; - if (y1 > i810Screen->height-1) y1 = i810Screen->height-1; - - - /* Onscreen drawing rectangle. - */ - 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 i810CalcViewport( struct gl_context *ctx ) -{ - 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( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - i810CalcViewport( ctx ); -} - -static void i810DepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - i810CalcViewport( ctx ); -} - - - -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 i810InitState( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - i810ScreenPrivate *i810Screen = imesa->i810Screen; - - memset(imesa->Setup, 0, sizeof(imesa->Setup)); - - imesa->Setup[I810_CTXREG_VF] = 0; - - imesa->Setup[I810_CTXREG_MT] = (GFX_OP_MAP_TEXELS | - MT_UPDATE_TEXEL1_STATE | - MT_TEXEL1_COORD1 | - MT_TEXEL1_MAP1 | - MT_TEXEL1_DISABLE | - MT_UPDATE_TEXEL0_STATE | - MT_TEXEL0_COORD0 | - MT_TEXEL0_MAP0 | - MT_TEXEL0_DISABLE); - - imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES | - MC_STAGE_0 | - MC_UPDATE_DEST | - MC_DEST_CURRENT | - MC_UPDATE_ARG1 | - ((MC_ARG_ITERATED_COLOR | - MC_ARG_DONT_REPLICATE_ALPHA | - MC_ARG_DONT_INVERT) << MC_ARG1_SHIFT) | - MC_UPDATE_ARG2 | - ((MC_ARG_ONE | - MC_ARG_DONT_REPLICATE_ALPHA | - MC_ARG_DONT_INVERT) << MC_ARG2_SHIFT) | - 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_ARG_ONE | - MC_ARG_DONT_REPLICATE_ALPHA | - MC_ARG_DONT_INVERT) << MC_ARG1_SHIFT) | - MC_UPDATE_ARG2 | - ((MC_ARG_ONE | - MC_ARG_DONT_REPLICATE_ALPHA | - MC_ARG_DONT_INVERT) << MC_ARG2_SHIFT) | - 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_ARG_CURRENT_COLOR | - MC_ARG_REPLICATE_ALPHA | - MC_ARG_DONT_INVERT) << MC_ARG1_SHIFT) | - MC_UPDATE_ARG2 | - ((MC_ARG_ONE | - MC_ARG_DONT_REPLICATE_ALPHA | - MC_ARG_DONT_INVERT) << MC_ARG2_SHIFT) | - MC_UPDATE_OP | - MC_OP_DISABLE ); - - - imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES | - MA_STAGE_0 | - MA_UPDATE_ARG1 | - ((MA_ARG_ITERATED_ALPHA | - MA_ARG_DONT_INVERT) << MA_ARG1_SHIFT) | - MA_UPDATE_ARG2 | - ((MA_ARG_CURRENT_ALPHA | - MA_ARG_DONT_INVERT) << MA_ARG2_SHIFT) | - MA_UPDATE_OP | - MA_OP_ARG1 ); - - - imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES | - MA_STAGE_1 | - MA_UPDATE_ARG1 | - ((MA_ARG_CURRENT_ALPHA | - MA_ARG_DONT_INVERT) << MA_ARG1_SHIFT) | - MA_UPDATE_ARG2 | - ((MA_ARG_CURRENT_ALPHA | - MA_ARG_DONT_INVERT) << MA_ARG2_SHIFT) | - MA_UPDATE_OP | - MA_OP_ARG1 ); - - - imesa->Setup[I810_CTXREG_MA2] = ( GFX_OP_MAP_ALPHA_STAGES | - MA_STAGE_2 | - MA_UPDATE_ARG1 | - ((MA_ARG_CURRENT_ALPHA | - MA_ARG_DONT_INVERT) << MA_ARG1_SHIFT) | - MA_UPDATE_ARG2 | - ((MA_ARG_CURRENT_ALPHA | - MA_ARG_DONT_INVERT) << MA_ARG2_SHIFT) | - MA_UPDATE_OP | - MA_OP_ARG1 ); - - - imesa->Setup[I810_CTXREG_SDM] = ( GFX_OP_SRC_DEST_MONO | - SDM_UPDATE_MONO_ENABLE | - 0 | - SDM_UPDATE_SRC_BLEND | - SDM_SRC_ONE | - SDM_UPDATE_DST_BLEND | - SDM_DST_ZERO ); - - /* Use for colormask: - */ - imesa->Setup[I810_CTXREG_CF0] = GFX_OP_COLOR_FACTOR; - imesa->Setup[I810_CTXREG_CF1] = 0xffffffff; - - imesa->Setup[I810_CTXREG_ZA] = (GFX_OP_ZBIAS_ALPHAFUNC | - ZA_UPDATE_ALPHAFUNC | - ZA_ALPHA_ALWAYS | - ZA_UPDATE_ZBIAS | - 0 | - ZA_UPDATE_ALPHAREF | - 0x0); - - imesa->Setup[I810_CTXREG_FOG] = (GFX_OP_FOG_COLOR | - (0xffffff & ~FOG_RESERVED_MASK)); - - /* Choose a pipe - */ - imesa->Setup[I810_CTXREG_B1] = ( GFX_OP_BOOL_1 | - B1_UPDATE_SPEC_SETUP_ENABLE | - 0 | - B1_UPDATE_ALPHA_SETUP_ENABLE | - B1_ALPHA_SETUP_ENABLE | - B1_UPDATE_CI_KEY_ENABLE | - 0 | - B1_UPDATE_CHROMAKEY_ENABLE | - 0 | - B1_UPDATE_Z_BIAS_ENABLE | - 0 | - B1_UPDATE_SPEC_ENABLE | - 0 | - B1_UPDATE_FOG_ENABLE | - 0 | - B1_UPDATE_ALPHA_TEST_ENABLE | - 0 | - B1_UPDATE_BLEND_ENABLE | - 0 | - B1_UPDATE_Z_TEST_ENABLE | - 0 ); - - imesa->Setup[I810_CTXREG_B2] = ( GFX_OP_BOOL_2 | - B2_UPDATE_MAP_CACHE_ENABLE | - B2_MAP_CACHE_ENABLE | - B2_UPDATE_ALPHA_DITHER_ENABLE | - 0 | - B2_UPDATE_FOG_DITHER_ENABLE | - 0 | - B2_UPDATE_SPEC_DITHER_ENABLE | - 0 | - B2_UPDATE_RGB_DITHER_ENABLE | - B2_RGB_DITHER_ENABLE | - B2_UPDATE_FB_WRITE_ENABLE | - B2_FB_WRITE_ENABLE | - B2_UPDATE_ZB_WRITE_ENABLE | - B2_ZB_WRITE_ENABLE ); - - imesa->Setup[I810_CTXREG_LCS] = ( GFX_OP_LINEWIDTH_CULL_SHADE_MODE | - LCS_UPDATE_ZMODE | - LCS_Z_LESS | - LCS_UPDATE_LINEWIDTH | - LCS_LINEWIDTH_1_0 | - LCS_UPDATE_ALPHA_INTERP | - LCS_ALPHA_INTERP | - LCS_UPDATE_FOG_INTERP | - 0 | - LCS_UPDATE_SPEC_INTERP | - 0 | - LCS_UPDATE_RGB_INTERP | - LCS_RGB_INTERP | - LCS_UPDATE_CULL_MODE | - 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_PV1 | - PV_UPDATE_TRIFAN | - PV_TRIFAN_PV2 | - PV_UPDATE_TRISTRIP | - PV_TRISTRIP_PV2 ); - - - imesa->Setup[I810_CTXREG_ST0] = GFX_OP_STIPPLE; - imesa->Setup[I810_CTXREG_ST1] = 0; - - imesa->Setup[I810_CTXREG_AA] = ( GFX_OP_ANTIALIAS | - AA_UPDATE_EDGEFLAG | - 0 | - AA_UPDATE_POLYWIDTH | - AA_POLYWIDTH_05 | - AA_UPDATE_LINEWIDTH | - AA_LINEWIDTH_05 | - AA_UPDATE_BB_EXPANSION | - 0 | - AA_UPDATE_AA_ENABLE | - 0 ); - - memset(imesa->BufferSetup, 0, sizeof(imesa->BufferSetup)); - imesa->BufferSetup[I810_DESTREG_DI0] = CMD_OP_DESTBUFFER_INFO; - - if (imesa->glCtx->Visual.doubleBufferMode && imesa->sarea->pf_current_page == 0) { - /* use back buffer by default */ - imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset | - i810Screen->backPitchBits); - } else { - /* use front buffer by default */ - imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset | - i810Screen->backPitchBits); - } - - imesa->BufferSetup[I810_DESTREG_DV0] = GFX_OP_DESTBUFFER_VARS; - imesa->BufferSetup[I810_DESTREG_DV1] = (DV_HORG_BIAS_OGL | - DV_VORG_BIAS_OGL | - i810Screen->fbFormat); - - imesa->BufferSetup[I810_DESTREG_DR0] = GFX_OP_DRAWRECT_INFO; - imesa->BufferSetup[I810_DESTREG_DR1] = DR1_RECT_CLIP_ENABLE; -} - - -static void i810InvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - I810_CONTEXT(ctx)->new_state |= new_state; -} - - -void i810InitStateFuncs(struct gl_context *ctx) -{ - /* Callbacks for internal Mesa events. - */ - ctx->Driver.UpdateState = i810InvalidateState; - - /* API callbacks - */ - ctx->Driver.AlphaFunc = i810AlphaFunc; - ctx->Driver.BlendEquationSeparate = i810BlendEquationSeparate; - 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.DrawBuffer = i810DrawBuffer; - ctx->Driver.ReadBuffer = i810ReadBuffer; - 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 = i810LightModelfv_i815; - } else { - ctx->Driver.LightModelfv = i810LightModelfv; - } -} diff --git a/src/mesa/drivers/dri/i810/i810state.h b/src/mesa/drivers/dri/i810/i810state.h deleted file mode 100644 index 96af1237651..00000000000 --- a/src/mesa/drivers/dri/i810/i810state.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _I810_STATE_H -#define _I810_STATE_H - -#include "i810context.h" - -extern void i810InitState( struct gl_context *ctx ); -extern void i810InitStateFuncs( struct gl_context *ctx ); -extern void i810PrintDirty( const char *msg, GLuint state ); -extern void i810DrawBuffer(struct gl_context *ctx, GLenum mode ); - -extern void i810Fallback( i810ContextPtr imesa, GLuint bit, GLboolean mode ); -#define FALLBACK( imesa, bit, mode ) i810Fallback( imesa, bit, mode ) - - -#endif diff --git a/src/mesa/drivers/dri/i810/i810tex.c b/src/mesa/drivers/dri/i810/i810tex.c deleted file mode 100644 index dba4ebaa5c7..00000000000 --- a/src/mesa/drivers/dri/i810/i810tex.c +++ /dev/null @@ -1,546 +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. - * - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/texstore.h" -#include "main/teximage.h" -#include "main/texobj.h" -#include "main/colormac.h" -#include "main/mm.h" - -#include "texmem.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "i810context.h" -#include "i810tex.h" -#include "i810ioctl.h" - - -/* - * 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 tex, - GLenum swrap, GLenum twrap) -{ - tex->Setup[I810_TEXREG_MCS] &= ~(MCS_U_STATE_MASK| MCS_V_STATE_MASK); - - switch( swrap ) { - case GL_REPEAT: - tex->Setup[I810_TEXREG_MCS] |= MCS_U_WRAP; - break; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - tex->Setup[I810_TEXREG_MCS] |= MCS_U_CLAMP; - break; - case GL_MIRRORED_REPEAT: - tex->Setup[I810_TEXREG_MCS] |= MCS_U_MIRROR; - break; - default: - _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__); - } - - switch( twrap ) { - case GL_REPEAT: - tex->Setup[I810_TEXREG_MCS] |= MCS_V_WRAP; - break; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - tex->Setup[I810_TEXREG_MCS] |= MCS_V_CLAMP; - break; - case GL_MIRRORED_REPEAT: - tex->Setup[I810_TEXREG_MCS] |= MCS_V_MIRROR; - break; - default: - _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__); - } -} - - -static void i810SetTexFilter(i810ContextPtr imesa, - i810TextureObjectPtr t, - GLenum minf, GLenum magf, - GLfloat bias) -{ - 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: - t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_NONE; - break; - case GL_LINEAR: - t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_NONE; - break; - case GL_NEAREST_MIPMAP_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: - t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_NEAREST; - break; - case GL_NEAREST_MIPMAP_LINEAR: - 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)) - 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: - return; - } - - switch (magf) { - case GL_NEAREST: - t->Setup[I810_TEXREG_MF] |= MF_MAG_NEAREST; - break; - case GL_LINEAR: - t->Setup[I810_TEXREG_MF] |= MF_MAG_LINEAR; - break; - default: - return; - } - - t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(bias); -} - - -static void -i810SetTexBorderColor( i810TextureObjectPtr t, const GLfloat color[4] ) -{ - /* Need a fallback. - */ -} - - -static i810TextureObjectPtr -i810AllocTexObj( struct gl_context *ctx, struct gl_texture_object *texObj ) -{ - i810TextureObjectPtr t; - i810ContextPtr imesa = I810_CONTEXT(ctx); - - t = CALLOC_STRUCT( i810_texture_object_t ); - texObj->DriverData = t; - if ( t != NULL ) { - GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias; - /* Initialize non-image-dependent parts of the state: - */ - t->base.tObj = texObj; - 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); - - make_empty_list( & t->base ); - - i810SetTexWrapping( t, texObj->Sampler.WrapS, texObj->Sampler.WrapT ); - /*i830SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );*/ - i810SetTexFilter( imesa, t, texObj->Sampler.MinFilter, texObj->Sampler.MagFilter, bias ); - i810SetTexBorderColor( t, texObj->Sampler.BorderColor.f ); - } - - return t; -} - - -static void i810TexParameter( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData; - - if (!t) - return; - - if ( target != GL_TEXTURE_2D ) - return; - - /* 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->Sampler.MinFilter, tObj->Sampler.MagFilter, bias ); - } - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - i810SetTexWrapping( t, tObj->Sampler.WrapS, tObj->Sampler.WrapT ); - break; - - case GL_TEXTURE_BORDER_COLOR: - i810SetTexBorderColor( t, tObj->Sampler.BorderColor.f ); - 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. - */ - I810_FIREVERTICES( I810_CONTEXT(ctx) ); - driSwapOutTextureObject( (driTextureObject *) t ); - break; - - default: - return; - } - - if (t == imesa->CurrentTexObj[0]) { - I810_STATECHANGE( imesa, I810_UPLOAD_TEX0 ); - } - - if (t == imesa->CurrentTexObj[1]) { - I810_STATECHANGE( imesa, I810_UPLOAD_TEX1 ); - } -} - - -/** - * Setup hardware bits for new texture environment settings. - * - * \todo - * Determine whether or not \c param can be used instead of - * \c texUnit->EnvColor in the \c GL_TEXTURE_ENV_COLOR case. - */ -static void i810TexEnv( struct gl_context *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - const GLuint unit = ctx->Texture.CurrentUnit; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - - /* 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: { - GLubyte c[4]; - GLuint envColor; - - UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor ); - envColor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] ); - - if (imesa->Setup[I810_CTXREG_CF1] != envColor) { - I810_STATECHANGE(imesa, I810_UPLOAD_CTX); - imesa->Setup[I810_CTXREG_CF1] = envColor; - } - break; - } - - case GL_TEXTURE_ENV_MODE: - imesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */ - break; - - case GL_TEXTURE_LOD_BIAS: { - if ( texUnit->_Current != NULL ) { - const struct gl_texture_object *tObj = texUnit->_Current; - i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData; - - t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK); - t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param); - } - break; - } - - default: - break; - } -} - - - -#if 0 -static void i810TexImage1D( struct gl_context *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) { - i810SwapOutTexObj( imesa, t ); - } -} - -static void i810TexSubImage1D( struct gl_context *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 ) -{ -} -#endif - - -static void i810TexImage2D( struct gl_context *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 ) -{ - driTextureObject *t = (driTextureObject *) texObj->DriverData; - if (t) { - I810_FIREVERTICES( I810_CONTEXT(ctx) ); - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) i810AllocTexObj( ctx, texObj ); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - _mesa_store_teximage2d( ctx, target, level, internalFormat, - width, height, border, format, type, - pixels, packing, texObj, texImage ); -} - -static void i810TexSubImage2D( struct gl_context *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 ) -{ - driTextureObject *t = (driTextureObject *)texObj->DriverData; - if (t) { - I810_FIREVERTICES( I810_CONTEXT(ctx) ); - driSwapOutTextureObject( t ); - } - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); -} - - -static void i810BindTexture( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - assert( (target != GL_TEXTURE_2D) || (tObj->DriverData != NULL) ); -} - - -static void i810DeleteTexture( struct gl_context *ctx, struct gl_texture_object *tObj ) -{ - driTextureObject * t = (driTextureObject *) tObj->DriverData; - if (t) { - i810ContextPtr imesa = I810_CONTEXT( ctx ); - if (imesa) - I810_FIREVERTICES( imesa ); - driDestroyTextureObject( t ); - } - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); -} - -/** - * Choose a Mesa texture format to match the requested format. - * - * The i810 only supports 5 texture modes that are useful to Mesa. That - * makes this routine pretty simple. - */ -static gl_format -i810ChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - switch ( internalFormat ) { - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - case GL_COMPRESSED_RGBA: - if ( ((format == GL_BGRA) && (type == GL_UNSIGNED_SHORT_1_5_5_5_REV)) - || ((format == GL_RGBA) && (type == GL_UNSIGNED_SHORT_5_5_5_1)) - || (internalFormat == GL_RGB5_A1) ) { - return MESA_FORMAT_ARGB1555; - } - return MESA_FORMAT_ARGB4444; - - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return MESA_FORMAT_RGB565; - - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - case 2: - case GL_LUMINANCE_ALPHA: - 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 GL_COMPRESSED_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return MESA_FORMAT_AL88; - - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_MESA || - type == GL_UNSIGNED_BYTE) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - - default: - fprintf(stderr, "unexpected texture format in %s\n", __FUNCTION__); - return MESA_FORMAT_NONE; - } - - return MESA_FORMAT_NONE; /* never get here */ -} - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -i810NewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - i810AllocTexObj( ctx, obj ); - return obj; -} - -void i810InitTextureFuncs( struct dd_function_table *functions ) -{ - functions->ChooseTextureFormat = i810ChooseTextureFormat; - functions->TexImage2D = i810TexImage2D; - functions->TexSubImage2D = i810TexSubImage2D; - functions->BindTexture = i810BindTexture; - functions->NewTextureObject = i810NewTextureObject; - functions->DeleteTexture = i810DeleteTexture; - functions->TexParameter = i810TexParameter; - functions->TexEnv = i810TexEnv; - functions->IsTextureResident = driIsTextureResident; -} diff --git a/src/mesa/drivers/dri/i810/i810tex.h b/src/mesa/drivers/dri/i810/i810tex.h deleted file mode 100644 index b396848b79f..00000000000 --- a/src/mesa/drivers/dri/i810/i810tex.h +++ /dev/null @@ -1,77 +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. - * - * - */ - -#ifndef I810TEX_INC -#define I810TEX_INC - -#include "main/mtypes.h" -#include "main/mm.h" - -#include "i810_3d_reg.h" -#include "texmem.h" - -#define I810_TEX_MAXLEVELS 11 - -/* 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 i810_texture_object_t { - driTextureObject base; - - int Pitch; - int Height; - int texelBytes; - char *BufAddr; - - GLuint max_level; - - struct { - const struct gl_texture_image *image; - int offset; /* into BufAddr */ - int height; - int internalFormat; - } image[I810_TEX_MAXLEVELS]; - - GLuint Setup[I810_TEX_SETUP_SIZE]; - GLuint dirty; - -}; - -void i810UpdateTextureState( struct gl_context *ctx ); -void i810InitTextureFuncs( struct dd_function_table *functions ); - -void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t ); -int i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t ); - -#endif diff --git a/src/mesa/drivers/dri/i810/i810texmem.c b/src/mesa/drivers/dri/i810/i810texmem.c deleted file mode 100644 index 6e6b21cf2b9..00000000000 --- a/src/mesa/drivers/dri/i810/i810texmem.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * GLX Hardware Device Driver for Intel i810 - * Copyright (C) 1999 Keith Whitwell - * Texmem interface changes (C) 2003 Dave Airlie - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/colormac.h" -#include "main/mm.h" - -#include "i810screen.h" -#include "i810_dri.h" -#include "i810context.h" -#include "i810tex.h" -#include "i810ioctl.h" - - -void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t) -{ - /* See if it was the driver's current object. - */ - if ( imesa != NULL ) { - 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; - } - } -} - - - -#if defined(i386) || defined(__i386__) -/* From linux kernel i386 header files, copes with odd sizes better - * than COPY_DWORDS would: - */ -static INLINE void * __memcpy(void * to, const void * from, size_t n) -{ -int d0, d1, d2; -__asm__ __volatile__( - "rep ; movsl\n\t" - "testb $2,%b4\n\t" - "je 1f\n\t" - "movsw\n" - "1:\ttestb $1,%b4\n\t" - "je 2f\n\t" - "movsb\n" - "2:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) - : "memory"); -return (to); -} -#else -/* Allow compilation on other architectures */ -#define __memcpy memcpy -#endif - -/* Upload an image from mesa's internal copy. - */ -static void i810UploadTexLevel( i810ContextPtr imesa, - i810TextureObjectPtr t, int hwlevel ) -{ - const struct gl_texture_image *image = t->image[hwlevel].image; - int j; - GLuint texelBytes; - - if (!image || !image->Data) - return; - - texelBytes = _mesa_get_format_bytes(image->TexFormat); - - if (image->Width * texelBytes == t->Pitch) { - GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset); - GLubyte *src = (GLubyte *)image->Data; - - memcpy( dst, src, t->Pitch * image->Height ); - } - else { - switch (texelBytes) { - case 1: - { - GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset); - GLubyte *src = (GLubyte *)image->Data; - - for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) { - __memcpy(dst, src, image->Width ); - src += image->Width; - } - } - break; - case 2: - { - GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset); - GLushort *src = (GLushort *)image->Data; - - for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) { - __memcpy(dst, src, image->Width * 2 ); - src += image->Width; - } - } - break; - default: - fprintf(stderr, "%s: Not supported texel size %d\n", - __FUNCTION__, texelBytes); - } - } -} - -/* 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 i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t ) -{ - int i; - int ofs; - int numLevels; - - /* Do we need to eject LRU texture objects? - */ - if (!t->base.memBlock) { - int heap; - - heap = driAllocateTexture( imesa->texture_heaps, imesa->nr_heaps, - (driTextureObject *) t); - - if ( heap == -1 ) { - return -1; - } - - assert(t->base.memBlock); - ofs = t->base.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 );*/ - } - driUpdateTextureLRU( (driTextureObject *) t ); - - if (imesa->texture_heaps[0]->timestamp >= GET_DISPATCH_AGE(imesa)) - i810WaitAgeLocked( imesa, imesa->texture_heaps[0]->timestamp ); - - numLevels = t->base.lastLevel - t->base.firstLevel + 1; - for (i = 0 ; i < numLevels ; i++) - if (t->base.dirty_images[0] & (1<<i)) - i810UploadTexLevel( imesa, t, i ); - - t->base.dirty_images[0] = 0; - - return 0; -} diff --git a/src/mesa/drivers/dri/i810/i810texstate.c b/src/mesa/drivers/dri/i810/i810texstate.c deleted file mode 100644 index 5b505e71a48..00000000000 --- a/src/mesa/drivers/dri/i810/i810texstate.c +++ /dev/null @@ -1,750 +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. - * - */ - -#include "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/mm.h" - -#include "i810screen.h" -#include "i810_dri.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[0][tObj->BaseLevel]; - GLint numLevels; - GLint log2Width, log2Height; - -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - t->texelBytes = 2; - switch (baseImage->TexFormat) { - case MESA_FORMAT_ARGB1555: - textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB1555; - break; - case MESA_FORMAT_ARGB4444: - textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB4444; - break; - case MESA_FORMAT_RGB565: - textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_RGB565; - break; - case MESA_FORMAT_AL88: - textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_AY88; - break; - case MESA_FORMAT_YCBCR: - textureFormat = MI1_FMT_422 | MI1_PF_422_YCRCB_SWAP_Y - | MI1_COLOR_CONV_ENABLE; - break; - case MESA_FORMAT_YCBCR_REV: - textureFormat = MI1_FMT_422 | MI1_PF_422_YCRCB - | MI1_COLOR_CONV_ENABLE; - break; - case MESA_FORMAT_CI8: - textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444; - t->texelBytes = 1; - break; - - default: - fprintf(stderr, "i810SetTexImages: bad image->Format\n" ); - return; - } - - driCalculateTextureFirstLastLevel( (driTextureObject *) t ); - - numLevels = t->base.lastLevel - t->base.firstLevel + 1; - - log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2; - log2Height = tObj->Image[0][t->base.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[0][t->base.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[0][t->base.firstLevel + i]; - t->image[i].offset = height * pitch; - t->image[i].internalFormat = baseImage->_BaseFormat; - height += t->image[i].image->Height; - } - - t->Pitch = pitch; - t->base.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_MLL] = (GFX_OP_MAP_LOD_LIMITS | - MLL_MAP_0 | - MLL_UPDATE_MAX_MIP | - MLL_UPDATE_MIN_MIP | - ((numLevels - 1) << MLL_MIN_MIP_SHIFT)); - - LOCK_HARDWARE( imesa ); - i810UploadTexImagesLocked( imesa, t ); - UNLOCK_HARDWARE( imesa ); -} - -/* ================================================================ - * Texture combine functions - */ - - -static void set_color_stage( unsigned color, int stage, - i810ContextPtr imesa ) -{ - if ( color != imesa->Setup[I810_CTXREG_MC0 + stage] ) { - I810_STATECHANGE( imesa, I810_UPLOAD_CTX ); - imesa->Setup[I810_CTXREG_MC0 + stage] = color; - } -} - - -static void set_alpha_stage( unsigned alpha, int stage, - i810ContextPtr imesa ) -{ - if ( alpha != imesa->Setup[I810_CTXREG_MA0 + stage] ) { - I810_STATECHANGE( imesa, I810_UPLOAD_CTX ); - imesa->Setup[I810_CTXREG_MA0 + stage] = alpha; - } -} - - -static const unsigned operand_modifiers[] = { - 0, MC_ARG_INVERT, - MC_ARG_REPLICATE_ALPHA, MC_ARG_INVERT | MC_ARG_REPLICATE_ALPHA -}; - -/** - * Configure the hardware bits for the specified texture environment. - * - * Configures the hardware bits for the texture environment state for the - * specified texture unit. As combine stages are added, the values pointed - * to by \c color_stage and \c alpha_stage are incremented. - * - * \param ctx GL context pointer. - * \param unit Texture unit to be added. - * \param color_stage Next available hardware color combine stage. - * \param alpha_stage Next available hardware alpha combine stage. - * - * \returns - * If the combine mode for the specified texture unit could be added without - * requiring a software fallback, \c GL_TRUE is returned. Otherwise, - * \c GL_FALSE is returned. - * - * \todo - * If the mode is (GL_REPLACE, GL_PREVIOUS), treat it as though the texture - * stage is disabled. That is, don't emit any combine stages. - * - * \todo - * Add support for ATI_texture_env_combine3 modes. This will require using - * two combine stages. - * - * \todo - * Add support for the missing \c GL_INTERPOLATE modes. This will require - * using all three combine stages. There is a comment in the function - * describing how this might work. - * - * \todo - * If, after all the combine stages have been emitted, a texture is never - * actually used, disable the texture unit. That should save texture some - * memory bandwidth. This won't happen in this function, but this seems like - * a reasonable place to make note of it. - */ -static GLboolean -i810UpdateTexEnvCombine( struct gl_context *ctx, GLuint unit, - int * color_stage, int * alpha_stage ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint color_arg[3] = { - MC_ARG_ONE, MC_ARG_ONE, MC_ARG_ONE - }; - GLuint alpha_arg[3] = { - MA_ARG_ITERATED_ALPHA, MA_ARG_ITERATED_ALPHA, MA_ARG_ITERATED_ALPHA - }; - GLuint i; - GLuint color_combine, alpha_combine; - const GLuint numColorArgs = texUnit->_CurrentCombine->_NumArgsRGB; - const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA; - GLuint RGBshift = texUnit->_CurrentCombine->ScaleShiftRGB; - GLuint Ashift = texUnit->_CurrentCombine->ScaleShiftA; - - - if ( !texUnit->_ReallyEnabled ) { - return GL_TRUE; - } - - - if ((*color_stage >= 3) || (*alpha_stage >= 3)) { - return GL_FALSE; - } - - - /* Step 1: - * Extract the color and alpha combine function arguments. - */ - - for ( i = 0 ; i < numColorArgs ; i++ ) { - unsigned op = texUnit->_CurrentCombine->OperandRGB[i] - GL_SRC_COLOR; - assert(op >= 0); - assert(op <= 3); - switch ( texUnit->_CurrentCombine->SourceRGB[i] ) { - case GL_TEXTURE0: - color_arg[i] = MC_ARG_TEX0_COLOR; - break; - case GL_TEXTURE1: - color_arg[i] = MC_ARG_TEX1_COLOR; - break; - case GL_TEXTURE: - color_arg[i] = (unit == 0) - ? MC_ARG_TEX0_COLOR : MC_ARG_TEX1_COLOR; - break; - case GL_CONSTANT: - color_arg[i] = MC_ARG_COLOR_FACTOR; - break; - case GL_PRIMARY_COLOR: - color_arg[i] = MC_ARG_ITERATED_COLOR; - break; - case GL_PREVIOUS: - color_arg[i] = (unit == 0) - ? MC_ARG_ITERATED_COLOR : MC_ARG_CURRENT_COLOR; - break; - case GL_ZERO: - /* Toggle the low bit of the op value. The is the 'invert' bit, - * and it acts to convert GL_ZERO+op to the equivalent GL_ONE+op. - */ - op ^= 1; - - /*FALLTHROUGH*/ - - case GL_ONE: - color_arg[i] = MC_ARG_ONE; - break; - default: - return GL_FALSE; - } - - color_arg[i] |= operand_modifiers[op]; - } - - - for ( i = 0 ; i < numAlphaArgs ; i++ ) { - unsigned op = texUnit->_CurrentCombine->OperandA[i] - GL_SRC_ALPHA; - assert(op >= 0); - assert(op <= 1); - switch ( texUnit->_CurrentCombine->SourceA[i] ) { - case GL_TEXTURE0: - alpha_arg[i] = MA_ARG_TEX0_ALPHA; - break; - case GL_TEXTURE1: - alpha_arg[i] = MA_ARG_TEX1_ALPHA; - break; - case GL_TEXTURE: - alpha_arg[i] = (unit == 0) - ? MA_ARG_TEX0_ALPHA : MA_ARG_TEX1_ALPHA; - break; - case GL_CONSTANT: - alpha_arg[i] = MA_ARG_ALPHA_FACTOR; - break; - case GL_PRIMARY_COLOR: - alpha_arg[i] = MA_ARG_ITERATED_ALPHA; - break; - case GL_PREVIOUS: - alpha_arg[i] = (unit == 0) - ? MA_ARG_ITERATED_ALPHA : MA_ARG_CURRENT_ALPHA; - break; - case GL_ZERO: - /* Toggle the low bit of the op value. The is the 'invert' bit, - * and it acts to convert GL_ZERO+op to the equivalent GL_ONE+op. - */ - op ^= 1; - - /*FALLTHROUGH*/ - - case GL_ONE: - if (i != 2) { - return GL_FALSE; - } - - alpha_arg[i] = MA_ARG_ONE; - break; - default: - return GL_FALSE; - } - - alpha_arg[i] |= operand_modifiers[op]; - } - - - /* Step 2: - * Build up the color and alpha combine functions. - */ - switch ( texUnit->_CurrentCombine->ModeRGB ) { - case GL_REPLACE: - color_combine = MC_OP_ARG1; - break; - case GL_MODULATE: - color_combine = MC_OP_MODULATE + RGBshift; - RGBshift = 0; - break; - case GL_ADD: - color_combine = MC_OP_ADD; - break; - case GL_ADD_SIGNED: - color_combine = MC_OP_ADD_SIGNED; - break; - case GL_SUBTRACT: - color_combine = MC_OP_SUBTRACT; - break; - case GL_INTERPOLATE: - /* For interpolation, the i810 hardware has some limitations. It - * can't handle using the secondary or diffuse color (diffuse alpha - * is okay) for the third argument. - * - * It is possible to emulate the missing modes by using multiple - * combine stages. Unfortunately it requires all three stages to - * emulate a single interpolate stage. The (arg0*arg2) portion is - * done in stage zero and writes to MC_DEST_ACCUMULATOR. The - * (arg1*(1-arg2)) portion is done in stage 1, and the final stage is - * (MC_ARG1_ACCUMULATOR | MC_ARG2_CURRENT_COLOR | MC_OP_ADD). - * - * It can also be done without using the accumulator by rearranging - * the equation as (arg1 + (arg2 * (arg0 - arg1))). Too bad the i810 - * doesn't support the MODULATE_AND_ADD mode that the i830 supports. - * If it did, the interpolate could be done in only two stages. - */ - - if ( (color_arg[2] & MC_ARG_INVERT) != 0 ) { - unsigned temp = color_arg[0]; - - color_arg[0] = color_arg[1]; - color_arg[1] = temp; - color_arg[2] &= ~MC_ARG_INVERT; - } - - switch (color_arg[2]) { - case (MC_ARG_ONE): - case (MC_ARG_ONE | MC_ARG_REPLICATE_ALPHA): - color_combine = MC_OP_ARG1; - color_arg[1] = MC_ARG_ONE; - break; - - case (MC_ARG_COLOR_FACTOR): - return GL_FALSE; - - case (MC_ARG_COLOR_FACTOR | MC_ARG_REPLICATE_ALPHA): - color_combine = MC_OP_LIN_BLEND_ALPHA_FACTOR; - break; - - case (MC_ARG_ITERATED_COLOR): - return GL_FALSE; - - case (MC_ARG_ITERATED_COLOR | MC_ARG_REPLICATE_ALPHA): - color_combine = MC_OP_LIN_BLEND_ITER_ALPHA; - break; - - case (MC_ARG_SPECULAR_COLOR): - case (MC_ARG_SPECULAR_COLOR | MC_ARG_REPLICATE_ALPHA): - return GL_FALSE; - - case (MC_ARG_TEX0_COLOR): - color_combine = MC_OP_LIN_BLEND_TEX0_COLOR; - break; - - case (MC_ARG_TEX0_COLOR | MC_ARG_REPLICATE_ALPHA): - color_combine = MC_OP_LIN_BLEND_TEX0_ALPHA; - break; - - case (MC_ARG_TEX1_COLOR): - color_combine = MC_OP_LIN_BLEND_TEX1_COLOR; - break; - - case (MC_ARG_TEX1_COLOR | MC_ARG_REPLICATE_ALPHA): - color_combine = MC_OP_LIN_BLEND_TEX1_ALPHA; - break; - - default: - return GL_FALSE; - } - break; - - default: - return GL_FALSE; - } - - - switch ( texUnit->_CurrentCombine->ModeA ) { - case GL_REPLACE: - alpha_combine = MA_OP_ARG1; - break; - case GL_MODULATE: - alpha_combine = MA_OP_MODULATE + Ashift; - Ashift = 0; - break; - case GL_ADD: - alpha_combine = MA_OP_ADD; - break; - case GL_ADD_SIGNED: - alpha_combine = MA_OP_ADD_SIGNED; - break; - case GL_SUBTRACT: - alpha_combine = MA_OP_SUBTRACT; - break; - case GL_INTERPOLATE: - if ( (alpha_arg[2] & MA_ARG_INVERT) != 0 ) { - unsigned temp = alpha_arg[0]; - - alpha_arg[0] = alpha_arg[1]; - alpha_arg[1] = temp; - alpha_arg[2] &= ~MA_ARG_INVERT; - } - - switch (alpha_arg[2]) { - case MA_ARG_ONE: - alpha_combine = MA_OP_ARG1; - alpha_arg[1] = MA_ARG_ITERATED_ALPHA; - break; - - case MA_ARG_ALPHA_FACTOR: - alpha_combine = MA_OP_LIN_BLEND_ALPHA_FACTOR; - break; - - case MA_ARG_ITERATED_ALPHA: - alpha_combine = MA_OP_LIN_BLEND_ITER_ALPHA; - break; - - case MA_ARG_TEX0_ALPHA: - alpha_combine = MA_OP_LIN_BLEND_TEX0_ALPHA; - break; - - case MA_ARG_TEX1_ALPHA: - alpha_combine = MA_OP_LIN_BLEND_TEX1_ALPHA; - break; - - default: - return GL_FALSE; - } - break; - - default: - return GL_FALSE; - } - - - color_combine |= GFX_OP_MAP_COLOR_STAGES | (*color_stage << MC_STAGE_SHIFT) - | MC_UPDATE_DEST | MC_DEST_CURRENT - | MC_UPDATE_ARG1 | (color_arg[0] << MC_ARG1_SHIFT) - | MC_UPDATE_ARG2 | (color_arg[1] << MC_ARG2_SHIFT) - | MC_UPDATE_OP; - - alpha_combine |= GFX_OP_MAP_ALPHA_STAGES | (*alpha_stage << MA_STAGE_SHIFT) - | MA_UPDATE_ARG1 | (alpha_arg[0] << MA_ARG1_SHIFT) - | MA_UPDATE_ARG2 | (alpha_arg[1] << MA_ARG2_SHIFT) - | MA_UPDATE_OP; - - set_color_stage( color_combine, *color_stage, imesa ); - set_alpha_stage( alpha_combine, *alpha_stage, imesa ); - (*color_stage)++; - (*alpha_stage)++; - - - /* Step 3: - * Apply the scale factor. - */ - /* The only operation where the i810 directly supports adding a post- - * scale factor is modulate. For all the other modes the post-scale is - * emulated by inserting and extra modulate stage. For the modulate - * case, the scaling is handled above when color_combine / alpha_combine - * are initially set. - */ - - if ( RGBshift != 0 ) { - const unsigned color_scale = GFX_OP_MAP_COLOR_STAGES - | (*color_stage << MC_STAGE_SHIFT) - | MC_UPDATE_DEST | MC_DEST_CURRENT - | MC_UPDATE_ARG1 | (MC_ARG_CURRENT_COLOR << MC_ARG1_SHIFT) - | MC_UPDATE_ARG2 | (MC_ARG_ONE << MC_ARG2_SHIFT) - | MC_UPDATE_OP | (MC_OP_MODULATE + RGBshift); - - if ( *color_stage >= 3 ) { - return GL_FALSE; - } - - set_color_stage( color_scale, *color_stage, imesa ); - (*color_stage)++; - } - - - if ( Ashift != 0 ) { - const unsigned alpha_scale = GFX_OP_MAP_ALPHA_STAGES - | (*alpha_stage << MA_STAGE_SHIFT) - | MA_UPDATE_ARG1 | (MA_ARG_CURRENT_ALPHA << MA_ARG1_SHIFT) - | MA_UPDATE_ARG2 | (MA_ARG_ONE << MA_ARG2_SHIFT) - | MA_UPDATE_OP | (MA_OP_MODULATE + Ashift); - - if ( *alpha_stage >= 3 ) { - return GL_FALSE; - } - - set_alpha_stage( alpha_scale, *alpha_stage, imesa ); - (*alpha_stage)++; - } - - return GL_TRUE; -} - -static GLboolean enable_tex_common( struct gl_context *ctx, GLuint unit ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - struct gl_texture_object *tObj = texUnit->_Current; - i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData; - - if (tObj->Image[0][tObj->BaseLevel]->Border > 0) { - return GL_FALSE; - } - - /* Upload teximages (not pipelined) - */ - if (t->base.dirty_images[0]) { - I810_FIREVERTICES(imesa); - i810SetTexImages( imesa, tObj ); - if (!t->base.memBlock) { - return GL_FALSE; - } - } - - /* 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; - t->base.bound |= (1U << unit); - - /* XXX: should be locked */ - driUpdateTextureLRU( (driTextureObject *) t ); - } - - imesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - return GL_TRUE; -} - -static GLboolean enable_tex_rect( struct gl_context *ctx, GLuint unit ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - struct gl_texture_object *tObj = texUnit->_Current; - i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData; - GLint Width, Height; - - Width = tObj->Image[0][t->base.firstLevel]->Width - 1; - Height = tObj->Image[0][t->base.firstLevel]->Height - 1; - - I810_STATECHANGE(imesa, (I810_UPLOAD_TEX0<<unit)); - t->Setup[I810_TEXREG_MCS] &= ~MCS_NORMALIZED_COORDS; - t->Setup[I810_TEXREG_MCS] |= MCS_UPDATE_NORMALIZED; - t->Setup[I810_TEXREG_MI2] = (MI2_DIMENSIONS_ARE_EXACT | - (Height << MI2_HEIGHT_SHIFT) | Width); - - return GL_TRUE; -} - -static GLboolean enable_tex_2d( struct gl_context *ctx, GLuint unit ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - struct gl_texture_object *tObj = texUnit->_Current; - i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData; - GLint log2Width, log2Height; - - - log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2; - log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2; - - I810_STATECHANGE(imesa, (I810_UPLOAD_TEX0<<unit)); - t->Setup[I810_TEXREG_MCS] |= MCS_NORMALIZED_COORDS | MCS_UPDATE_NORMALIZED; - t->Setup[I810_TEXREG_MI2] = (MI2_DIMENSIONS_ARE_LOG2 | - (log2Height << MI2_HEIGHT_SHIFT) | log2Width); - - return GL_TRUE; -} - -static void disable_tex( struct gl_context *ctx, GLuint unit ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - - imesa->CurrentTexObj[unit] = 0; - imesa->TexEnvImageFmt[unit] = 0; - imesa->dirty &= ~(I810_UPLOAD_TEX0<<unit); - -} - -/** - * Update hardware state for a texture unit. - * - * \todo - * 1D textures should be supported! Just use a 2D texture with the second - * texture coordinate value fixed at 0.0. - */ -static void i810UpdateTexUnit( struct gl_context *ctx, GLuint unit, - int * next_color_stage, int * next_alpha_stage ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLboolean ret; - - switch(texUnit->_ReallyEnabled) { - case TEXTURE_2D_BIT: - ret = enable_tex_common( ctx, unit); - ret &= enable_tex_2d(ctx, unit); - if (ret == GL_FALSE) { - FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE ); - } - break; - case TEXTURE_RECT_BIT: - ret = enable_tex_common( ctx, unit); - ret &= enable_tex_rect(ctx, unit); - if (ret == GL_FALSE) { - FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE ); - } - break; - case 0: - disable_tex(ctx, unit); - break; - } - - - if (!i810UpdateTexEnvCombine( ctx, unit, - next_color_stage, next_alpha_stage )) { - FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE ); - } - - return; -} - - -void i810UpdateTextureState( struct gl_context *ctx ) -{ - static const unsigned color_pass[3] = { - GFX_OP_MAP_COLOR_STAGES | MC_STAGE_0 | MC_UPDATE_DEST | MC_DEST_CURRENT - | MC_UPDATE_ARG1 | (MC_ARG_ITERATED_COLOR << MC_ARG1_SHIFT) - | MC_UPDATE_ARG2 | (MC_ARG_ONE << MC_ARG2_SHIFT) - | MC_UPDATE_OP | MC_OP_ARG1, - GFX_OP_MAP_COLOR_STAGES | MC_STAGE_1 | MC_UPDATE_DEST | MC_DEST_CURRENT - | MC_UPDATE_ARG1 | (MC_ARG_CURRENT_COLOR << MC_ARG1_SHIFT) - | MC_UPDATE_ARG2 | (MC_ARG_ONE << MC_ARG2_SHIFT) - | MC_UPDATE_OP | MC_OP_ARG1, - GFX_OP_MAP_COLOR_STAGES | MC_STAGE_2 | MC_UPDATE_DEST | MC_DEST_CURRENT - | MC_UPDATE_ARG1 | (MC_ARG_CURRENT_COLOR << MC_ARG1_SHIFT) - | MC_UPDATE_ARG2 | (MC_ARG_ONE << MC_ARG2_SHIFT) - | MC_UPDATE_OP | MC_OP_ARG1 - }; - static const unsigned alpha_pass[3] = { - GFX_OP_MAP_ALPHA_STAGES | MA_STAGE_0 - | MA_UPDATE_ARG1 | (MA_ARG_ITERATED_ALPHA << MA_ARG1_SHIFT) - | MA_UPDATE_ARG2 | (MA_ARG_ITERATED_ALPHA << MA_ARG2_SHIFT) - | MA_UPDATE_OP | MA_OP_ARG1, - GFX_OP_MAP_ALPHA_STAGES | MA_STAGE_1 - | MA_UPDATE_ARG1 | (MA_ARG_CURRENT_ALPHA << MA_ARG1_SHIFT) - | MA_UPDATE_ARG2 | (MA_ARG_CURRENT_ALPHA << MA_ARG2_SHIFT) - | MA_UPDATE_OP | MA_OP_ARG1, - GFX_OP_MAP_ALPHA_STAGES | MA_STAGE_2 - | MA_UPDATE_ARG1 | (MA_ARG_CURRENT_ALPHA << MA_ARG1_SHIFT) - | MA_UPDATE_ARG2 | (MA_ARG_CURRENT_ALPHA << MA_ARG2_SHIFT) - | MA_UPDATE_OP | MA_OP_ARG1 - }; - i810ContextPtr imesa = I810_CONTEXT(ctx); - int next_color_stage = 0; - int next_alpha_stage = 0; - - - /* fprintf(stderr, "%s\n", __FUNCTION__); */ - FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_FALSE ); - - i810UpdateTexUnit( ctx, 0, & next_color_stage, & next_alpha_stage ); - i810UpdateTexUnit( ctx, 1, & next_color_stage, & next_alpha_stage ); - - /* There needs to be at least one combine stage emitted that just moves - * the incoming primary color to the current color register. In addition, - * there number be the same number of color and alpha stages emitted. - * Finally, if there are less than 3 combine stages, a MC_OP_DISABLE stage - * must be emitted. - */ - - while ( (next_color_stage == 0) || - (next_color_stage < next_alpha_stage) ) { - set_color_stage( color_pass[ next_color_stage ], next_color_stage, - imesa ); - next_color_stage++; - } - - assert( next_color_stage <= 3 ); - - while ( next_alpha_stage < next_color_stage ) { - set_alpha_stage( alpha_pass[ next_alpha_stage ], next_alpha_stage, - imesa ); - next_alpha_stage++; - } - - assert( next_alpha_stage <= 3 ); - assert( next_color_stage == next_alpha_stage ); - - if ( next_color_stage < 3 ) { - const unsigned color = GFX_OP_MAP_COLOR_STAGES - | (next_color_stage << MC_STAGE_SHIFT) - | MC_UPDATE_DEST | MC_DEST_CURRENT - | MC_UPDATE_ARG1 | (MC_ARG_ONE << MC_ARG1_SHIFT) - | MC_UPDATE_ARG2 | (MC_ARG_ONE << MC_ARG2_SHIFT) - | MC_UPDATE_OP | (MC_OP_DISABLE); - - const unsigned alpha = GFX_OP_MAP_ALPHA_STAGES - | (next_color_stage << MC_STAGE_SHIFT) - | MA_UPDATE_ARG1 | (MA_ARG_CURRENT_ALPHA << MA_ARG1_SHIFT) - | MA_UPDATE_ARG2 | (MA_ARG_CURRENT_ALPHA << MA_ARG2_SHIFT) - | MA_UPDATE_OP | (MA_OP_ARG1); - - set_color_stage( color, next_color_stage, imesa ); - set_alpha_stage( alpha, next_alpha_stage, imesa ); - } -} diff --git a/src/mesa/drivers/dri/i810/i810tris.c b/src/mesa/drivers/dri/i810/i810tris.c deleted file mode 100644 index ec22a3deb36..00000000000 --- a/src/mesa/drivers/dri/i810/i810tris.c +++ /dev/null @@ -1,872 +0,0 @@ -/************************************************************************** - -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. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/enums.h" -#include "main/colormac.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "i810screen.h" -#include "i810_dri.h" - -#include "i810tris.h" -#include "i810state.h" -#include "i810vb.h" -#include "i810ioctl.h" - -static void i810RenderPrimitive( struct gl_context *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 INLINE void 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 INLINE void 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 = 0.5 * CLAMP(imesa->glCtx->Point.Size, - imesa->glCtx->Const.MinPointSize, - imesa->glCtx->Const.MaxPointSize); - 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 { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_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_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX i810Vertex -#define TAB rast_tab - - -#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_size * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - i810_color_t *color = (i810_color_t *)&((v)->ui[coloroffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] - -#define VERT_SET_SPEC( v0, c ) \ -do { \ - if (havespec) { \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \ - } \ -} while (0) -#define VERT_COPY_SPEC( v0, v1 ) \ -do { \ - if (havespec) { \ - v0->v.specular.red = v1->v.specular.red; \ - v0->v.specular.green = v1->v.specular.green; \ - v0->v.specular.blue = v1->v.specular.blue; \ - } \ -} while (0) - -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] -#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] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - 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 -#define IND I810_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 (I810_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (I810_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#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_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" - -#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_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(); -} - - -/*********************************************************************** - * 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 ) -{ - struct gl_context *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 ) -{ - struct gl_context *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 ) -{ - struct gl_context *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)*vertsize*sizeof(int))) -#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 vertsize = imesa->vertex_size; \ - 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( struct gl_context *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( struct gl_context *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -static void i810FastRenderClippedPoly( struct gl_context *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 *start = (const GLuint *)V(elts[0]); - int i,j; - - for (i = 2 ; i < n ; i++) { - COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) ); - COPY_DWORDS( j, vb, vertsize, V(elts[i]) ); - COPY_DWORDS( j, vb, vertsize, start ); - } -} - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - -/*********************************************************************** - * Rasterization fallback helpers * - ***********************************************************************/ - - - -#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(struct gl_context *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (I810_DEBUG & DEBUG_STATE) - fprintf(stderr,"\n%s\n",__FUNCTION__); - - 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( struct gl_context *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( struct gl_context *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( struct gl_context *ctx ) -{ - /* Check for projective textureing. Make sure all texcoord - * pointers point to something. (fix in mesa?) - */ - i810CheckTexSizes( ctx ); -} - -static void i810RenderFinish( struct gl_context *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( struct gl_context *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; - - if (I810_DEBUG & DEBUG_PRIMS) { - /* Prints reduced prim, and hw prim */ - char *prim_name = "Unknown"; - - switch(hwprim) { - case PR_LINES: - prim_name = "Lines"; - break; - case PR_LINESTRIP: - prim_name = "LineStrip"; - break; - case PR_TRIANGLES: - prim_name = "Triangles"; - break; - case PR_TRISTRIP_0: - prim_name = "TriStrip_0"; - break; - case PR_TRIFAN: - prim_name = "TriFan"; - break; - case PR_POLYGON: - prim_name = "Polygons"; - break; - default: - break; - } - - fprintf(stderr, "%s : rprim(%s), hwprim(%s)\n", - __FUNCTION__, - _mesa_lookup_enum_by_nr(rprim), - prim_name); - } - - 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. */ -/**********************************************************************/ -static char *fallbackStrings[] = { - "Texture", - "Draw buffer", - "Read buffer", - "Color mask", - "Render mode", - "Stencil", - "Stipple", - "User disable" -}; - - -static char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - -void i810Fallback( i810ContextPtr imesa, GLuint bit, GLboolean mode ) -{ - struct gl_context *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) { - I810_FIREVERTICES(imesa); - if (I810_DEBUG & DEBUG_FALLBACKS) - fprintf(stderr, "ENTER FALLBACK %s\n", getFallbackString( bit )); - _swsetup_Wakeup( ctx ); - imesa->RenderIndex = ~0; - } - } - else { - imesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - if (I810_DEBUG & DEBUG_FALLBACKS) - fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit )); - 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( struct gl_context *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/src/mesa/drivers/dri/i810/i810tris.h b/src/mesa/drivers/dri/i810/i810tris.h deleted file mode 100644 index 07a0ebf69f3..00000000000 --- a/src/mesa/drivers/dri/i810/i810tris.h +++ /dev/null @@ -1,35 +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. - * - * - */ - -#ifndef I810TRIS_INC -#define I810TRIS_INC - -#include "main/mtypes.h" - -extern void i810PrintRenderState( const char *msg, GLuint state ); -extern void i810InitTriFuncs( struct gl_context *ctx ); -extern void i810RasterPrimitive( struct gl_context *ctx, GLenum rprim, GLuint hwprim ); - -#endif diff --git a/src/mesa/drivers/dri/i810/i810vb.c b/src/mesa/drivers/dri/i810/i810vb.c deleted file mode 100644 index 333e07c0eaa..00000000000 --- a/src/mesa/drivers/dri/i810/i810vb.c +++ /dev/null @@ -1,486 +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. - * - * - */ - - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" - -#include "i810screen.h" -#include "i810_dri.h" -#include "i810context.h" -#include "i810vb.h" -#include "i810ioctl.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)( struct gl_context *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( struct gl_context *ctx ); - GLuint vertex_size; - 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 VERTEX_COLOR i810_color_t -#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_SIZE() I810_CONTEXT(ctx)->vertex_size * sizeof(GLuint) -#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 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 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 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" - -#define IND (I810_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (I810_TEX0_BIT|I810_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (I810_FOG_BIT) -#define TAG(x) x##_f -#include "tnl_dd/t_dd_vbtmp.h" - -#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" - -#define IND (I810_RGBA_BIT|I810_SPEC_BIT) -#define TAG(x) x##_gs -#include "tnl_dd/t_dd_vbtmp.h" - -#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 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(); -} - - - -static void i810PrintSetupFlags(const char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n", - msg, - (int)flags, - (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," : ""); -} - - - -void i810CheckTexSizes( struct gl_context *ctx ) -{ - 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; - } - if (imesa->Fallback) { - tnl->Driver.Render.Start(ctx); - } - } -} - -void i810BuildVertices( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - GLuint stride = imesa->vertex_size * sizeof(int); - GLubyte *v = ((GLubyte *)imesa->verts + (start * stride)); - - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - newinputs |= imesa->SetupNewInputs; - imesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[imesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= I810_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= I810_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= I810_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= I810_TEX1_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= I810_FOG_BIT; - - if (imesa->SetupIndex & I810_PTEX_BIT) - ind = ~0; - - ind &= imesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - -void i810ChooseVertexState( struct gl_context *ctx ) -{ - 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; - - if (ctx->Texture._EnabledUnits & 0x2) - /* unit 1 enabled */ - ind |= I810_TEX1_BIT|I810_TEX0_BIT; - else if (ctx->Texture._EnabledUnits & 0x1) - /* unit 0 enabled */ - ind |= I810_TEX0_BIT; - - imesa->SetupIndex = ind; - - if (I810_DEBUG & (DEBUG_VERTS|DEBUG_STATE)) - i810PrintSetupFlags( __FUNCTION__, ind ); - - 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; - } - - 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; - } -} - - - -void *i810_emit_contiguous_verts( struct gl_context *ctx, - GLuint start, - GLuint count, - void *dest ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLuint stride = imesa->vertex_size * 4; - setup_tab[imesa->SetupIndex].emit( ctx, start, count, dest, stride ); - return (void *)((char *)dest + stride * (count - start)); -} - - - -void i810InitVB( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - imesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - } -} - - -void i810FreeVB( struct gl_context *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - if (imesa->verts) { - _mesa_align_free(imesa->verts); - imesa->verts = 0; - } -} diff --git a/src/mesa/drivers/dri/i810/i810vb.h b/src/mesa/drivers/dri/i810/i810vb.h deleted file mode 100644 index e321518507e..00000000000 --- a/src/mesa/drivers/dri/i810/i810vb.h +++ /dev/null @@ -1,59 +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. - * - * - */ - -#ifndef I810VB_INC -#define I810VB_INC - -#include "main/mtypes.h" -#include "swrast/swrast.h" - -#define _I810_NEW_VERTEX (_NEW_TEXTURE | \ - _DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _NEW_FOG) - - -extern void i810ChooseVertexState( struct gl_context *ctx ); -extern void i810CheckTexSizes( struct gl_context *ctx ); -extern void i810BuildVertices( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint newinputs ); - - -extern void *i810_emit_contiguous_verts( struct gl_context *ctx, - GLuint start, - GLuint count, - void *dest ); - -extern void i810_translate_vertex( struct gl_context *ctx, - const i810Vertex *src, - SWvertex *dst ); - -extern void i810InitVB( struct gl_context *ctx ); -extern void i810FreeVB( struct gl_context *ctx ); - -#endif diff --git a/src/mesa/drivers/dri/i810/server/i810_common.h b/src/mesa/drivers/dri/i810/server/i810_common.h deleted file mode 100644 index 29be444b45e..00000000000 --- a/src/mesa/drivers/dri/i810/server/i810_common.h +++ /dev/null @@ -1,191 +0,0 @@ -/* i810_common.h -- common header definitions for I810 2D/3D/DRM suite - * - * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * 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 - * 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. - * - * Converted to common header format: - * Jens Owen <[email protected]> - * - * - */ - -/* WARNING: If you change any of these defines, make sure to change - * the kernel include file as well (i810_drm.h) - */ - -#ifndef _I810_COMMON_H_ -#define _I810_COMMON_H_ - -#ifndef _I810_DEFINES_ -#define _I810_DEFINES_ -#define I810_USE_BATCH 1 - -#define I810_DMA_BUF_ORDER 12 -#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER) -#define I810_DMA_BUF_NR 256 - -#define I810_NR_SAREA_CLIPRECTS 8 - -/* Each region is a minimum of 64k, and there are at most 64 of them. - */ -#define I810_NR_TEX_REGIONS 64 -#define I810_LOG_MIN_TEX_REGION_SIZE 16 - -/* Destbuffer state - * - backbuffer linear offset and pitch -- invarient in the current dri - * - zbuffer linear offset and pitch -- also invarient - * - drawing origin in back and depth buffers. - * - * Keep the depth/back buffer state here to acommodate private buffers - * in the future. - */ -#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */ -#define I810_DESTREG_DI1 1 -#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */ -#define I810_DESTREG_DV1 3 -#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */ -#define I810_DESTREG_DR1 5 -#define I810_DESTREG_DR2 6 -#define I810_DESTREG_DR3 7 -#define I810_DESTREG_DR4 8 -#define I810_DEST_SETUP_SIZE 10 - -/* Context state - */ -#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */ -#define I810_CTXREG_CF1 1 -#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */ -#define I810_CTXREG_ST1 3 -#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */ -#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */ -#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */ -#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */ -#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */ -#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */ -#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */ -#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */ -#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */ -#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */ -#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */ -#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */ -#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */ -#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */ -#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */ -#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */ -#define I810_CTX_SETUP_SIZE 20 - -/* Texture state (per tex unit) - */ -#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */ -#define I810_TEXREG_MI1 1 -#define I810_TEXREG_MI2 2 -#define I810_TEXREG_MI3 3 -#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */ -#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */ -#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */ -#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */ -#define I810_TEX_SETUP_SIZE 8 - -/* Driver specific DRM command indices - * NOTE: these are not OS specific, but they are driver specific - */ -#define DRM_I810_INIT 0x00 -#define DRM_I810_VERTEX 0x01 -#define DRM_I810_CLEAR 0x02 -#define DRM_I810_FLUSH 0x03 -#define DRM_I810_GETAGE 0x04 -#define DRM_I810_GETBUF 0x05 -#define DRM_I810_SWAP 0x06 -#define DRM_I810_COPY 0x07 -#define DRM_I810_DOCOPY 0x08 -#define DRM_I810_OV0INFO 0x09 -#define DRM_I810_FSTATUS 0x0a -#define DRM_I810_OV0FLIP 0x0b -#define DRM_I810_MC 0x0c -#define DRM_I810_RSTATUS 0x0d -#define DRM_I810_FLIP 0x0e - -#endif - -typedef enum _drmI810Initfunc { - I810_INIT_DMA = 0x01, - I810_CLEANUP_DMA = 0x02, - I810_INIT_DMA_1_4 = 0x03 -} drmI810Initfunc; - -typedef struct { - drmI810Initfunc func; - unsigned int mmio_offset; - unsigned int buffers_offset; - int sarea_priv_offset; - unsigned int ring_start; - unsigned int ring_end; - unsigned int ring_size; - unsigned int front_offset; - unsigned int back_offset; - unsigned int depth_offset; - unsigned int overlay_offset; - unsigned int overlay_physical; - unsigned int w; - unsigned int h; - unsigned int pitch; - unsigned int pitch_bits; -} drmI810Init; - -typedef struct { - void *virtual; - int request_idx; - int request_size; - int granted; -} drmI810DMA; - -/* Flags for clear ioctl - */ -#define I810_FRONT 0x1 -#define I810_BACK 0x2 -#define I810_DEPTH 0x4 - -typedef struct { - int clear_color; - int clear_depth; - int flags; -} drmI810Clear; - -typedef struct { - int idx; /* buffer index */ - int used; /* nr bytes in use */ - int discard; /* client is finished with the buffer? */ -} drmI810Vertex; - -/* Flags for vertex ioctl - */ -#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_MASK (0x7<<18) - -#endif diff --git a/src/mesa/drivers/dri/i810/server/i810_dri.h b/src/mesa/drivers/dri/i810/server/i810_dri.h deleted file mode 100644 index 4a714f03062..00000000000 --- a/src/mesa/drivers/dri/i810/server/i810_dri.h +++ /dev/null @@ -1,127 +0,0 @@ - -#ifndef _I810_DRI_ -#define _I810_DRI_ - -#include "xf86drm.h" -#include "i810_common.h" - -#define I810_MAX_DRAWABLES 256 - -typedef struct { - drm_handle_t regs; - drmSize regsSize; - - drmSize backbufferSize; - drm_handle_t backbuffer; - - drmSize depthbufferSize; - drm_handle_t depthbuffer; - - drm_handle_t textures; - int textureSize; - - drm_handle_t agp_buffers; - drmSize agp_buf_size; - - int deviceID; - int width; - int height; - int mem; - int cpp; - int bitsPerPixel; - int fbOffset; - int fbStride; - - int backOffset; - int depthOffset; - - int auxPitch; - int auxPitchBits; - - int logTextureGranularity; - int textureOffset; - - /* For non-dma direct rendering. - */ - int ringOffset; - int ringSize; - - drmBufMapPtr drmBufs; - int irq; - unsigned int sarea_priv_offset; - -} I810DRIRec, *I810DRIPtr; - -/* WARNING: Do not change the SAREA structure without changing the kernel - * as well */ - -#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */ -#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */ -#define I810_UPLOAD_CTX 0x4 -#define I810_UPLOAD_BUFFERS 0x8 -#define I810_UPLOAD_TEX0 0x10 -#define I810_UPLOAD_TEX1 0x20 -#define I810_UPLOAD_CLIPRECTS 0x40 - -typedef struct { - unsigned char next, prev; /* indices to form a circular LRU */ - unsigned char in_use; /* owned by a client, or free? */ - int age; /* tracked by clients to update local LRU's */ -} I810TexRegionRec, *I810TexRegionPtr; - -typedef struct { - unsigned int ContextState[I810_CTX_SETUP_SIZE]; - unsigned int BufferState[I810_DEST_SETUP_SIZE]; - unsigned int TexState[2][I810_TEX_SETUP_SIZE]; - unsigned int dirty; - - unsigned int nbox; - drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS]; - - /* Maintain an LRU of contiguous regions of texture space. If - * you think you own a region of texture memory, and it has an - * age different to the one you set, then you are mistaken and - * it has been stolen by another client. If global texAge - * hasn't changed, there is no need to walk the list. - * - * These regions can be used as a proxy for the fine-grained - * texture information of other clients - by maintaining them - * in the same lru which is used to age their own textures, - * clients have an approximate lru for the whole of global - * texture space, and can make informed decisions as to which - * areas to kick out. There is no need to choose whether to - * kick out your own texture or someone else's - simply eject - * them all in LRU order. - */ - - drmTextureRegion texList[I810_NR_TEX_REGIONS + 1]; - - /* Last elt is sentinal */ - int texAge; /* last time texture was uploaded */ - - int last_enqueue; /* last time a buffer was enqueued */ - int last_dispatch; /* age of the most recently dispatched buffer */ - int last_quiescent; /* */ - - int ctxOwner; /* last context to upload state */ - - int vertex_prim; - - int pf_enabled; /* is pageflipping allowed? */ - int pf_active; /* is pageflipping active right now? */ - int pf_current_page; /* which buffer is being displayed? */ - - -} I810SAREARec, *I810SAREAPtr; - -typedef struct { - /* Nothing here yet */ - int dummy; -} I810ConfigPrivRec, *I810ConfigPrivPtr; - -typedef struct { - /* Nothing here yet */ - int dummy; -} I810DRIContextRec, *I810DRIContextPtr; - -#endif diff --git a/src/mesa/drivers/dri/i810/server/i810_reg.h b/src/mesa/drivers/dri/i810/server/i810_reg.h deleted file mode 100644 index e7e5081038e..00000000000 --- a/src/mesa/drivers/dri/i810/server/i810_reg.h +++ /dev/null @@ -1,991 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - * based on the i740 driver by - * Kevin E. Martin <[email protected]> - * - * - */ - -#ifndef _I810_REG_H -#define _I810_REG_H - -/* I/O register offsets - */ -#define SRX 0x3C4 /* p208 */ -#define GRX 0x3CE /* p213 */ -#define ARX 0x3C0 /* p224 */ - -/* VGA Color Palette Registers */ -#define DACMASK 0x3C6 /* p232 */ -#define DACSTATE 0x3C7 /* p232 */ -#define DACRX 0x3C7 /* p233 */ -#define DACWX 0x3C8 /* p233 */ -#define DACDATA 0x3C9 /* p233 */ - -/* CRT Controller Registers (CRX) */ -#define START_ADDR_HI 0x0C /* p246 */ -#define START_ADDR_LO 0x0D /* p247 */ -#define VERT_SYNC_END 0x11 /* p249 */ -#define EXT_VERT_TOTAL 0x30 /* p257 */ -#define EXT_VERT_DISPLAY 0x31 /* p258 */ -#define EXT_VERT_SYNC_START 0x32 /* p259 */ -#define EXT_VERT_BLANK_START 0x33 /* p260 */ -#define EXT_HORIZ_TOTAL 0x35 /* p261 */ -#define EXT_HORIZ_BLANK 0x39 /* p261 */ -#define EXT_START_ADDR 0x40 /* p262 */ -#define EXT_START_ADDR_ENABLE 0x80 -#define EXT_OFFSET 0x41 /* p263 */ -#define EXT_START_ADDR_HI 0x42 /* p263 */ -#define INTERLACE_CNTL 0x70 /* p264 */ -#define INTERLACE_ENABLE 0x80 -#define INTERLACE_DISABLE 0x00 - -/* Miscellaneous Output Register - */ -#define MSR_R 0x3CC /* p207 */ -#define MSR_W 0x3C2 /* p207 */ -#define IO_ADDR_SELECT 0x01 - -#define MDA_BASE 0x3B0 /* p207 */ -#define CGA_BASE 0x3D0 /* p207 */ - -/* CR80 - IO Control, p264 - */ -#define IO_CTNL 0x80 -#define EXTENDED_ATTR_CNTL 0x02 -#define EXTENDED_CRTC_CNTL 0x01 - -/* GR10 - Address mapping, p221 - */ -#define ADDRESS_MAPPING 0x10 -#define PAGE_TO_LOCAL_MEM_ENABLE 0x10 -#define GTT_MEM_MAP_ENABLE 0x08 -#define PACKED_MODE_ENABLE 0x04 -#define LINEAR_MODE_ENABLE 0x02 -#define PAGE_MAPPING_ENABLE 0x01 - -/* Blitter control, p378 - */ -#define BITBLT_CNTL 0x7000c -#define COLEXP_MODE 0x30 -#define COLEXP_8BPP 0x00 -#define COLEXP_16BPP 0x10 -#define COLEXP_24BPP 0x20 -#define COLEXP_RESERVED 0x30 -#define BITBLT_STATUS 0x01 - -/* p375. - */ -#define DISPLAY_CNTL 0x70008 -#define VGA_WRAP_MODE 0x02 -#define VGA_WRAP_AT_256KB 0x00 -#define VGA_NO_WRAP 0x02 -#define GUI_MODE 0x01 -#define STANDARD_VGA_MODE 0x00 -#define HIRES_MODE 0x01 - -/* p375 - */ -#define PIXPIPE_CONFIG_0 0x70009 -#define DAC_8_BIT 0x80 -#define DAC_6_BIT 0x00 -#define HW_CURSOR_ENABLE 0x10 -#define EXTENDED_PALETTE 0x01 - -/* p375 - */ -#define PIXPIPE_CONFIG_1 0x7000a -#define DISPLAY_COLOR_MODE 0x0F -#define DISPLAY_VGA_MODE 0x00 -#define DISPLAY_8BPP_MODE 0x02 -#define DISPLAY_15BPP_MODE 0x04 -#define DISPLAY_16BPP_MODE 0x05 -#define DISPLAY_24BPP_MODE 0x06 -#define DISPLAY_32BPP_MODE 0x07 - -/* p375 - */ -#define PIXPIPE_CONFIG_2 0x7000b -#define DISPLAY_GAMMA_ENABLE 0x08 -#define DISPLAY_GAMMA_DISABLE 0x00 -#define OVERLAY_GAMMA_ENABLE 0x04 -#define OVERLAY_GAMMA_DISABLE 0x00 - - -/* p380 - */ -#define DISPLAY_BASE 0x70020 -#define DISPLAY_BASE_MASK 0x03fffffc - - -/* Cursor control registers, pp383-384 - */ -/* Desktop (845G, 865G) */ -#define CURSOR_CONTROL 0x70080 -#define CURSOR_ENABLE 0x80000000 -#define CURSOR_GAMMA_ENABLE 0x40000000 -#define CURSOR_STRIDE_MASK 0x30000000 -#define CURSOR_FORMAT_SHIFT 24 -#define CURSOR_FORMAT_MASK (0x07 << CURSOR_FORMAT_SHIFT) -#define CURSOR_FORMAT_2C (0x00 << CURSOR_FORMAT_SHIFT) -#define CURSOR_FORMAT_3C (0x01 << CURSOR_FORMAT_SHIFT) -#define CURSOR_FORMAT_4C (0x02 << CURSOR_FORMAT_SHIFT) -#define CURSOR_FORMAT_ARGB (0x04 << CURSOR_FORMAT_SHIFT) -#define CURSOR_FORMAT_XRGB (0x05 << CURSOR_FORMAT_SHIFT) - -/* Mobile and i810 */ -#define CURSOR_A_CONTROL CURSOR_CONTROL -#define CURSOR_ORIGIN_SCREEN 0x00 /* i810 only */ -#define CURSOR_ORIGIN_DISPLAY 0x1 /* i810 only */ -#define CURSOR_MODE 0x27 -#define CURSOR_MODE_DISABLE 0x00 -#define CURSOR_MODE_32_4C_AX 0x01 /* i810 only */ -#define CURSOR_MODE_64_3C 0x04 -#define CURSOR_MODE_64_4C_AX 0x05 -#define CURSOR_MODE_64_4C 0x06 -#define CURSOR_MODE_64_32B_AX 0x07 -#define CURSOR_MODE_64_ARGB_AX (0x20 | CURSOR_MODE_64_32B_AX) -#define MCURSOR_PIPE_SELECT (1 << 28) -#define MCURSOR_PIPE_A 0x00 -#define MCURSOR_PIPE_B (1 << 28) -#define MCURSOR_GAMMA_ENABLE (1 << 26) -#define MCURSOR_MEM_TYPE_LOCAL (1 << 25) - - -#define CURSOR_BASEADDR 0x70084 -#define CURSOR_A_BASE CURSOR_BASEADDR -#define CURSOR_BASEADDR_MASK 0x1FFFFF00 -#define CURSOR_A_POSITION 0x70088 -#define CURSOR_POS_SIGN 0x8000 -#define CURSOR_POS_MASK 0x007FF -#define CURSOR_X_SHIFT 0 -#define CURSOR_Y_SHIFT 16 -#define CURSOR_X_LO 0x70088 -#define CURSOR_X_HI 0x70089 -#define CURSOR_X_POS 0x00 -#define CURSOR_X_NEG 0x80 -#define CURSOR_Y_LO 0x7008A -#define CURSOR_Y_HI 0x7008B -#define CURSOR_Y_POS 0x00 -#define CURSOR_Y_NEG 0x80 - -#define CURSOR_A_PALETTE0 0x70090 -#define CURSOR_A_PALETTE1 0x70094 -#define CURSOR_A_PALETTE2 0x70098 -#define CURSOR_A_PALETTE3 0x7009C - -#define CURSOR_SIZE 0x700A0 -#define CURSOR_SIZE_MASK 0x3FF -#define CURSOR_SIZE_HSHIFT 0 -#define CURSOR_SIZE_VSHIFT 12 - - -/* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm - * not sure they refer to local (graphics) memory. - * - * These details are for the local memory control registers, - * (pp301-310). The test machines are not equiped with local memory, - * so nothing is tested. Only a single row seems to be supported. - */ -#define DRAM_ROW_TYPE 0x3000 -#define DRAM_ROW_0 0x01 -#define DRAM_ROW_0_SDRAM 0x01 -#define DRAM_ROW_0_EMPTY 0x00 -#define DRAM_ROW_CNTL_LO 0x3001 -#define DRAM_PAGE_MODE_CTRL 0x10 -#define DRAM_RAS_TO_CAS_OVRIDE 0x08 -#define DRAM_CAS_LATENCY 0x04 -#define DRAM_RAS_TIMING 0x02 -#define DRAM_RAS_PRECHARGE 0x01 -#define DRAM_ROW_CNTL_HI 0x3002 -#define DRAM_REFRESH_RATE 0x18 -#define DRAM_REFRESH_DISABLE 0x00 -#define DRAM_REFRESH_60HZ 0x08 -#define DRAM_REFRESH_FAST_TEST 0x10 -#define DRAM_REFRESH_RESERVED 0x18 -#define DRAM_SMS 0x07 -#define DRAM_SMS_NORMAL 0x00 -#define DRAM_SMS_NOP_ENABLE 0x01 -#define DRAM_SMS_ABPCE 0x02 -#define DRAM_SMS_MRCE 0x03 -#define DRAM_SMS_CBRCE 0x04 - -/* p307 - */ -#define DPMS_SYNC_SELECT 0x5002 -#define VSYNC_CNTL 0x08 -#define VSYNC_ON 0x00 -#define VSYNC_OFF 0x08 -#define HSYNC_CNTL 0x02 -#define HSYNC_ON 0x00 -#define HSYNC_OFF 0x02 - - - -/* p317, 319 - */ -#define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */ -#define VCLK2_VCO_N 0x600a -#define VCLK2_VCO_DIV_SEL 0x6012 - -#define VCLK_DIVISOR_VGA0 0x6000 -#define VCLK_DIVISOR_VGA1 0x6004 -#define VCLK_POST_DIV 0x6010 - -#define POST_DIV_SELECT 0x70 -#define POST_DIV_1 0x00 -#define POST_DIV_2 0x10 -#define POST_DIV_4 0x20 -#define POST_DIV_8 0x30 -#define POST_DIV_16 0x40 -#define POST_DIV_32 0x50 -#define VCO_LOOP_DIV_BY_4M 0x00 -#define VCO_LOOP_DIV_BY_16M 0x04 - - -/* Instruction Parser Mode Register - * - p281 - * - 2 new bits. - */ -#define INST_PM 0x20c0 -#define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */ -#define SYNC_PACKET_FLUSH_ENABLE 0x10 -#define TWO_D_INST_DISABLE 0x08 -#define THREE_D_INST_DISABLE 0x04 -#define STATE_VAR_UPDATE_DISABLE 0x02 -#define PAL_STIP_DISABLE 0x01 - -#define INST_DONE 0x2090 -#define INST_PS 0x20c4 - -#define MEMMODE 0x20dc - - -/* Instruction parser error register. p279 - */ -#define IPEIR 0x2088 -#define IPEHR 0x208C - - -/* General error reporting regs, p296 - */ -#define EIR 0x20B0 -#define EMR 0x20B4 -#define ESR 0x20B8 -#define IP_ERR 0x0001 -#define ERROR_RESERVED 0xffc6 - - -/* Interrupt Control Registers - * - new bits for i810 - * - new register hwstam (mask) - */ -#define HWSTAM 0x2098 /* p290 */ -#define IER 0x20a0 /* p291 */ -#define IIR 0x20a4 /* p292 */ -#define IMR 0x20a8 /* p293 */ -#define ISR 0x20ac /* p294 */ -#define HW_ERROR 0x8000 -#define SYNC_STATUS_TOGGLE 0x1000 -#define DPY_0_FLIP_PENDING 0x0800 -#define DPY_1_FLIP_PENDING 0x0400 /* not implemented on i810 */ -#define OVL_0_FLIP_PENDING 0x0200 -#define OVL_1_FLIP_PENDING 0x0100 /* not implemented on i810 */ -#define DPY_0_VBLANK 0x0080 -#define DPY_0_EVENT 0x0040 -#define DPY_1_VBLANK 0x0020 /* not implemented on i810 */ -#define DPY_1_EVENT 0x0010 /* not implemented on i810 */ -#define HOST_PORT_EVENT 0x0008 /* */ -#define CAPTURE_EVENT 0x0004 /* */ -#define USER_DEFINED 0x0002 -#define BREAKPOINT 0x0001 - - -#define INTR_RESERVED (0x6000 | \ - DPY_1_FLIP_PENDING | \ - OVL_1_FLIP_PENDING | \ - DPY_1_VBLANK | \ - DPY_1_EVENT | \ - HOST_PORT_EVENT | \ - CAPTURE_EVENT ) - -/* FIFO Watermark and Burst Length Control Register - * - * - different offset and contents on i810 (p299) (fewer bits per field) - * - some overlay fields added - * - what does it all mean? - */ -#define FWATER_BLC 0x20d8 -#define FWATER_BLC2 0x20dc -#define MM_BURST_LENGTH 0x00700000 -#define MM_FIFO_WATERMARK 0x0001F000 -#define LM_BURST_LENGTH 0x00000700 -#define LM_FIFO_WATERMARK 0x0000001F - - -/* Fence/Tiling ranges [0..7] - */ -#define FENCE 0x2000 -#define FENCE_NR 8 - -#define I830_FENCE_START_MASK 0x07f80000 - -#define FENCE_START_MASK 0x03F80000 -#define FENCE_X_MAJOR 0x00000000 -#define FENCE_Y_MAJOR 0x00001000 -#define FENCE_SIZE_MASK 0x00000700 -#define FENCE_SIZE_512K 0x00000000 -#define FENCE_SIZE_1M 0x00000100 -#define FENCE_SIZE_2M 0x00000200 -#define FENCE_SIZE_4M 0x00000300 -#define FENCE_SIZE_8M 0x00000400 -#define FENCE_SIZE_16M 0x00000500 -#define FENCE_SIZE_32M 0x00000600 -#define FENCE_SIZE_64M 0x00000700 -#define FENCE_PITCH_MASK 0x00000070 -#define FENCE_PITCH_1 0x00000000 -#define FENCE_PITCH_2 0x00000010 -#define FENCE_PITCH_4 0x00000020 -#define FENCE_PITCH_8 0x00000030 -#define FENCE_PITCH_16 0x00000040 -#define FENCE_PITCH_32 0x00000050 -#define FENCE_PITCH_64 0x00000060 -#define FENCE_VALID 0x00000001 - - -/* Registers to control page table, p274 - */ -#define PGETBL_CTL 0x2020 -#define PGETBL_ADDR_MASK 0xFFFFF000 -#define PGETBL_ENABLE_MASK 0x00000001 -#define PGETBL_ENABLED 0x00000001 - -/* Register containing pge table error results, p276 - */ -#define PGE_ERR 0x2024 -#define PGE_ERR_ADDR_MASK 0xFFFFF000 -#define PGE_ERR_ID_MASK 0x00000038 -#define PGE_ERR_CAPTURE 0x00000000 -#define PGE_ERR_OVERLAY 0x00000008 -#define PGE_ERR_DISPLAY 0x00000010 -#define PGE_ERR_HOST 0x00000018 -#define PGE_ERR_RENDER 0x00000020 -#define PGE_ERR_BLITTER 0x00000028 -#define PGE_ERR_MAPPING 0x00000030 -#define PGE_ERR_CMD_PARSER 0x00000038 -#define PGE_ERR_TYPE_MASK 0x00000007 -#define PGE_ERR_INV_TABLE 0x00000000 -#define PGE_ERR_INV_PTE 0x00000001 -#define PGE_ERR_MIXED_TYPES 0x00000002 -#define PGE_ERR_PAGE_MISS 0x00000003 -#define PGE_ERR_ILLEGAL_TRX 0x00000004 -#define PGE_ERR_LOCAL_MEM 0x00000005 -#define PGE_ERR_TILED 0x00000006 - - - -/* Page table entries loaded via mmio region, p323 - */ -#define PTE_BASE 0x10000 -#define PTE_ADDR_MASK 0x3FFFF000 -#define PTE_TYPE_MASK 0x00000006 -#define PTE_LOCAL 0x00000002 -#define PTE_MAIN_UNCACHED 0x00000000 -#define PTE_MAIN_CACHED 0x00000006 -#define PTE_VALID_MASK 0x00000001 -#define PTE_VALID 0x00000001 - - -/* Ring buffer registers, p277, overview p19 - */ -#define LP_RING 0x2030 -#define HP_RING 0x2040 - -#define RING_TAIL 0x00 -#define TAIL_ADDR 0x000FFFF8 -#define I830_TAIL_MASK 0x001FFFF8 - -#define RING_HEAD 0x04 -#define HEAD_WRAP_COUNT 0xFFE00000 -#define HEAD_WRAP_ONE 0x00200000 -#define HEAD_ADDR 0x001FFFFC -#define I830_HEAD_MASK 0x001FFFFC - -#define RING_START 0x08 -#define START_ADDR 0x00FFFFF8 -#define I830_RING_START_MASK 0xFFFFF000 - -#define RING_LEN 0x0C -#define RING_NR_PAGES 0x000FF000 -#define I830_RING_NR_PAGES 0x001FF000 -#define RING_REPORT_MASK 0x00000006 -#define RING_REPORT_64K 0x00000002 -#define RING_REPORT_128K 0x00000004 -#define RING_NO_REPORT 0x00000000 -#define RING_VALID_MASK 0x00000001 -#define RING_VALID 0x00000001 -#define RING_INVALID 0x00000000 - - - -/* BitBlt Instructions - * - * There are many more masks & ranges yet to add. - */ -#define BR00_BITBLT_CLIENT 0x40000000 -#define BR00_OP_COLOR_BLT 0x10000000 -#define BR00_OP_SRC_COPY_BLT 0x10C00000 -#define BR00_OP_FULL_BLT 0x11400000 -#define BR00_OP_MONO_SRC_BLT 0x11800000 -#define BR00_OP_MONO_SRC_COPY_BLT 0x11000000 -#define BR00_OP_MONO_PAT_BLT 0x11C00000 -#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22) -#define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000 - - -#define BR00_TPCY_DISABLE 0x00000000 -#define BR00_TPCY_ENABLE 0x00000010 - -#define BR00_TPCY_ROP 0x00000000 -#define BR00_TPCY_NO_ROP 0x00000020 -#define BR00_TPCY_EQ 0x00000000 -#define BR00_TPCY_NOT_EQ 0x00000040 - -#define BR00_PAT_MSB_FIRST 0x00000000 /* ? */ - -#define BR00_PAT_VERT_ALIGN 0x000000e0 - -#define BR00_LENGTH 0x0000000F - -#define BR09_DEST_ADDR 0x03FFFFFF - -#define BR11_SOURCE_PITCH 0x00003FFF - -#define BR12_SOURCE_ADDR 0x03FFFFFF - -#define BR13_SOLID_PATTERN 0x80000000 -#define BR13_RIGHT_TO_LEFT 0x40000000 -#define BR13_LEFT_TO_RIGHT 0x00000000 -#define BR13_MONO_TRANSPCY 0x20000000 -#define BR13_USE_DYN_DEPTH 0x04000000 -#define BR13_DYN_8BPP 0x00000000 -#define BR13_DYN_16BPP 0x01000000 -#define BR13_DYN_24BPP 0x02000000 -#define BR13_ROP_MASK 0x00FF0000 -#define BR13_DEST_PITCH 0x0000FFFF -#define BR13_PITCH_SIGN_BIT 0x00008000 - -#define BR14_DEST_HEIGHT 0xFFFF0000 -#define BR14_DEST_WIDTH 0x0000FFFF - -#define BR15_PATTERN_ADDR 0x03FFFFFF - -#define BR16_SOLID_PAT_COLOR 0x00FFFFFF -#define BR16_BACKGND_PAT_CLR 0x00FFFFFF - -#define BR17_FGND_PAT_CLR 0x00FFFFFF - -#define BR18_SRC_BGND_CLR 0x00FFFFFF -#define BR19_SRC_FGND_CLR 0x00FFFFFF - - -/* Instruction parser instructions - */ - -#define INST_PARSER_CLIENT 0x00000000 -#define INST_OP_FLUSH 0x02000000 -#define INST_FLUSH_MAP_CACHE 0x00000001 - - -#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23)) - - -/* Registers in the i810 host-pci bridge pci config space which affect - * the i810 graphics operations. - */ -#define SMRAM_MISCC 0x70 -#define GMS 0x000000c0 -#define GMS_DISABLE 0x00000000 -#define GMS_ENABLE_BARE 0x00000040 -#define GMS_ENABLE_512K 0x00000080 -#define GMS_ENABLE_1M 0x000000c0 -#define USMM 0x00000030 -#define USMM_DISABLE 0x00000000 -#define USMM_TSEG_ZERO 0x00000010 -#define USMM_TSEG_512K 0x00000020 -#define USMM_TSEG_1M 0x00000030 -#define GFX_MEM_WIN_SIZE 0x00010000 -#define GFX_MEM_WIN_32M 0x00010000 -#define GFX_MEM_WIN_64M 0x00000000 - -/* Overkill? I don't know. Need to figure out top of mem to make the - * SMRAM calculations come out. Linux seems to have problems - * detecting it all on its own, so this seems a reasonable double - * check to any user supplied 'mem=...' boot param. - * - * ... unfortunately this reg doesn't work according to spec on the - * test hardware. - */ -#define WHTCFG_PAMR_DRP 0x50 -#define SYS_DRAM_ROW_0_SHIFT 16 -#define SYS_DRAM_ROW_1_SHIFT 20 -#define DRAM_MASK 0x0f -#define DRAM_VALUE_0 0 -#define DRAM_VALUE_1 8 -/* No 2 value defined */ -#define DRAM_VALUE_3 16 -#define DRAM_VALUE_4 16 -#define DRAM_VALUE_5 24 -#define DRAM_VALUE_6 32 -#define DRAM_VALUE_7 32 -#define DRAM_VALUE_8 48 -#define DRAM_VALUE_9 64 -#define DRAM_VALUE_A 64 -#define DRAM_VALUE_B 96 -#define DRAM_VALUE_C 128 -#define DRAM_VALUE_D 128 -#define DRAM_VALUE_E 192 -#define DRAM_VALUE_F 256 /* nice one, geezer */ -#define LM_FREQ_MASK 0x10 -#define LM_FREQ_133 0x10 -#define LM_FREQ_100 0x00 - - - - -/* These are 3d state registers, but the state is invarient, so we let - * the X server handle it: - */ - - - -/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135 - */ -#define GFX_OP_COLOR_CHROMA_KEY ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1) -#define CC1_UPDATE_KILL_WRITE (1<<28) -#define CC1_ENABLE_KILL_WRITE (1<<27) -#define CC1_DISABLE_KILL_WRITE 0 -#define CC1_UPDATE_COLOR_IDX (1<<26) -#define CC1_UPDATE_CHROMA_LOW (1<<25) -#define CC1_UPDATE_CHROMA_HI (1<<24) -#define CC1_CHROMA_LOW_MASK ((1<<24)-1) -#define CC2_COLOR_IDX_SHIFT 24 -#define CC2_COLOR_IDX_MASK (0xff<<24) -#define CC2_CHROMA_HI_MASK ((1<<24)-1) - - -#define GFX_CMD_CONTEXT_SEL ((0<<29)|(0x5<<23)) -#define CS_UPDATE_LOAD (1<<17) -#define CS_UPDATE_USE (1<<16) -#define CS_UPDATE_LOAD (1<<17) -#define CS_LOAD_CTX0 0 -#define CS_LOAD_CTX1 (1<<8) -#define CS_USE_CTX0 0 -#define CS_USE_CTX1 (1<<0) - -/* I810 LCD/TV registers */ -#define LCD_TV_HTOTAL 0x60000 -#define LCD_TV_C 0x60018 -#define LCD_TV_OVRACT 0x6001C - -#define LCD_TV_ENABLE (1 << 31) -#define LCD_TV_VGAMOD (1 << 28) - -/* I830 CRTC registers */ -#define HTOTAL_A 0x60000 -#define HBLANK_A 0x60004 -#define HSYNC_A 0x60008 -#define VTOTAL_A 0x6000c -#define VBLANK_A 0x60010 -#define VSYNC_A 0x60014 -#define PIPEASRC 0x6001c -#define BCLRPAT_A 0x60020 - -#define HTOTAL_B 0x61000 -#define HBLANK_B 0x61004 -#define HSYNC_B 0x61008 -#define VTOTAL_B 0x6100c -#define VBLANK_B 0x61010 -#define VSYNC_B 0x61014 -#define PIPEBSRC 0x6101c -#define BCLRPAT_B 0x61020 - -#define DPLL_A 0x06014 -#define DPLL_B 0x06018 -#define FPA0 0x06040 -#define FPA1 0x06044 - -#define I830_HTOTAL_MASK 0xfff0000 -#define I830_HACTIVE_MASK 0x7ff - -#define I830_HBLANKEND_MASK 0xfff0000 -#define I830_HBLANKSTART_MASK 0xfff - -#define I830_HSYNCEND_MASK 0xfff0000 -#define I830_HSYNCSTART_MASK 0xfff - -#define I830_VTOTAL_MASK 0xfff0000 -#define I830_VACTIVE_MASK 0x7ff - -#define I830_VBLANKEND_MASK 0xfff0000 -#define I830_VBLANKSTART_MASK 0xfff - -#define I830_VSYNCEND_MASK 0xfff0000 -#define I830_VSYNCSTART_MASK 0xfff - -#define I830_PIPEA_HORZ_MASK 0x7ff0000 -#define I830_PIPEA_VERT_MASK 0x7ff - -#define ADPA 0x61100 -#define ADPA_DAC_ENABLE (1<<31) -#define ADPA_DAC_DISABLE 0 -#define ADPA_PIPE_SELECT_MASK (1<<30) -#define ADPA_PIPE_A_SELECT 0 -#define ADPA_PIPE_B_SELECT (1<<30) -#define ADPA_USE_VGA_HVPOLARITY (1<<15) -#define ADPA_SETS_HVPOLARITY 0 -#define ADPA_VSYNC_CNTL_DISABLE (1<<11) -#define ADPA_VSYNC_CNTL_ENABLE 0 -#define ADPA_HSYNC_CNTL_DISABLE (1<<10) -#define ADPA_HSYNC_CNTL_ENABLE 0 -#define ADPA_VSYNC_ACTIVE_HIGH (1<<4) -#define ADPA_VSYNC_ACTIVE_LOW 0 -#define ADPA_HSYNC_ACTIVE_HIGH (1<<3) -#define ADPA_HSYNC_ACTIVE_LOW 0 - - -#define DVOA 0x61120 -#define DVOB 0x61140 -#define DVOC 0x61160 -#define DVO_ENABLE (1<<31) - -#define DVOA_SRCDIM 0x61124 -#define DVOB_SRCDIM 0x61144 -#define DVOC_SRCDIM 0x61164 - -#define LVDS 0x61180 - -#define PIPEACONF 0x70008 -#define PIPEACONF_ENABLE (1<<31) -#define PIPEACONF_DISABLE 0 -#define PIPEACONF_DOUBLE_WIDE (1<<30) -#define PIPEACONF_SINGLE_WIDE 0 -#define PIPEACONF_PIPE_UNLOCKED 0 -#define PIPEACONF_PIPE_LOCKED (1<<25) -#define PIPEACONF_PALETTE 0 -#define PIPEACONF_GAMMA (1<<24) - -#define PIPEBCONF 0x71008 -#define PIPEBCONF_ENABLE (1<<31) -#define PIPEBCONF_DISABLE 0 -#define PIPEBCONF_GAMMA (1<<24) -#define PIPEBCONF_PALETTE 0 - -#define DSPACNTR 0x70180 -#define DSPBCNTR 0x71180 -#define DISPLAY_PLANE_ENABLE (1<<31) -#define DISPLAY_PLANE_DISABLE 0 -#define DISPPLANE_GAMMA_ENABLE (1<<30) -#define DISPPLANE_GAMMA_DISABLE 0 -#define DISPPLANE_PIXFORMAT_MASK (0xf<<26) -#define DISPPLANE_8BPP (0x2<<26) -#define DISPPLANE_15_16BPP (0x4<<26) -#define DISPPLANE_16BPP (0x5<<26) -#define DISPPLANE_32BPP_NO_ALPHA (0x6<<26) -#define DISPPLANE_32BPP (0x7<<26) -#define DISPPLANE_STEREO_ENABLE (1<<25) -#define DISPPLANE_STEREO_DISABLE 0 -#define DISPPLANE_SEL_PIPE_MASK (1<<24) -#define DISPPLANE_SEL_PIPE_A 0 -#define DISPPLANE_SEL_PIPE_B (1<<24) -#define DISPPLANE_SRC_KEY_ENABLE (1<<22) -#define DISPPLANE_SRC_KEY_DISABLE 0 -#define DISPPLANE_LINE_DOUBLE (1<<20) -#define DISPPLANE_NO_LINE_DOUBLE 0 -#define DISPPLANE_STEREO_POLARITY_FIRST 0 -#define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) -/* plane B only */ -#define DISPPLANE_ALPHA_TRANS_ENABLE (1<<15) -#define DISPPLANE_ALPHA_TRANS_DISABLE 0 -#define DISPPLANE_SPRITE_ABOVE_DISPLAYA 0 -#define DISPPLANE_SPRITE_ABOVE_OVERLAY (1) - -#define DSPABASE 0x70184 -#define DSPASTRIDE 0x70188 - -#define DSPBBASE 0x71184 -#define DSPBADDR DSPBBASE -#define DSPBSTRIDE 0x71188 - -/* Various masks for reserved bits, etc. */ -#define I830_FWATER1_MASK (~((1<<11)|(1<<10)|(1<<9)| \ - (1<<8)|(1<<26)|(1<<25)|(1<<24)|(1<<5)|(1<<4)|(1<<3)| \ - (1<<2)|(1<<1)|1|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))) -#define I830_FWATER2_MASK ~(0) - -#define DV0A_RESERVED ((1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<16)|(1<<5)|(1<<1)|1) -#define DV0B_RESERVED ((1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<16)|(1<<5)|(1<<1)|1) -#define VGA0_N_DIVISOR_MASK ((1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)) -#define VGA0_M1_DIVISOR_MASK ((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)) -#define VGA0_M2_DIVISOR_MASK ((1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1) -#define VGA0_M1M2N_RESERVED ~(VGA0_N_DIVISOR_MASK|VGA0_M1_DIVISOR_MASK|VGA0_M2_DIVISOR_MASK) -#define VGA0_POSTDIV_MASK ((1<<7)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1) -#define VGA1_POSTDIV_MASK ((1<<15)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)) -#define VGA_POSTDIV_RESERVED ~(VGA0_POSTDIV_MASK|VGA1_POSTDIV_MASK|(1<<7)|(1<<15)) -#define DPLLA_POSTDIV_MASK ((1<<23)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)) -#define DPLLA_RESERVED ((1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<22)|(1<<15)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1) -#define ADPA_RESERVED ((1<<2)|(1<<1)|1|(1<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)) -#define SUPER_WORD 32 -#define BURST_A_MASK ((1<<11)|(1<<10)|(1<<9)|(1<<8)) -#define BURST_B_MASK ((1<<26)|(1<<25)|(1<<24)) -#define WATER_A_MASK ((1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1) -#define WATER_B_MASK ((1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)) -#define WATER_RESERVED ((1<<31)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<23)|(1<<22)|(1<<21)|(1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<7)|(1<<6)) -#define PIPEACONF_RESERVED ((1<<29)|(1<<28)|(1<<27)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)|0xffff) -#define PIPEBCONF_RESERVED ((1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<26)|(1<<25)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)|0xffff) -#define DSPACNTR_RESERVED ((1<<23)|(1<<19)|(1<<17)|(1<<16)|0xffff) -#define DSPBCNTR_RESERVED ((1<<23)|(1<<19)|(1<<17)|(1<<16)|0x7ffe) - -#define I830_GMCH_CTRL 0x52 - -#define I830_GMCH_ENABLED 0x4 -#define I830_GMCH_MEM_MASK 0x1 -#define I830_GMCH_MEM_64M 0x1 -#define I830_GMCH_MEM_128M 0 - -#define I830_GMCH_GMS_MASK 0x70 -#define I830_GMCH_GMS_DISABLED 0x00 -#define I830_GMCH_GMS_LOCAL 0x10 -#define I830_GMCH_GMS_STOLEN_512 0x20 -#define I830_GMCH_GMS_STOLEN_1024 0x30 -#define I830_GMCH_GMS_STOLEN_8192 0x40 - -#define I830_RDRAM_CHANNEL_TYPE 0x03010 -#define I830_RDRAM_ND(x) (((x) & 0x20) >> 5) -#define I830_RDRAM_DDT(x) (((x) & 0x18) >> 3) - -#define I855_GMCH_GMS_MASK (0x7 << 4) -#define I855_GMCH_GMS_DISABLED 0x00 -#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4) -#define I855_GMCH_GMS_STOLEN_4M (0x2 << 4) -#define I855_GMCH_GMS_STOLEN_8M (0x3 << 4) -#define I855_GMCH_GMS_STOLEN_16M (0x4 << 4) -#define I855_GMCH_GMS_STOLEN_32M (0x5 << 4) - -#define I85X_CAPID 0x44 -#define I85X_VARIANT_MASK 0x7 -#define I85X_VARIANT_SHIFT 5 -#define I855_GME 0x0 -#define I855_GM 0x4 -#define I852_GME 0x2 -#define I852_GM 0x5 - -/* BLT commands */ -#define COLOR_BLT_CMD ((2<<29)|(0x40<<22)|(0x3)) -#define COLOR_BLT_WRITE_ALPHA (1<<21) -#define COLOR_BLT_WRITE_RGB (1<<20) - -#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|(0x4)) -#define XY_COLOR_BLT_WRITE_ALPHA (1<<21) -#define XY_COLOR_BLT_WRITE_RGB (1<<20) - -#define XY_SETUP_CLIP_BLT_CMD ((2<<29)|(3<<22)|1) - -#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) -#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21) -#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20) - -#define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|0x4) -#define SRC_COPY_BLT_WRITE_ALPHA (1<<21) -#define SRC_COPY_BLT_WRITE_RGB (1<<20) - -#define XY_MONO_PAT_BLT_CMD ((0x2<<29)|(0x52<<22)|0x7) -#define XY_MONO_PAT_VERT_SEED ((1<<10)|(1<<9)|(1<<8)) -#define XY_MONO_PAT_HORT_SEED ((1<<14)|(1<<13)|(1<<12)) -#define XY_MONO_PAT_BLT_WRITE_ALPHA (1<<21) -#define XY_MONO_PAT_BLT_WRITE_RGB (1<<20) - -#define XY_MONO_SRC_BLT_CMD ((0x2<<29)|(0x54<<22)|(0x6)) -#define XY_MONO_SRC_BLT_WRITE_ALPHA (1<<21) -#define XY_MONO_SRC_BLT_WRITE_RGB (1<<20) - -/* 3d state */ -#define STATE3D_FOG_MODE ((3<<29)|(0x1d<<24)|(0x89<<16)|2) -#define FOG_MODE_VERTEX (1<<31) -#define STATE3D_MAP_COORD_TRANSFORM ((3<<29)|(0x1d<<24)|(0x8c<<16)) -#define DISABLE_TEX_TRANSFORM (1<<28) -#define TEXTURE_SET(x) (x<<29) -#define STATE3D_RASTERIZATION_RULES ((3<<29)|(0x07<<24)) -#define POINT_RASTER_ENABLE (1<<15) -#define POINT_RASTER_OGL (1<<13) -#define STATE3D_VERTEX_TRANSFORM ((3<<29)|(0x1d<<24)|(0x8b<<16)) -#define DISABLE_VIEWPORT_TRANSFORM (1<<31) -#define DISABLE_PERSPECTIVE_DIVIDE (1<<29) - -#define MI_SET_CONTEXT (0x18<<23) -#define CTXT_NO_RESTORE (1) -#define CTXT_PALETTE_SAVE_DISABLE (1<<3) -#define CTXT_PALETTE_RESTORE_DISABLE (1<<2) - -/* Dword 0 */ -#define MI_VERTEX_BUFFER (0x17<<23) -#define MI_VERTEX_BUFFER_IDX(x) (x<<20) -#define MI_VERTEX_BUFFER_PITCH(x) (x<<13) -#define MI_VERTEX_BUFFER_WIDTH(x) (x<<6) -/* Dword 1 */ -#define MI_VERTEX_BUFFER_DISABLE (1) - -/* Overlay Flip */ -#define MI_OVERLAY_FLIP (0x11<<23) -#define MI_OVERLAY_FLIP_CONTINUE (0<<21) -#define MI_OVERLAY_FLIP_ON (1<<21) -#define MI_OVERLAY_FLIP_OFF (2<<21) - -/* Wait for Events */ -#define MI_WAIT_FOR_EVENT (0x03<<23) -#define MI_WAIT_FOR_OVERLAY_FLIP (1<<16) - -/* Flush */ -#define MI_FLUSH (0x04<<23) -#define MI_WRITE_DIRTY_STATE (1<<4) -#define MI_END_SCENE (1<<3) -#define MI_INHIBIT_RENDER_CACHE_FLUSH (1<<2) -#define MI_INVALIDATE_MAP_CACHE (1<<0) - -/* Noop */ -#define MI_NOOP 0x00 -#define MI_NOOP_WRITE_ID (1<<22) -#define MI_NOOP_ID_MASK (1<<22 - 1) - -#define STATE3D_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x01<<16)) - -/* STATE3D_FOG_MODE stuff */ -#define ENABLE_FOG_SOURCE (1<<27) -#define ENABLE_FOG_CONST (1<<24) -#define ENABLE_FOG_DENSITY (1<<23) - - -#define MAX_DISPLAY_PIPES 2 - -typedef enum { - CrtIndex = 0, - TvIndex, - DfpIndex, - LfpIndex, - Tv2Index, - Dfp2Index, - UnknownIndex, - Unknown2Index, - NumDisplayTypes, - NumKnownDisplayTypes = UnknownIndex -} DisplayType; - -/* What's connected to the pipes (as reported by the BIOS) */ -#define PIPE_ACTIVE_MASK 0xff -#define PIPE_CRT_ACTIVE (1 << CrtIndex) -#define PIPE_TV_ACTIVE (1 << TvIndex) -#define PIPE_DFP_ACTIVE (1 << DfpIndex) -#define PIPE_LCD_ACTIVE (1 << LfpIndex) -#define PIPE_TV2_ACTIVE (1 << Tv2Index) -#define PIPE_DFP2_ACTIVE (1 << Dfp2Index) -#define PIPE_UNKNOWN_ACTIVE ((1 << UnknownIndex) | \ - (1 << Unknown2Index)) - -#define PIPE_SIZED_DISP_MASK (PIPE_DFP_ACTIVE | \ - PIPE_LCD_ACTIVE | \ - PIPE_DFP2_ACTIVE) - -#define PIPE_A_SHIFT 0 -#define PIPE_B_SHIFT 8 -#define PIPE_SHIFT(n) ((n) == 0 ? \ - PIPE_A_SHIFT : PIPE_B_SHIFT) - -/* - * Some BIOS scratch area registers. The 845 (and 830?) store the amount - * of video memory available to the BIOS in SWF1. - */ - -#define SWF0 0x71410 -#define SWF1 0x71414 -#define SWF2 0x71418 -#define SWF3 0x7141c -#define SWF4 0x71420 -#define SWF5 0x71424 -#define SWF6 0x71428 - -/* - * 855 scratch registers. - */ -#define SWF00 0x70410 -#define SWF01 0x70414 -#define SWF02 0x70418 -#define SWF03 0x7041c -#define SWF04 0x70420 -#define SWF05 0x70424 -#define SWF06 0x70428 - -#define SWF10 SWF0 -#define SWF11 SWF1 -#define SWF12 SWF2 -#define SWF13 SWF3 -#define SWF14 SWF4 -#define SWF15 SWF5 -#define SWF16 SWF6 - -#define SWF30 0x72414 -#define SWF31 0x72418 -#define SWF32 0x7241c - -/* - * Overlay registers. These are overlay registers accessed via MMIO. - * Those loaded via the overlay register page are defined in i830_video.c. - */ -#define OVADD 0x30000 - -#define DOVSTA 0x30008 -#define OC_BUF (0x3<<20) - -#define OGAMC5 0x30010 -#define OGAMC4 0x30014 -#define OGAMC3 0x30018 -#define OGAMC2 0x3001c -#define OGAMC1 0x30020 -#define OGAMC0 0x30024 - - -/* - * Palette registers - */ -#define PALETTE_A 0x0a000 -#define PALETTE_B 0x0a800 - -#endif /* _I810_REG_H */ diff --git a/src/mesa/drivers/dri/mach64/Makefile b/src/mesa/drivers/dri/mach64/Makefile deleted file mode 100644 index 0474c1a165f..00000000000 --- a/src/mesa/drivers/dri/mach64/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# src/mesa/drivers/dri/mach64/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = mach64_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - mach64_context.c \ - mach64_ioctl.c \ - mach64_screen.c \ - mach64_span.c \ - mach64_state.c \ - mach64_tex.c \ - mach64_texmem.c \ - mach64_texstate.c \ - mach64_tris.c \ - mach64_vb.c \ - mach64_dd.c \ - mach64_lock.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c deleted file mode 100644 index 35b01a97402..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_context.c +++ /dev/null @@ -1,356 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos�Fonseca <[email protected]> - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/simple_list.h" -#include "main/imports.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_dd.h" -#include "mach64_span.h" -#include "mach64_state.h" -#include "mach64_tex.h" -#include "mach64_tris.h" -#include "mach64_vb.h" - -#include "utils.h" -#include "vblank.h" - -#ifndef MACH64_DEBUG -int MACH64_DEBUG = (0); -#endif - -static const struct dri_debug_control debug_control[] = -{ - { "sync", DEBUG_ALWAYS_SYNC }, - { "api", DEBUG_VERBOSE_API }, - { "msg", DEBUG_VERBOSE_MSG }, - { "lru", DEBUG_VERBOSE_LRU }, - { "dri", DEBUG_VERBOSE_DRI }, - { "ioctl", DEBUG_VERBOSE_IOCTL }, - { "prims", DEBUG_VERBOSE_PRIMS }, - { "count", DEBUG_VERBOSE_COUNT }, - { "nowait", DEBUG_NOWAIT }, - { "fall", DEBUG_VERBOSE_FALLBACK }, - { NULL, 0 } -}; - -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_EXT_texture_edge_clamp", NULL }, - { "GL_MESA_ycbcr_texture", NULL }, - { NULL, NULL } -}; - - -/* Create the device specific context. - */ -GLboolean mach64CreateContext( gl_api api, - const struct gl_config *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - struct gl_context *ctx, *shareCtx; - __DRIscreen *driScreen = driContextPriv->driScreenPriv; - struct dd_function_table functions; - mach64ContextPtr mmesa; - mach64ScreenPtr mach64Screen; - int i, heap; - GLuint *c_textureSwapsPtr = NULL; - -#if DO_DEBUG - MACH64_DEBUG = driParseDebugString(getenv("MACH64_DEBUG"), debug_control); -#endif - - /* Allocate the mach64 context */ - mmesa = (mach64ContextPtr) CALLOC( sizeof(*mmesa) ); - if ( !mmesa ) - return GL_FALSE; - - /* Init default driver functions then plug in our Mach64-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions( &functions ); - mach64InitDriverFuncs( &functions ); - mach64InitIoctlFuncs( &functions ); - mach64InitTextureFuncs( &functions ); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((mach64ContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - mmesa->glCtx = _mesa_create_context(API_OPENGL, glVisual, shareCtx, - &functions, (void *)mmesa); - if (!mmesa->glCtx) { - FREE(mmesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = mmesa; - ctx = mmesa->glCtx; - - mmesa->driContext = driContextPriv; - mmesa->driScreen = driScreen; - mmesa->driDrawable = NULL; - mmesa->hHWContext = driContextPriv->hHWContext; - mmesa->driHwLock = &driScreen->pSAREA->lock; - mmesa->driFd = driScreen->fd; - - mach64Screen = mmesa->mach64Screen = (mach64ScreenPtr)driScreen->private; - - /* Parse configuration files */ - driParseConfigFiles (&mmesa->optionCache, &mach64Screen->optionCache, - mach64Screen->driScreen->myNum, "mach64"); - - mmesa->sarea = (drm_mach64_sarea_t *)((char *)driScreen->pSAREA + - sizeof(drm_sarea_t)); - - mmesa->CurrentTexObj[0] = NULL; - mmesa->CurrentTexObj[1] = NULL; - - (void) memset( mmesa->texture_heaps, 0, sizeof( mmesa->texture_heaps ) ); - make_empty_list( &mmesa->swapped ); - - mmesa->firstTexHeap = mach64Screen->firstTexHeap; - mmesa->lastTexHeap = mach64Screen->firstTexHeap + mach64Screen->numTexHeaps; - - for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) { - mmesa->texture_heaps[i] = driCreateTextureHeap( i, mmesa, - mach64Screen->texSize[i], - 6, /* align to 64-byte boundary, use 12 for page-size boundary */ - MACH64_NR_TEX_REGIONS, - (drmTextureRegionPtr)mmesa->sarea->tex_list[i], - &mmesa->sarea->tex_age[i], - &mmesa->swapped, - sizeof( mach64TexObj ), - (destroy_texture_object_t *) mach64DestroyTexObj ); - -#if ENABLE_PERF_BOXES - c_textureSwapsPtr = & mmesa->c_textureSwaps; -#endif - driSetTextureSwapCounterLocation( mmesa->texture_heaps[i], - c_textureSwapsPtr ); - } - - mmesa->RenderIndex = -1; /* Impossible value */ - mmesa->vert_buf = NULL; - mmesa->num_verts = 0; - mmesa->new_state = MACH64_NEW_ALL; - mmesa->dirty = MACH64_UPLOAD_ALL; - - /* 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 memory (on-card or AGP) at once. - * Test for 2 textures * bytes/texel * size * size. There's no - * need to account for mipmaps since we only upload one level. - */ - - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureImageUnits = 2; - ctx->Const.MaxTextureCoordUnits = 2; - ctx->Const.MaxDrawBuffers = 1; - - heap = mach64Screen->IsPCI ? MACH64_CARD_HEAP : MACH64_AGP_HEAP; - - driCalculateMaxTextureLevels( & mmesa->texture_heaps[heap], - 1, - & ctx->Const, - mach64Screen->cpp, - 10, /* max 2D texture size is 1024x1024 */ - 0, /* 3D textures unsupported. */ - 0, /* cube textures unsupported. */ - 0, /* texture rectangles unsupported. */ - 1, /* mipmapping unsupported. */ - GL_TRUE, /* need to have both textures in - either local or AGP memory */ - 0 ); - -#if ENABLE_PERF_BOXES - mmesa->boxes = ( getenv( "LIBGL_PERFORMANCE_BOXES" ) != NULL ); -#endif - - /* Allocate the vertex buffer - */ - mmesa->vert_buf = _mesa_align_malloc(MACH64_BUFFER_SIZE, 32); - if ( !mmesa->vert_buf ) - return GL_FALSE; - mmesa->vert_used = 0; - mmesa->vert_total = MACH64_BUFFER_SIZE; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ -/* _tnl_destroy_pipeline( ctx ); */ -/* _tnl_install_pipeline( ctx, mach64_pipeline ); */ - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - _tnl_allow_pixel_fog( ctx, GL_FALSE ); - _tnl_allow_vertex_fog( ctx, GL_TRUE ); - - driInitExtensions( ctx, card_extensions, GL_TRUE ); - - mach64InitVB( ctx ); - mach64InitTriFuncs( ctx ); - mach64DDInitStateFuncs( ctx ); - mach64DDInitSpanFuncs( ctx ); - mach64DDInitState( mmesa ); - - mmesa->do_irqs = (mmesa->mach64Screen->irq && !getenv("MACH64_NO_IRQS")); - - driContextPriv->driverPrivate = (void *)mmesa; - - if (driQueryOptionb(&mmesa->optionCache, "no_rast")) { - fprintf(stderr, "disabling 3D acceleration\n"); - FALLBACK(mmesa, MACH64_FALLBACK_DISABLE, 1); - } - - return GL_TRUE; -} - -/* Destroy the device specific context. - */ -void mach64DestroyContext( __DRIcontext *driContextPriv ) -{ - mach64ContextPtr mmesa = (mach64ContextPtr) driContextPriv->driverPrivate; - - assert(mmesa); /* should never be null */ - if ( mmesa ) { - GLboolean release_texture_heaps; - - release_texture_heaps = (mmesa->glCtx->Shared->RefCount == 1); - - _swsetup_DestroyContext( mmesa->glCtx ); - _tnl_DestroyContext( mmesa->glCtx ); - _vbo_DestroyContext( mmesa->glCtx ); - _swrast_DestroyContext( mmesa->glCtx ); - - if (release_texture_heaps) { - /* This share group is about to go away, free our private - * texture object data. - */ - int i; - - for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) { - driDestroyTextureHeap( mmesa->texture_heaps[i] ); - mmesa->texture_heaps[i] = NULL; - } - - assert( is_empty_list( & mmesa->swapped ) ); - } - - mach64FreeVB( mmesa->glCtx ); - - /* Free the vertex buffer */ - if ( mmesa->vert_buf ) - _mesa_align_free( mmesa->vert_buf ); - - /* free the Mesa context */ - mmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(mmesa->glCtx); - - FREE( mmesa ); - } -} - -/* Force the context `c' to be the current context and associate with it - * buffer `b'. - */ -GLboolean -mach64MakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ) -{ - if ( driContextPriv ) { - GET_CURRENT_CONTEXT(ctx); - mach64ContextPtr oldMach64Ctx = ctx ? MACH64_CONTEXT(ctx) : NULL; - mach64ContextPtr newMach64Ctx = (mach64ContextPtr) driContextPriv->driverPrivate; - - if ( newMach64Ctx != oldMach64Ctx ) { - newMach64Ctx->new_state |= MACH64_NEW_CONTEXT; - newMach64Ctx->dirty = MACH64_UPLOAD_ALL; - } - - - if ( newMach64Ctx->driDrawable != driDrawPriv ) { - if (driDrawPriv->swap_interval == (unsigned)-1) { - driDrawPriv->vblFlags = (newMach64Ctx->do_irqs) - ? driGetDefaultVBlankFlags(&newMach64Ctx->optionCache) - : VBLANK_FLAG_NO_IRQ; - - driDrawableInitVBlank( driDrawPriv ); - } - - newMach64Ctx->driDrawable = driDrawPriv; - mach64CalcViewport( newMach64Ctx->glCtx ); - } - - _mesa_make_current( newMach64Ctx->glCtx, - (struct gl_framebuffer *) driDrawPriv->driverPrivate, - (struct gl_framebuffer *) driReadPriv->driverPrivate ); - - - newMach64Ctx->new_state |= MACH64_NEW_CLIP; - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - return GL_TRUE; -} - - -/* Force the context `c' to be unbound from its buffer. - */ -GLboolean -mach64UnbindContext( __DRIcontext *driContextPriv ) -{ - return GL_TRUE; -} diff --git a/src/mesa/drivers/dri/mach64/mach64_context.h b/src/mesa/drivers/dri/mach64/mach64_context.h deleted file mode 100644 index 70bc0ae79de..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_context.h +++ /dev/null @@ -1,369 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos�Fonseca <[email protected]> - */ - -#ifndef __MACH64_CONTEXT_H__ -#define __MACH64_CONTEXT_H__ - -#include "dri_util.h" -#include "drm.h" -#include "mach64_drm.h" - -#include "main/mtypes.h" - -#include "mach64_reg.h" - -#include "texmem.h" - -struct mach64_context; -typedef struct mach64_context mach64ContextRec; -typedef struct mach64_context *mach64ContextPtr; - -#include "mach64_lock.h" -#include "mach64_screen.h" - -/* Experimental driver options */ -#define MACH64_CLIENT_STATE_EMITS 0 - -/* Performace monitoring */ -#define ENABLE_PERF_BOXES 1 - -/* Native vertex format */ -#define MACH64_NATIVE_VTXFMT 1 - -/* Flags for what context state needs to be updated: - */ -#define MACH64_NEW_ALPHA 0x0001 -#define MACH64_NEW_DEPTH 0x0002 -#define MACH64_NEW_FOG 0x0004 -#define MACH64_NEW_CLIP 0x0008 -#define MACH64_NEW_CULL 0x0010 -#define MACH64_NEW_MASKS 0x0020 -#define MACH64_NEW_RENDER_UNUSED 0x0040 -#define MACH64_NEW_WINDOW 0x0080 -#define MACH64_NEW_TEXTURE 0x0100 -#define MACH64_NEW_CONTEXT 0x0200 -#define MACH64_NEW_ALL 0x03ff - -/* Flags for software fallback cases: - */ -#define MACH64_FALLBACK_TEXTURE 0x0001 -#define MACH64_FALLBACK_DRAW_BUFFER 0x0002 -#define MACH64_FALLBACK_READ_BUFFER 0x0004 -#define MACH64_FALLBACK_STENCIL 0x0008 -#define MACH64_FALLBACK_RENDER_MODE 0x0010 -#define MACH64_FALLBACK_LOGICOP 0x0020 -#define MACH64_FALLBACK_SEP_SPECULAR 0x0040 -#define MACH64_FALLBACK_BLEND_EQ 0x0080 -#define MACH64_FALLBACK_BLEND_FUNC 0x0100 -#define MACH64_FALLBACK_DISABLE 0x0200 - -#define CARD32 GLuint /* KW: For building in mesa tree */ - -#if MACH64_NATIVE_VTXFMT - -/* The vertex structures. - */ - -/* The size of this union is not of relevence: - */ -union mach64_vertex_t { - GLfloat f[16]; - GLuint ui[16]; - GLushort us2[16][2]; - GLubyte ub4[16][4]; -}; - -typedef union mach64_vertex_t mach64Vertex, *mach64VertexPtr; - -#else - -/* Use the templated vertex format: - */ -#define TAG(x) mach64##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -#endif /* MACH64_NATIVE_VTXFMT */ - -/* Subpixel offsets for window coordinates: - * These are enough to fix most glean tests except polygonOffset. - * There are also still some gaps that show in e.g. the tunnel Mesa demo - * or the lament xscreensaver hack. - */ -#define SUBPIXEL_X (0.0125F) -#define SUBPIXEL_Y (0.15F) - - -typedef void (*mach64_tri_func)( mach64ContextPtr, - mach64Vertex *, - mach64Vertex *, - mach64Vertex * ); - -typedef void (*mach64_line_func)( mach64ContextPtr, - mach64Vertex *, - mach64Vertex * ); - -typedef void (*mach64_point_func)( mach64ContextPtr, - mach64Vertex * ); - -struct mach64_texture_object { - driTextureObject base; - - GLuint bufAddr; - - GLint heap; /* same as base.heap->heapId */ - - /* For communicating values from mach64AllocTexObj(), mach64SetTexImages() - * to mach64UpdateTextureUnit(). Alternately, we can use the tObj values or - * set the context registers directly. - */ - GLint widthLog2; - GLint heightLog2; - GLint maxLog2; - - GLint hasAlpha; - GLint textureFormat; - - GLboolean BilinearMin; - GLboolean BilinearMag; - GLboolean ClampS; - GLboolean ClampT; -}; - -typedef struct mach64_texture_object mach64TexObj, *mach64TexObjPtr; - -struct mach64_context { - struct gl_context *glCtx; - - /* Driver and hardware state management - */ - GLuint new_state; - GLuint dirty; /* Hardware state to be updated */ - drm_mach64_context_regs_t setup; - - 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; - GLubyte *verts; - - CARD32 Color; /* Current draw color */ - CARD32 ClearColor; /* Color used to clear color buffer */ - CARD32 ClearDepth; /* Value used to clear depth buffer */ - - /* Map GL texture units onto hardware - */ - GLint multitex; - GLint tmu_source[2]; - GLint tex_dest[2]; - - /* Texture object bookkeeping - */ - mach64TexObjPtr CurrentTexObj[2]; - - GLint firstTexHeap, lastTexHeap; - driTexHeap *texture_heaps[MACH64_NR_TEX_HEAPS]; - driTextureObject swapped; - - /* Fallback rasterization functions - */ - mach64_point_func draw_point; - mach64_line_func draw_line; - mach64_tri_func draw_tri; - - /* Culling */ - GLfloat backface_sign; - - /* DMA buffers - */ - void *vert_buf; - size_t vert_total; - unsigned vert_used; - - GLuint hw_primitive; - GLenum render_primitive; - - /* Visual, drawable, cliprect and scissor information - */ - GLint drawOffset, drawPitch; - GLint drawX, drawY; /* origin of drawable in draw buffer */ - GLint readOffset, readPitch; - - GLuint numClipRects; /* Cliprects for the draw buffer */ - drm_clip_rect_t *pClipRects; - - GLint scissor; - drm_clip_rect_t ScissorRect; /* Current software scissor */ - - /* Mirrors of some DRI state - */ - __DRIcontext *driContext; /* DRI context */ - __DRIscreen *driScreen; /* DRI screen */ - __DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */ - - unsigned int lastStamp; /* mirror driDrawable->lastStamp */ - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - - mach64ScreenPtr mach64Screen; /* Screen private DRI data */ - drm_mach64_sarea_t *sarea; /* Private SAREA data */ - - GLuint hardwareWentIdle; - -#if ENABLE_PERF_BOXES - /* Performance counters - */ - GLuint boxes; /* Draw performance boxes */ - GLuint c_clears; - GLuint c_drawWaits; - GLuint c_textureSwaps; - GLuint c_textureBytes; - GLuint c_agpTextureBytes; - GLuint c_texsrc_agp; - GLuint c_texsrc_card; - GLuint c_vertexBuffers; -#endif - - /* VBI - */ - GLuint do_irqs; - - /* Configuration cache - */ - driOptionCache optionCache; -}; - -#define MACH64_CONTEXT(ctx) ((mach64ContextPtr)(ctx->DriverCtx)) - - -extern GLboolean mach64CreateContext( gl_api api, - const struct gl_config *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ); - -extern void mach64DestroyContext( __DRIcontext * ); - -extern GLboolean mach64MakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ); - -extern GLboolean mach64UnbindContext( __DRIcontext *driContextPriv ); - -/* ================================================================ - * Byte ordering - */ -#if MESA_LITTLE_ENDIAN == 1 -#define LE32_IN( x ) ( *(GLuint *)(x) ) -#define LE32_IN_FLOAT( x ) ( *(GLfloat *)(x) ) -#define LE32_OUT( x, y ) do { *(GLuint *)(x) = (y); } while (0) -#define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)(x) = (y); } while (0) -#else -#if defined(__OpenBSD__) || defined(__NetBSD__) -#include <machine/endian.h> -#define bswap_32 bswap32 -#else -#include <byteswap.h> -#endif - -#define LE32_IN( x ) bswap_32( *(GLuint *)(x) ) -#define LE32_IN_FLOAT( x ) \ -({ \ - GLuint __tmp = bswap_32( *(GLuint *)(x) ); \ - *(GLfloat *)&__tmp; \ -}) -#define LE32_OUT( x, y ) do { *(GLuint *)(x) = bswap_32( y ); } while (0) -#define LE32_OUT_FLOAT( x, y ) \ -do { \ - GLuint __tmp; \ - *(GLfloat *)&__tmp = (y); \ - *(GLuint *)(x) = bswap_32( __tmp ); \ -} while (0) -#endif - -/* ================================================================ - * DMA buffers - */ - -#define DMALOCALS CARD32 *buf=NULL; int requested=0; int outcount=0 - -/* called while locked for interleaved client-side state emits */ -#define DMAGETPTR( dwords ) \ -do { \ - requested = (dwords); \ - buf = (CARD32 *)mach64AllocDmaLocked( mmesa, ((dwords)*4) ); \ - outcount = 0; \ -} while(0) - -#define DMAOUTREG( reg, val ) \ -do { \ - LE32_OUT( &buf[outcount++], ADRINDEX( reg ) ); \ - LE32_OUT( &buf[outcount++], ( val ) ); \ -} while(0) - -#define DMAADVANCE() \ -do { \ - if (outcount < requested) { \ - mmesa->vert_used -= (requested - outcount) * 4; \ - } \ -} while(0) - -/* ================================================================ - * Debugging: - */ - -#define DO_DEBUG 1 - -#if DO_DEBUG -extern int MACH64_DEBUG; -#else -#define MACH64_DEBUG 0 -#endif - -#define DEBUG_ALWAYS_SYNC 0x001 -#define DEBUG_VERBOSE_API 0x002 -#define DEBUG_VERBOSE_MSG 0x004 -#define DEBUG_VERBOSE_LRU 0x008 -#define DEBUG_VERBOSE_DRI 0x010 -#define DEBUG_VERBOSE_IOCTL 0x020 -#define DEBUG_VERBOSE_PRIMS 0x040 -#define DEBUG_VERBOSE_COUNT 0x080 -#define DEBUG_NOWAIT 0x100 -#define DEBUG_VERBOSE_FALLBACK 0x200 -#endif /* __MACH64_CONTEXT_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_dd.c b/src/mesa/drivers/dri/mach64/mach64_dd.c deleted file mode 100644 index 2b557a70202..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_dd.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_dd.h" - -#include "main/context.h" - -#include "utils.h" - -/* Return the current color buffer size. - */ -static void mach64DDGetBufferSize( struct gl_framebuffer *buffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - LOCK_HARDWARE( mmesa ); - *width = mmesa->driDrawable->w; - *height = mmesa->driDrawable->h; - UNLOCK_HARDWARE( mmesa ); -} - -/* Return various strings for glGetString(). - */ -static const GLubyte *mach64DDGetString( struct gl_context *ctx, GLenum name ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - static char buffer[128]; - unsigned offset; - const char * card_name = "Mach64 [Rage Pro]"; - GLuint agp_mode = mmesa->mach64Screen->IsPCI ? 0 : - mmesa->mach64Screen->AGPMode; - - switch ( name ) { - case GL_VENDOR: - return (GLubyte*)"Gareth Hughes, Leif Delgass, Jos� Fonseca"; - - case GL_RENDERER: - - offset = driGetRendererString( buffer, card_name, agp_mode ); - 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 mach64DDFlush( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - LOCK_HARDWARE( mmesa ); - FLUSH_DMA_LOCKED( mmesa ); - UNLOCK_HARDWARE( mmesa ); - -#if ENABLE_PERF_BOXES - if ( mmesa->boxes ) { - LOCK_HARDWARE( mmesa ); - mach64PerformanceBoxesLocked( mmesa ); - UNLOCK_HARDWARE( mmesa ); - } - - /* Log the performance counters if necessary */ - mach64PerformanceCounters( mmesa ); -#endif -} - -/* Make sure all commands have been sent to the hardware and have - * completed processing. - */ -static void mach64DDFinish( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - mmesa->c_drawWaits++; -#endif - - mach64DDFlush( ctx ); - mach64WaitForIdle( mmesa ); -} - -/* Initialize the driver's misc functions. - */ -void mach64InitDriverFuncs( struct dd_function_table *functions ) -{ - functions->GetBufferSize = mach64DDGetBufferSize; - functions->GetString = mach64DDGetString; - functions->Finish = mach64DDFinish; - functions->Flush = mach64DDFlush; - -} diff --git a/src/mesa/drivers/dri/mach64/mach64_dd.h b/src/mesa/drivers/dri/mach64/mach64_dd.h deleted file mode 100644 index 0a2ce064120..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_dd.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * - */ - -#ifndef __MACH64_DD_H__ -#define __MACH64_DD_H__ - -extern void mach64InitDriverFuncs( struct dd_function_table *functions ); - -#endif diff --git a/src/mesa/drivers/dri/mach64/mach64_ioctl.c b/src/mesa/drivers/dri/mach64/mach64_ioctl.c deleted file mode 100644 index 0146e0d0515..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_ioctl.c +++ /dev/null @@ -1,932 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos�Fonseca <[email protected]> - */ -#include <errno.h> - -#include "mach64_context.h" -#include "mach64_state.h" -#include "mach64_ioctl.h" -#include "mach64_tex.h" - -#include "main/imports.h" -#include "main/macros.h" - -#include "swrast/swrast.h" - -#include "vblank.h" - -#define MACH64_TIMEOUT 10 /* the DRM already has a timeout, so keep this small */ - - -/* ============================================================= - * Hardware vertex buffer handling - */ - -/* Get a new VB from the pool of vertex buffers in AGP space. - */ -drmBufPtr mach64GetBufferLocked( mach64ContextPtr mmesa ) -{ - int fd = mmesa->mach64Screen->driScreen->fd; - int index = 0; - int size = 0; - drmDMAReq dma; - drmBufPtr buf = NULL; - int to = 0; - int ret; - - dma.context = mmesa->hHWContext; - dma.send_count = 0; - dma.send_list = NULL; - dma.send_sizes = NULL; - dma.flags = 0; - dma.request_count = 1; - dma.request_size = MACH64_BUFFER_SIZE; - dma.request_list = &index; - dma.request_sizes = &size; - dma.granted_count = 0; - - while ( !buf && ( to++ < MACH64_TIMEOUT ) ) { - ret = drmDMA( fd, &dma ); - - if ( ret == 0 ) { - buf = &mmesa->mach64Screen->buffers->list[index]; - buf->used = 0; -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - mmesa->c_vertexBuffers++; -#endif - return buf; - } - } - - if ( !buf ) { - drmCommandNone( fd, DRM_MACH64_RESET ); - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "Error: Could not get new VB... exiting\n" ); - exit( -1 ); - } - - return buf; -} - -void mach64FlushVerticesLocked( mach64ContextPtr mmesa ) -{ - drm_clip_rect_t *pbox = mmesa->pClipRects; - int nbox = mmesa->numClipRects; - void *buffer = mmesa->vert_buf; - int count = mmesa->vert_used; - int prim = mmesa->hw_primitive; - int fd = mmesa->driScreen->fd; - drm_mach64_vertex_t vertex; - int i; - - mmesa->num_verts = 0; - mmesa->vert_used = 0; - - if ( !count ) - return; - - if ( mmesa->dirty & ~MACH64_UPLOAD_CLIPRECTS ) - mach64EmitHwStateLocked( mmesa ); - - if ( !nbox ) - count = 0; - - if ( nbox > MACH64_NR_SAREA_CLIPRECTS ) - mmesa->dirty |= MACH64_UPLOAD_CLIPRECTS; - - if ( !count || !(mmesa->dirty & MACH64_UPLOAD_CLIPRECTS) ) { - int to = 0; - int ret; - - /* FIXME: Is this really necessary */ - if ( nbox == 1 ) - mmesa->sarea->nbox = 0; - else - mmesa->sarea->nbox = nbox; - - vertex.prim = prim; - vertex.buf = buffer; - vertex.used = count; - vertex.discard = 1; - do { - ret = drmCommandWrite( fd, DRM_MACH64_VERTEX, - &vertex, sizeof(drm_mach64_vertex_t) ); - } while ( ( ret == -EAGAIN ) && ( to++ < MACH64_TIMEOUT ) ); - if ( ret ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "Error flushing vertex buffer: return = %d\n", ret ); - exit( -1 ); - } - - } else { - - for ( i = 0 ; i < nbox ; ) { - int nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS, nbox ); - drm_clip_rect_t *b = mmesa->sarea->boxes; - int discard = 0; - int to = 0; - int ret; - - mmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++ ) { - *b++ = pbox[i]; - } - - /* Finished with the buffer? - */ - if ( nr == nbox ) { - discard = 1; - } - - mmesa->sarea->dirty |= MACH64_UPLOAD_CLIPRECTS; - - vertex.prim = prim; - vertex.buf = buffer; - vertex.used = count; - vertex.discard = discard; - do { - ret = drmCommandWrite( fd, DRM_MACH64_VERTEX, - &vertex, sizeof(drm_mach64_vertex_t) ); - } while ( ( ret == -EAGAIN ) && ( to++ < MACH64_TIMEOUT ) ); - if ( ret ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "Error flushing vertex buffer: return = %d\n", ret ); - exit( -1 ); - } - } - } - - mmesa->dirty &= ~MACH64_UPLOAD_CLIPRECTS; -} - -/* ================================================================ - * Texture uploads - */ - -void mach64FireBlitLocked( mach64ContextPtr mmesa, void *buffer, - GLint offset, GLint pitch, GLint format, - GLint x, GLint y, GLint width, GLint height ) -{ - drm_mach64_blit_t blit; - int to = 0; - int ret; - - blit.buf = buffer; - blit.offset = offset; - blit.pitch = pitch; - blit.format = format; - blit.x = x; - blit.y = y; - blit.width = width; - blit.height = height; - - do { - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_BLIT, - &blit, sizeof(drm_mach64_blit_t) ); - } while ( ( ret == -EAGAIN ) && ( to++ < MACH64_TIMEOUT ) ); - - if ( ret ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_BLIT: return = %d\n", ret ); - exit( -1 ); - } -} - - -/* ================================================================ - * SwapBuffers with client-side throttling - */ -static void delay( void ) { -/* Prevent an optimizing compiler from removing a spin loop */ -} - -/* Throttle the frame rate -- only allow MACH64_MAX_QUEUED_FRAMES - * pending swap buffers requests 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. - */ -static int mach64WaitForFrameCompletion( mach64ContextPtr mmesa ) -{ - int fd = mmesa->driFd; - int i; - int wait = 0; - int frames; - - while ( 1 ) { - drm_mach64_getparam_t gp; - int ret; - - if ( mmesa->sarea->frames_queued < MACH64_MAX_QUEUED_FRAMES ) { - break; - } - - if (MACH64_DEBUG & DEBUG_NOWAIT) { - return 1; - } - - gp.param = MACH64_PARAM_FRAMES_QUEUED; - gp.value = &frames; /* also copied into sarea->frames_queued by DRM */ - - ret = drmCommandWriteRead( fd, DRM_MACH64_GETPARAM, &gp, sizeof(gp) ); - - if ( ret ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_GETPARAM: return = %d\n", ret ); - exit( -1 ); - } - - /* Spin in place a bit so we aren't hammering the register */ - wait++; - - for ( i = 0 ; i < 1024 ; i++ ) { - delay(); - } - - } - - return wait; -} - -/* Copy the back color buffer to the front color buffer. - */ -void mach64CopyBuffer( __DRIdrawable *dPriv ) -{ - mach64ContextPtr mmesa; - GLint nbox, i, ret; - drm_clip_rect_t *pbox; - GLboolean missed_target; - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - mmesa = (mach64ContextPtr) dPriv->driContextPriv->driverPrivate; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "\n********************************\n" ); - fprintf( stderr, "\n%s( %p )\n\n", - __FUNCTION__, mmesa->glCtx ); - fflush( stderr ); - } - - /* Flush any outstanding vertex buffers */ - FLUSH_BATCH( mmesa ); - - LOCK_HARDWARE( mmesa ); - - /* Throttle the frame rate -- only allow one pending swap buffers - * request at a time. - */ - if ( !mach64WaitForFrameCompletion( mmesa ) ) { - mmesa->hardwareWentIdle = 1; - } else { - mmesa->hardwareWentIdle = 0; - } - -#if ENABLE_PERF_BOXES - if ( mmesa->boxes ) { - mach64PerformanceBoxesLocked( mmesa ); - } -#endif - - UNLOCK_HARDWARE( mmesa ); - driWaitForVBlank( dPriv, &missed_target ); - LOCK_HARDWARE( mmesa ); - - /* use front buffer cliprects */ - nbox = dPriv->numClipRects; - pbox = dPriv->pClipRects; - - for ( i = 0 ; i < nbox ; ) { - GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox ); - drm_clip_rect_t *b = mmesa->sarea->boxes; - GLint n = 0; - - for ( ; i < nr ; i++ ) { - *b++ = pbox[i]; - n++; - } - mmesa->sarea->nbox = n; - - ret = drmCommandNone( mmesa->driFd, DRM_MACH64_SWAP ); - - if ( ret ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_SWAP: return = %d\n", ret ); - exit( -1 ); - } - } - - if ( MACH64_DEBUG & DEBUG_ALWAYS_SYNC ) { - mach64WaitForIdleLocked( mmesa ); - } - - UNLOCK_HARDWARE( mmesa ); - - mmesa->dirty |= (MACH64_UPLOAD_CONTEXT | - MACH64_UPLOAD_MISC | - MACH64_UPLOAD_CLIPRECTS); - -#if ENABLE_PERF_BOXES - /* Log the performance counters if necessary */ - mach64PerformanceCounters( mmesa ); -#endif -} - -#if ENABLE_PERF_BOXES -/* ================================================================ - * Performance monitoring - */ - -void mach64PerformanceCounters( mach64ContextPtr mmesa ) -{ - - if (MACH64_DEBUG & DEBUG_VERBOSE_COUNT) { - /* report performance counters */ - fprintf( stderr, "mach64CopyBuffer: vertexBuffers:%i drawWaits:%i clears:%i\n", - mmesa->c_vertexBuffers, mmesa->c_drawWaits, mmesa->c_clears ); - } - - mmesa->c_vertexBuffers = 0; - mmesa->c_drawWaits = 0; - mmesa->c_clears = 0; - - if ( mmesa->c_textureSwaps || mmesa->c_textureBytes || mmesa->c_agpTextureBytes ) { - if (MACH64_DEBUG & DEBUG_VERBOSE_COUNT) { - fprintf( stderr, " textureSwaps:%i textureBytes:%i agpTextureBytes:%i\n", - mmesa->c_textureSwaps, mmesa->c_textureBytes, mmesa->c_agpTextureBytes ); - } - mmesa->c_textureSwaps = 0; - mmesa->c_textureBytes = 0; - mmesa->c_agpTextureBytes = 0; - } - - mmesa->c_texsrc_agp = 0; - mmesa->c_texsrc_card = 0; - - if (MACH64_DEBUG & DEBUG_VERBOSE_COUNT) - fprintf( stderr, "---------------------------------------------------------\n" ); -} - - -void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa ) -{ - GLint ret; - drm_mach64_clear_t clear; - GLint x, y, w, h; - GLuint color; - GLint nbox; - GLint x1, y1, x2, y2; - drm_clip_rect_t *b = mmesa->sarea->boxes; - - /* save cliprects */ - nbox = mmesa->sarea->nbox; - x1 = b[0].x1; - y1 = b[0].y1; - x2 = b[0].x2; - y2 = b[0].y2; - - /* setup a single cliprect and call the clear ioctl for each box */ - mmesa->sarea->nbox = 1; - - w = h = 8; - x = mmesa->drawX; - y = mmesa->drawY; - b[0].x1 = x; - b[0].x2 = x + w; - b[0].y1 = y; - b[0].y2 = y + h; - - clear.flags = MACH64_BACK; - clear.clear_depth = 0; - - /* Red box if DDFinish was called to wait for rendering to complete */ - if ( mmesa->c_drawWaits ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 0, 0, 0 ); - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - - } - - x += w; - b[0].x1 = x; - b[0].x2 = x + w; - - /* draw a green box if we had to wait for previous frame(s) to complete */ - if ( !mmesa->hardwareWentIdle ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 0, 255, 0, 0 ); - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - - } - - x += w; - w = 20; - b[0].x1 = x; - - /* show approx. ratio of AGP/card textures used - Blue = AGP, Purple = Card */ - if ( mmesa->c_texsrc_agp || mmesa->c_texsrc_card ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 0, 0, 255, 0 ); - w = ((GLfloat)mmesa->c_texsrc_agp / (GLfloat)(mmesa->c_texsrc_agp + mmesa->c_texsrc_card))*20; - if (w > 1) { - - b[0].x2 = x + w; - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - } - - x += w; - w = 20 - w; - - if (w > 1) { - b[0].x1 = x; - b[0].x2 = x + w; - - color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 0, 255, 0 ); - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - } - } - - x += w; - w = 8; - b[0].x1 = x; - b[0].x2 = x + w; - - /* Yellow box if we swapped textures */ - if ( mmesa->c_textureSwaps ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 255, 0, 0 ); - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - - } - - h = 4; - x += 8; - b[0].x1 = x; - b[0].y2 = y + h; - - /* Purple bar for card memory texture blits/uploads */ - if ( mmesa->c_textureBytes ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 0, 255, 0 ); - w = mmesa->c_textureBytes / 16384; - if ( w <= 0 ) - w = 1; - if (w > (mmesa->driDrawable->w - 44)) - w = mmesa->driDrawable->w - 44; - - b[0].x2 = x + w; - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - } - - /* Blue bar for AGP memory texture blits/uploads */ - if ( mmesa->c_agpTextureBytes ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 0, 0, 255, 0 ); - w = mmesa->c_agpTextureBytes / 16384; - if ( w <= 0 ) - w = 1; - if (w > (mmesa->driDrawable->w - 44)) - w = mmesa->driDrawable->w - 44; - - y += 4; - b[0].x2 = x + w; - b[0].y1 = y; - b[0].y2 = y + h; - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - } - - /* Pink bar for number of vertex buffers used */ - if ( mmesa->c_vertexBuffers ) { - color = mach64PackColor( mmesa->mach64Screen->cpp, 196, 128, 128, 0 ); - - w = mmesa->c_vertexBuffers; - if (w > (mmesa->driDrawable->w)) - w = mmesa->driDrawable->w; - - h = 8; - x = mmesa->drawX; - y = mmesa->drawY + 8; - b[0].x1 = x; - b[0].x2 = x + w; - b[0].y1 = y; - b[0].y2 = y + h; - - clear.x = x; - clear.y = y; - clear.w = w; - clear.h = h; - clear.clear_color = color; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if (ret < 0) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - } - - /* restore cliprects */ - mmesa->sarea->nbox = nbox; - b[0].x1 = x1; - b[0].y1 = y1; - b[0].x2 = x2; - b[0].y2 = y2; - -} - -#endif - -/* ================================================================ - * Buffer clear - */ - -static void mach64DDClear( struct gl_context *ctx, GLbitfield mask ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - __DRIdrawable *dPriv = mmesa->driDrawable; - drm_mach64_clear_t clear; - GLuint flags = 0; - GLint i; - GLint ret; - GLint cx, cy, cw, ch; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "mach64DDClear\n"); - } - -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - mmesa->c_clears++; -#endif - - FLUSH_BATCH( mmesa ); - - /* The only state changes we care about here are the RGBA colormask - * and scissor/clipping. We'll just update that state, if needed. - */ - if ( mmesa->new_state & (MACH64_NEW_MASKS | MACH64_NEW_CLIP) ) { - const GLuint save_state = mmesa->new_state; - mmesa->new_state &= (MACH64_NEW_MASKS | MACH64_NEW_CLIP); - mach64DDUpdateHWState( ctx ); - mmesa->new_state = save_state & ~(MACH64_NEW_MASKS | MACH64_NEW_CLIP); - } - - if ( mask & BUFFER_BIT_FRONT_LEFT ) { - flags |= MACH64_FRONT; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if ( mask & BUFFER_BIT_BACK_LEFT ) { - flags |= MACH64_BACK; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) { - flags |= MACH64_DEPTH; - mask &= ~BUFFER_BIT_DEPTH; - } - - if ( mask ) - _swrast_Clear( ctx, mask ); - - if ( !flags ) - return; - - LOCK_HARDWARE( mmesa ); - - /* compute region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - - /* Flip top to bottom */ - cx += mmesa->drawX; - cy = mmesa->drawY + dPriv->h - cy - ch; - - /* HACK? - */ - if ( mmesa->dirty & ~MACH64_UPLOAD_CLIPRECTS ) { - mach64EmitHwStateLocked( mmesa ); - } - - for ( i = 0 ; i < mmesa->numClipRects ; ) { - int nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS, mmesa->numClipRects ); - drm_clip_rect_t *box = mmesa->pClipRects; - drm_clip_rect_t *b = mmesa->sarea->boxes; - GLint n = 0; - - if (cw != dPriv->w || ch != dPriv->h) { - /* clear subregion */ - 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 { - /* clear whole window */ - for ( ; i < nr ; i++ ) { - *b++ = box[i]; - n++; - } - } - - mmesa->sarea->nbox = n; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) { - fprintf( stderr, - "DRM_MACH64_CLEAR: flag 0x%x color %x depth %x nbox %d\n", - flags, - (GLuint)mmesa->ClearColor, - (GLuint)mmesa->ClearDepth, - mmesa->sarea->nbox ); - } - - clear.flags = flags; - clear.x = cx; - clear.y = cy; - clear.w = cw; - clear.h = ch; - clear.clear_color = mmesa->ClearColor; - clear.clear_depth = mmesa->ClearDepth; - - ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR, - &clear, sizeof(drm_mach64_clear_t) ); - - if ( ret ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret ); - exit( -1 ); - } - } - - UNLOCK_HARDWARE( mmesa ); - - mmesa->dirty |= (MACH64_UPLOAD_CONTEXT | - MACH64_UPLOAD_MISC | - MACH64_UPLOAD_CLIPRECTS); - -} - - -void mach64WaitForIdleLocked( mach64ContextPtr mmesa ) -{ - int fd = mmesa->driFd; - int to = 0; - int ret; - - do { - ret = drmCommandNone( fd, DRM_MACH64_IDLE ); - } while ( ( ret == -EBUSY ) && ( to++ < MACH64_TIMEOUT ) ); - - if ( ret < 0 ) { - drmCommandNone( fd, DRM_MACH64_RESET ); - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "Error: Mach64 timed out... exiting\n" ); - exit( -1 ); - } -} - -/* Flush the DMA queue to the hardware */ -void mach64FlushDMALocked( mach64ContextPtr mmesa ) -{ - int fd = mmesa->driFd; - int ret; - - ret = drmCommandNone( fd, DRM_MACH64_FLUSH ); - - if ( ret < 0 ) { - drmCommandNone( fd, DRM_MACH64_RESET ); - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "Error flushing DMA... exiting\n" ); - exit( -1 ); - } - - mmesa->dirty |= (MACH64_UPLOAD_CONTEXT | - MACH64_UPLOAD_MISC | - MACH64_UPLOAD_CLIPRECTS); - -} - -/* For client-side state emits - currently unused */ -void mach64UploadHwStateLocked( mach64ContextPtr mmesa ) -{ - drm_mach64_sarea_t *sarea = mmesa->sarea; - - drm_mach64_context_regs_t *regs = &sarea->context_state; - unsigned int dirty = sarea->dirty; - CARD32 offset = ((regs->tex_size_pitch & 0xf0) >> 2); - - DMALOCALS; - - DMAGETPTR( 19*2 ); - - if ( dirty & MACH64_UPLOAD_MISC ) { - DMAOUTREG( MACH64_DP_MIX, regs->dp_mix ); - DMAOUTREG( MACH64_DP_SRC, regs->dp_src ); - DMAOUTREG( MACH64_CLR_CMP_CNTL, regs->clr_cmp_cntl ); - DMAOUTREG( MACH64_GUI_TRAJ_CNTL, regs->gui_traj_cntl ); - DMAOUTREG( MACH64_SC_LEFT_RIGHT, regs->sc_left_right ); - DMAOUTREG( MACH64_SC_TOP_BOTTOM, regs->sc_top_bottom ); - sarea->dirty &= ~MACH64_UPLOAD_MISC; - } - - if ( dirty & MACH64_UPLOAD_DST_OFF_PITCH ) { - DMAOUTREG( MACH64_DST_OFF_PITCH, regs->dst_off_pitch ); - sarea->dirty &= ~MACH64_UPLOAD_DST_OFF_PITCH; - } - if ( dirty & MACH64_UPLOAD_Z_OFF_PITCH ) { - DMAOUTREG( MACH64_Z_OFF_PITCH, regs->z_off_pitch ); - sarea->dirty &= ~MACH64_UPLOAD_Z_OFF_PITCH; - } - if ( dirty & MACH64_UPLOAD_Z_ALPHA_CNTL ) { - DMAOUTREG( MACH64_Z_CNTL, regs->z_cntl ); - DMAOUTREG( MACH64_ALPHA_TST_CNTL, regs->alpha_tst_cntl ); - sarea->dirty &= ~MACH64_UPLOAD_Z_ALPHA_CNTL; - } - if ( dirty & MACH64_UPLOAD_SCALE_3D_CNTL ) { - DMAOUTREG( MACH64_SCALE_3D_CNTL, regs->scale_3d_cntl ); - sarea->dirty &= ~MACH64_UPLOAD_SCALE_3D_CNTL; - } - if ( dirty & MACH64_UPLOAD_DP_FOG_CLR ) { - DMAOUTREG( MACH64_DP_FOG_CLR, regs->dp_fog_clr ); - sarea->dirty &= ~MACH64_UPLOAD_DP_FOG_CLR; - } - if ( dirty & MACH64_UPLOAD_DP_WRITE_MASK ) { - DMAOUTREG( MACH64_DP_WRITE_MASK, regs->dp_write_mask ); - sarea->dirty &= ~MACH64_UPLOAD_DP_WRITE_MASK; - } - if ( dirty & MACH64_UPLOAD_DP_PIX_WIDTH ) { - DMAOUTREG( MACH64_DP_PIX_WIDTH, regs->dp_pix_width ); - sarea->dirty &= ~MACH64_UPLOAD_DP_PIX_WIDTH; - } - if ( dirty & MACH64_UPLOAD_SETUP_CNTL ) { - DMAOUTREG( MACH64_SETUP_CNTL, regs->setup_cntl ); - sarea->dirty &= ~MACH64_UPLOAD_SETUP_CNTL; - } - - if ( dirty & MACH64_UPLOAD_TEXTURE ) { - DMAOUTREG( MACH64_TEX_SIZE_PITCH, regs->tex_size_pitch ); - DMAOUTREG( MACH64_TEX_CNTL, regs->tex_cntl ); - DMAOUTREG( MACH64_SECONDARY_TEX_OFF, regs->secondary_tex_off ); - DMAOUTREG( MACH64_TEX_0_OFF + offset, regs->tex_offset ); - sarea->dirty &= ~MACH64_UPLOAD_TEXTURE; - } - -#if 0 - if ( dirty & MACH64_UPLOAD_CLIPRECTS ) { - DMAOUTREG( MACH64_SC_LEFT_RIGHT, regs->sc_left_right ); - DMAOUTREG( MACH64_SC_TOP_BOTTOM, regs->sc_top_bottom ); - sarea->dirty &= ~MACH64_UPLOAD_CLIPRECTS; - } -#endif - - sarea->dirty = 0; - - DMAADVANCE(); -} - -void mach64InitIoctlFuncs( struct dd_function_table *functions ) -{ - functions->Clear = mach64DDClear; -} diff --git a/src/mesa/drivers/dri/mach64/mach64_ioctl.h b/src/mesa/drivers/dri/mach64/mach64_ioctl.h deleted file mode 100644 index 9145ee6e6cf..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_ioctl.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#ifndef __MACH64_IOCTL_H__ -#define __MACH64_IOCTL_H__ - -#include <stdio.h> -#include <stdlib.h> - -#include "mach64_dri.h" -#include "mach64_reg.h" -#include "mach64_lock.h" - -#define MACH64_BUFFER_MAX_DWORDS (MACH64_BUFFER_SIZE / sizeof(CARD32)) - - -extern drmBufPtr mach64GetBufferLocked( mach64ContextPtr mmesa ); -extern void mach64FlushVerticesLocked( mach64ContextPtr mmesa ); -extern void mach64FlushDMALocked( mach64ContextPtr mmesa ); -extern void mach64UploadHwStateLocked( mach64ContextPtr mmesa ); - -static INLINE void *mach64AllocDmaLow( mach64ContextPtr mmesa, int bytes ) -{ - CARD32 *head; - - if ( mmesa->vert_used + bytes > mmesa->vert_total ) { - LOCK_HARDWARE( mmesa ); - mach64FlushVerticesLocked( mmesa ); - UNLOCK_HARDWARE( mmesa ); - } - - head = (CARD32 *)((char *)mmesa->vert_buf + mmesa->vert_used); - mmesa->vert_used += bytes; - - return head; -} - -static INLINE void *mach64AllocDmaLocked( mach64ContextPtr mmesa, int bytes ) -{ - CARD32 *head; - - if ( mmesa->vert_used + bytes > mmesa->vert_total ) { - mach64FlushVerticesLocked( mmesa ); - } - - head = (CARD32 *)((char *)mmesa->vert_buf + mmesa->vert_used); - mmesa->vert_used += bytes; - - return head; -} - -extern void mach64FireBlitLocked( mach64ContextPtr mmesa, void *buffer, - GLint offset, GLint pitch, GLint format, - GLint x, GLint y, GLint width, GLint height ); - -extern void mach64CopyBuffer( __DRIdrawable *dPriv ); -#if ENABLE_PERF_BOXES -extern void mach64PerformanceCounters( mach64ContextPtr mmesa ); -extern void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa ); -#endif -extern void mach64WaitForIdleLocked( mach64ContextPtr mmesa ); - -extern void mach64InitIoctlFuncs( struct dd_function_table *functions ); - -/* ================================================================ - * Helper macros: - */ - -#define FLUSH_BATCH( mmesa ) \ -do { \ - if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \ - fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \ - if ( mmesa->vert_used ) { \ - mach64FlushVertices( mmesa ); \ - } \ -} while (0) - -/* According to a comment in ATIMach64Sync (atimach64.c) in the DDX: - * - * "For VTB's and later, the first CPU read of the framebuffer will return - * zeroes [...] This appears to be due to some kind of engine - * caching of framebuffer data I haven't found any way of disabling, or - * otherwise circumventing." - */ -#define FINISH_DMA_LOCKED( mmesa ) \ -do { \ - CARD32 _tmp; \ - if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \ - fprintf( stderr, "FINISH_DMA_LOCKED in %s\n", __FUNCTION__ ); \ - if ( mmesa->vert_used ) { \ - mach64FlushVerticesLocked( mmesa ); \ - } \ - mach64WaitForIdleLocked( mmesa ); \ - /* pre-read framebuffer to counter caching problem */ \ - _tmp = *(volatile CARD32 *)mmesa->driScreen->pFB; \ -} while (0) - -#define FLUSH_DMA_LOCKED( mmesa ) \ -do { \ - if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \ - fprintf( stderr, "FLUSH_DMA_LOCKED in %s\n", __FUNCTION__ ); \ - if ( mmesa->vert_used ) { \ - mach64FlushVerticesLocked( mmesa ); \ - } \ - mach64FlushDMALocked( mmesa ); \ -} while (0) - -#define mach64FlushVertices( mmesa ) \ -do { \ - LOCK_HARDWARE( mmesa ); \ - mach64FlushVerticesLocked( mmesa ); \ - UNLOCK_HARDWARE( mmesa ); \ -} while (0) - -#define mach64WaitForIdle( mmesa ) \ -do { \ - LOCK_HARDWARE( mmesa ); \ - mach64WaitForIdleLocked( mmesa ); \ - UNLOCK_HARDWARE( mmesa ); \ -} while (0) - - -#endif /* __MACH64_IOCTL_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_lock.c b/src/mesa/drivers/dri/mach64/mach64_lock.c deleted file mode 100644 index 1a95a8f619d..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_lock.c +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#include "mach64_context.h" -#include "mach64_state.h" -#include "mach64_lock.h" -#include "drirenderbuffer.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 mach64GetLock( mach64ContextPtr mmesa, GLuint flags ) -{ - __DRIdrawable *dPriv = mmesa->driDrawable; - __DRIscreen *sPriv = mmesa->driScreen; - drm_mach64_sarea_t *sarea = mmesa->sarea; - int i; - - drmGetLock( mmesa->driFd, mmesa->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( sPriv, dPriv ); - - if ( mmesa->lastStamp != dPriv->lastStamp ) { - mmesa->lastStamp = dPriv->lastStamp; - if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) - mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT ); - else - mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT ); - driUpdateFramebufferSize( mmesa->glCtx, dPriv ); - mach64CalcViewport( mmesa->glCtx ); - } - - mmesa->dirty |= (MACH64_UPLOAD_CONTEXT - | MACH64_UPLOAD_MISC - | MACH64_UPLOAD_CLIPRECTS); - - /* EXA render acceleration uses the texture engine, so restore it */ - mmesa->dirty |= (MACH64_UPLOAD_TEXTURE); - - if ( sarea->ctx_owner != mmesa->hHWContext ) { - sarea->ctx_owner = mmesa->hHWContext; - mmesa->dirty = MACH64_UPLOAD_ALL; - } - - for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) { - DRI_AGE_TEXTURES( mmesa->texture_heaps[i] ); - } -} diff --git a/src/mesa/drivers/dri/mach64/mach64_lock.h b/src/mesa/drivers/dri/mach64/mach64_lock.h deleted file mode 100644 index 3130b183e33..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_lock.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * - */ - -#ifndef __MACH64_LOCK_H__ -#define __MACH64_LOCK_H__ - -extern void mach64GetLock( mach64ContextPtr mmesa, GLuint flags ); - - -/* Turn DEBUG_LOCKING on to find locking conflicts. - */ -#define DEBUG_LOCKING 1 - -#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( mmesa ) \ - do { \ - char __ret = 0; \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( mmesa->driHwLock, mmesa->hHWContext, \ - (DRM_LOCK_HELD | mmesa->hHWContext), __ret ); \ - if ( __ret ) \ - mach64GetLock( mmesa, 0 ); \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware. - */ -#define UNLOCK_HARDWARE( mmesa ) \ - do { \ - DRM_UNLOCK( mmesa->driFd, \ - mmesa->driHwLock, \ - mmesa->hHWContext ); \ - DEBUG_RESET(); \ - } while (0) - -#endif /* __MACH64_LOCK_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vb.c b/src/mesa/drivers/dri/mach64/mach64_native_vb.c deleted file mode 100644 index d8426ddee1c..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_native_vb.c +++ /dev/null @@ -1,257 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Original authors: - * Keith Whitwell <[email protected]> - * - * Adapted to Mach64 by: - * Jos� Fonseca <[email protected]> - */ - -#include "math/m_translate.h" - -#ifndef LOCALVARS -#define LOCALVARS -#endif - -void TAG(translate_vertex)(struct gl_context *ctx, - const VERTEX *src, - SWvertex *dst) -{ - LOCALVARS - GLuint format = GET_VERTEX_FORMAT(); - UNVIEWPORT_VARS; - CARD32 *p = (CARD32 *)src + 10 - mmesa->vertex_size; - - dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0; - - switch ( format ) { - case TEX1_VERTEX_FORMAT: -#ifdef MACH64_PREMULT_TEXCOORDS - { - float rhw = 1.0 / LE32_IN_FLOAT( p + 2 ); - - dst->attrib[FRAG_ATTRIB_TEX1][0] = rhw*LE32_IN_FLOAT( p++ ); - dst->attrib[FRAG_ATTRIB_TEX1][1] = rhw*LE32_IN_FLOAT( p++ ); - } -#else - dst->attrib[FRAG_ATTRIB_TEX1][0] = LE32_IN_FLOAT( p++ ); - dst->attrib[FRAG_ATTRIB_TEX1][1] = LE32_IN_FLOAT( p++ ); -#endif - dst->attrib[FRAG_ATTRIB_TEX1][3] = 1.0; - p++; - - case TEX0_VERTEX_FORMAT: -#ifdef MACH64_PREMULT_TEXCOORDS - { - float rhw = 1.0 / LE32_IN_FLOAT( p + 2 ); - - dst->attrib[FRAG_ATTRIB_TEX0][0] = rhw*LE32_IN_FLOAT( p++ ); - dst->attrib[FRAG_ATTRIB_TEX0][1] = rhw*LE32_IN_FLOAT( p++ ); - } -#else - dst->attrib[FRAG_ATTRIB_TEX0][0] = LE32_IN_FLOAT( p++ ); - dst->attrib[FRAG_ATTRIB_TEX0][1] = LE32_IN_FLOAT( p++ ); -#endif - dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0; - dst->attrib[FRAG_ATTRIB_WPOS][3] = LE32_IN_FLOAT( p++ ); - - case NOTEX_VERTEX_FORMAT: - dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(((GLubyte *)p)[0]); - dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(((GLubyte *)p)[1]); - dst->attrib[FRAG_ATTRIB_COL1][0] = UBYTE_TO_FLOAT(((GLubyte *)p)[2]); - dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3]; /*XXX int->float?*/ - p++; - - case TINY_VERTEX_FORMAT: - dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( LE32_IN( p++ ) ); - - dst->color[2] = ((GLubyte *)p)[0]; - dst->color[1] = ((GLubyte *)p)[1]; - dst->color[0] = ((GLubyte *)p)[2]; - dst->color[3] = ((GLubyte *)p)[3]; - p++; - - { - GLuint xy = LE32_IN( p ); - - dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) ); - dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) ); - } - } - - assert( p + 1 - (CARD32 *)src == 10 ); - - dst->pointSize = ctx->Point.Size; -} - - - -void TAG(print_vertex)( struct gl_context *ctx, const VERTEX *v ) -{ - LOCALVARS - GLuint format = GET_VERTEX_FORMAT(); - CARD32 *p = (CARD32 *)v + 10 - mmesa->vertex_size; - - switch ( format ) { - case TEX1_VERTEX_FORMAT: - { - GLfloat u, v, w; -#ifdef MACH64_PREMULT_TEXCOORDS - float rhw = 1.0 / LE32_IN_FLOAT( p + 2 ); - - u = rhw*LE32_IN_FLOAT( p++ ); - v = rhw*LE32_IN_FLOAT( p++ ); -#else - u = LE32_IN_FLOAT( p++ ); - v = LE32_IN_FLOAT( p++ ); -#endif - w = LE32_IN_FLOAT( p++ ); - fprintf( stderr, "u1 %f v1 %f w1 %f\n", u, v, w ); - } - - case TEX0_VERTEX_FORMAT: - { - GLfloat u, v, w; -#ifdef MACH64_PREMULT_TEXCOORDS - float rhw = 1.0 / LE32_IN_FLOAT( p + 2 ); - - u = rhw*LE32_IN_FLOAT( p++ ); - v = rhw*LE32_IN_FLOAT( p++ ); -#else - u = LE32_IN_FLOAT( p++ ); - v = LE32_IN_FLOAT( p++ ); -#endif - w = LE32_IN_FLOAT( p++ ); - fprintf( stderr, "u0 %f v0 %f w0 %f\n", u, v, w ); - } - - case NOTEX_VERTEX_FORMAT: - { - GLubyte r, g, b, a; - - b = ((GLubyte *)p)[0]; - g = ((GLubyte *)p)[1]; - r = ((GLubyte *)p)[2]; - a = ((GLubyte *)p)[3]; - p++; - fprintf(stderr, "spec: r %d g %d b %d a %d\n", r, g, b, a); - } - - case TINY_VERTEX_FORMAT: - { - GLuint xy; - GLfloat x, y, z; - GLubyte r, g, b, a; - - z = LE32_IN( p++ ) / 65536.0; - - b = ((GLubyte *)p)[0]; - g = ((GLubyte *)p)[1]; - r = ((GLubyte *)p)[2]; - a = ((GLubyte *)p)[3]; - p++; - xy = LE32_IN( p ); - x = (GLfloat)(GLshort)( xy >> 16 ) / 4.0; - y = (GLfloat)(GLshort)( xy & 0xffff ) / 4.0; - - fprintf(stderr, "x %f y %f z %f\n", x, y, z); - fprintf(stderr, "r %d g %d b %d a %d\n", r, g, b, a); - } - } - - assert( p + 1 - (CARD32 *)v == 10 ); - - fprintf(stderr, "\n"); -} - -/* Interpolate the elements of the VB not included in typical hardware - * vertices. - * - * NOTE: All these arrays are guarenteed by tnl to be writeable and - * have good stride. - */ -#ifndef INTERP_QUALIFIER -#define INTERP_QUALIFIER static -#endif - -#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) - - -INTERP_QUALIFIER void TAG(interp_extras)( struct gl_context *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->BackfaceColorPtr) { - assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat)); - - INTERP_4F( t, - GET_COLOR(VB->BackfaceColorPtr, dst), - GET_COLOR(VB->BackfaceColorPtr, out), - GET_COLOR(VB->BackfaceColorPtr, in) ); - - if (VB->BackfaceSecondaryColorPtr) { - INTERP_3F( t, - GET_COLOR(VB->BackfaceSecondaryColorPtr, dst), - GET_COLOR(VB->BackfaceSecondaryColorPtr, out), - GET_COLOR(VB->BackfaceSecondaryColorPtr, in) ); - } - } - - if (VB->EdgeFlag) { - VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; - } - - INTERP_VERTEX(ctx, t, dst, out, in, force_boundary); -} - -INTERP_QUALIFIER void TAG(copy_pv_extras)( struct gl_context *ctx, - GLuint dst, GLuint src ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->BackfaceColorPtr) { - COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst), - GET_COLOR(VB->BackfaceColorPtr, src) ); - - if (VB->BackfaceSecondaryColorPtr) { - COPY_4FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst), - GET_COLOR(VB->BackfaceSecondaryColorPtr, src) ); - } - } - - COPY_PV_VERTEX(ctx, dst, src); -} - - -#undef INTERP_QUALIFIER -#undef GET_COLOR - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h b/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h deleted file mode 100644 index 8345f5cdbcc..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h +++ /dev/null @@ -1,562 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Original authors: - * Keith Whitwell <[email protected]> - * - * Adapted to Mach64 by: - * Jos� Fonseca <[email protected]> - */ - - -/* DO_XYZW: Emit xyz and maybe w coordinates. - * DO_RGBA: Emit color. - * DO_SPEC: Emit specular color. - * DO_FOG: Emit fog coordinate in specular alpha. - * DO_TEX0: Emit tex0 u,v coordinates. - * DO_TEX1: Emit tex1 u,v coordinates. - * DO_PTEX: Emit tex0,1 q coordinates where possible. - * - * Additionally, this template assumes it is emitting *transformed* - * vertices; the modifications to emit untransformed vertices (ie. to - * t&l hardware) are probably too great to cooexist with the code - * already in this file. - */ - -#define VIEWPORT_X(x) ((GLint) ((s[0] * (x) + s[12]) * 4.0)) -#define VIEWPORT_Y(y) ((GLint) ((s[5] * (y) + s[13]) * 4.0)) -#define VIEWPORT_Z(z) (((GLuint) (s[10] * (z) + s[14])) << 15) - -#ifndef LOCALVARS -#define LOCALVARS -#endif - -static void TAG(emit)( struct gl_context *ctx, - GLuint start, GLuint end, - void *dest, - GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; -#if DO_TEX1 - GLfloat (*tc1)[4]; - GLuint tc1_stride; -#if DO_PTEX - GLuint tc1_size; -#endif -#endif -#if DO_TEX0 - GLfloat (*tc0)[4]; - GLuint tc0_stride; -#if DO_PTEX - GLuint tc0_size; -#endif -#endif -#if DO_SPEC - GLfloat (*spec)[4]; - GLuint spec_stride; -#endif -#if DO_FOG - GLfloat (*fog)[4]; - GLuint fog_stride; -#endif -#if DO_RGBA - GLfloat (*col)[4]; - GLuint col_stride; -#endif - GLfloat (*coord)[4]; - GLuint coord_stride; - VERTEX *v = (VERTEX *)dest; - const GLfloat *s = GET_VIEWPORT_MAT(); -#if DO_TEX1 || DO_TEX0 || DO_XYZW - const GLubyte *mask = VB->ClipMask; -#endif - int i; - -#if !DO_XYZW - (void) s; /* Quiet compiler */ -#endif -/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */ -/* __FUNCTION__, VB->importable_data, start, end); */ - -#if DO_TEX1 - { - const GLuint t1 = GET_TEXSOURCE(1); - tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->data; - tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->stride; -#if DO_PTEX - tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size; -#endif - } -#endif - -#if DO_TEX0 - { - const GLuint t0 = GET_TEXSOURCE(0); - tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->data; - tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->stride; -#if DO_PTEX - tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size; -#endif - } -#endif - -#if DO_SPEC - if (VB->AttribPtr[_TNL_ATTRIB_COLOR1]) { - spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data; - spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride; - } else { - spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - spec_stride = 0; - } -#endif - -#if DO_FOG - if (VB->AttribPtr[_TNL_ATTRIB_FOG]) { - fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data; - fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride; - } else { - static GLfloat tmp[4] = {0, 0, 0, 0}; - fog = &tmp; - fog_stride = 0; - } -#endif - -#if DO_RGBA - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; -#endif - - coord = VB->NdcPtr->data; - coord_stride = VB->NdcPtr->stride; - - if (start) { -#if DO_TEX1 - STRIDE_4F(tc1, start * tc1_stride); -#endif -#if DO_TEX0 - STRIDE_4F(tc0, start * tc0_stride); -#endif -#if DO_SPEC - STRIDE_4F(spec, start * spec_stride); -#endif -#if DO_FOG - STRIDE_4F(fog, start * fog_stride); -#endif -#if DO_RGBA - STRIDE_4F(col, start * col_stride); -#endif - STRIDE_4F(coord, start * coord_stride); - } - - for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) { - CARD32 *p = (CARD32 *)v; -#if DO_TEX1 || DO_TEX0 - GLfloat w; - - if (mask[i] == 0) { - /* unclipped */ - w = coord[0][3]; - } else { - /* clipped */ - w = 1.0; - } -#endif - -#if DO_TEX1 -#if DO_PTEX - if (tc1_size == 4) { -#ifdef MACH64_PREMULT_TEXCOORDS - LE32_OUT_FLOAT( p++, w*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */ - LE32_OUT_FLOAT( p++, w*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */ - LE32_OUT_FLOAT( p++, w*tc1[0][3] ); /* VERTEX_?_SECONDARY_W */ -#else /* !MACH64_PREMULT_TEXCOORDS */ - float rhw = 1.0 / tc1[0][3]; - LE32_OUT_FLOAT( p++, rhw*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */ - LE32_OUT_FLOAT( p++, rhw*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */ - LE32_OUT_FLOAT( p++, w*tc1[0][3] ); /* VERTEX_?_SECONDARY_W */ -#endif /* !MACH64_PREMULT_TEXCOORDS */ - } else { -#endif /* DO_PTEX */ -#ifdef MACH64_PREMULT_TEXCOORDS - LE32_OUT_FLOAT( p++, w*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */ - LE32_OUT_FLOAT( p++, w*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */ - LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_SECONDARY_W */ -#else /* !MACH64_PREMULT_TEXCOORDS */ - LE32_OUT_FLOAT( p++, tc1[0][0] ); /* VERTEX_?_SECONDARY_S */ - LE32_OUT_FLOAT( p++, tc1[0][1] ); /* VERTEX_?_SECONDARY_T */ - LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_SECONDARY_W */ -#endif /* !MACH64_PREMULT_TEXCOORDS */ -#if DO_PTEX - } -#endif /* DO_PTEX */ - STRIDE_4F(tc1, tc1_stride); -#else /* !DO_TEX1 */ - p += 3; -#endif /* !DO_TEX1 */ - -#if DO_TEX0 -#if DO_PTEX - if (tc0_size == 4) { -#ifdef MACH64_PREMULT_TEXCOORDS - LE32_OUT_FLOAT( p++, w*tc0[0][0] ); /* VERTEX_?_S */ - LE32_OUT_FLOAT( p++, w*tc0[0][1] ); /* VERTEX_?_T */ - LE32_OUT_FLOAT( p++, w*tc0[0][3] ); /* VERTEX_?_W */ -#else /* !MACH64_PREMULT_TEXCOORDS */ - float rhw = 1.0 / tc0[0][3]; - LE32_OUT_FLOAT( p++, rhw*tc0[0][0] ); /* VERTEX_?_S */ - LE32_OUT_FLOAT( p++, rhw*tc0[0][1] ); /* VERTEX_?_T */ - LE32_OUT_FLOAT( p++, w*tc0[0][3] ); /* VERTEX_?_W */ -#endif /* !MACH64_PREMULT_TEXCOORDS */ - } else { -#endif /* DO_PTEX */ -#ifdef MACH64_PREMULT_TEXCOORDS - LE32_OUT_FLOAT( p++, w*tc0[0][0] ); /* VERTEX_?_S */ - LE32_OUT_FLOAT( p++, w*tc0[0][1] ); /* VERTEX_?_T */ - LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_W */ -#else /* !MACH64_PREMULT_TEXCOORDS */ - LE32_OUT_FLOAT( p++, tc0[0][0] ); /* VERTEX_?_S */ - LE32_OUT_FLOAT( p++, tc0[0][1] ); /* VERTEX_?_T */ - LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_W */ -#endif /* !MACH64_PREMULT_TEXCOORDS */ -#if DO_PTEX - } -#endif /* DO_PTEX */ - STRIDE_4F(tc0, tc0_stride); -#else /* !DO_TEX0 */ - p += 3; -#endif /* !DO_TEX0 */ - -#if DO_SPEC - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[0], spec[0][2]); /* VERTEX_?_SPEC_B */ - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[1], spec[0][1]); /* VERTEX_?_SPEC_G */ - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[2], spec[0][0]); /* VERTEX_?_SPEC_R */ - - STRIDE_4F(spec, spec_stride); -#endif -#if DO_FOG - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[3], fog[0][0]); /* VERTEX_?_SPEC_A */ - /* ((GLubyte *)p)[3] = fog[0][0] * 255.0; */ - STRIDE_4F(fog, fog_stride); -#endif - p++; - -#if DO_XYZW - if (mask[i] == 0) { - /* unclipped */ - LE32_OUT( p++, VIEWPORT_Z( coord[0][2] ) ); /* VERTEX_?_Z */ - } else { -#endif - p++; -#if DO_XYZW - } -#endif - -#if DO_RGBA - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[0], col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[1], col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[2], col[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[3], col[0][3]); - p++; - STRIDE_4F(col, col_stride); -#else - p++; -#endif - -#if DO_XYZW - if (mask[i] == 0) { - /* unclipped */ - LE32_OUT( p, - (VIEWPORT_X( coord[0][0] ) << 16) | /* VERTEX_?_X */ - (VIEWPORT_Y( coord[0][1] ) & 0xffff) ); /* VERTEX_?_Y */ - - if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) { - fprintf( stderr, "%s: vert %d: %.2f %.2f %.2f %x\n", - __FUNCTION__, - i, - (LE32_IN( p ) >> 16)/4.0, - (LE32_IN( p ) & 0xffff)/4.0, - LE32_IN( p - 2 )/65536.0, - *(GLuint *)(p - 1) ); - } - } -#endif -#if DO_TEX1 || DO_TEX0 || DO_XYZW - STRIDE_4F(coord, coord_stride); -#endif - - assert( p + 1 - (CARD32 *)v == 10 ); - } -} - -#if DO_XYZW && DO_RGBA - -static GLboolean TAG(check_tex_sizes)( struct gl_context *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* Force 'missing' texcoords to something valid. - */ - if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1]; - - if (DO_PTEX) - return GL_TRUE; - - /* No hardware support for projective texture. Can fake it for - * TEX0 only. - */ - if ((DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4)) { - PTEX_FALLBACK(); - return GL_FALSE; - } - - if (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4) { - if (DO_TEX1) { - PTEX_FALLBACK(); - } - return GL_FALSE; - } - - return GL_TRUE; -} - - -static void TAG(interp)( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte *ddverts = GET_VERTEX_STORE(); - GLuint size = GET_VERTEX_SIZE(); - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - GLfloat w; - const GLfloat *s = GET_VIEWPORT_MAT(); - - CARD32 *dst = (CARD32 *)(ddverts + (edst * size)); - CARD32 *in = (CARD32 *)(ddverts + (ein * size)); - CARD32 *out = (CARD32 *)(ddverts + (eout * size)); - - (void)s; - - w = (dstclip[3] == 0.0F) ? 1.0 : (1.0 / dstclip[3]); - -#if DO_TEX1 - { - GLfloat temp; -#if DO_PTEX - GLfloat wout = VB->NdcPtr->data[eout][3]; - GLfloat win = VB->NdcPtr->data[ein][3]; - GLfloat qout = LE32_IN_FLOAT( out + 2 ) / wout; - GLfloat qin = LE32_IN_FLOAT( in + 2 ) / win; - GLfloat qdst, rqdst; - - INTERP_F( t, qdst, qout, qin ); - rqdst = 1.0 / qdst; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_SECONDARY_S */ - dst++; out++; in++; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_SECONDARY_T */ - dst++; out++; in++; - - LE32_OUT_FLOAT( dst, w*rqdst ); /* VERTEX_?_SECONDARY_W */ - dst++; out++; in++; -#else /* !DO_PTEX */ -#ifdef MACH64_PREMULT_TEXCOORDS - GLfloat qout = w / LE32_IN_FLOAT( out + 2 ); - GLfloat qin = w / LE32_IN_FLOAT( in + 2 ); - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_S */ - dst++; out++; in++; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_T */ - dst++; out++; in++; -#else /* !MACH64_PREMULT_TEXCOORDS */ - INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_S */ - dst++; out++; in++; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_T */ - dst++; out++; in++; -#endif /* !MACH64_PREMULT_TEXCOORDS */ - LE32_OUT_FLOAT( dst, w ); /* VERTEX_?_SECONDARY_W */ - dst++; out++; in++; -#endif /* !DO_PTEX */ - } -#else /* !DO_TEX1 */ - dst += 3; out += 3; in += 3; -#endif /* !DO_TEX1 */ - -#if DO_TEX0 - { - GLfloat temp; -#if DO_PTEX - GLfloat wout = VB->NdcPtr->data[eout][3]; - GLfloat win = VB->NdcPtr->data[ein][3]; - GLfloat qout = LE32_IN_FLOAT( out + 2 ) / wout; - GLfloat qin = LE32_IN_FLOAT( in + 2 ) / win; - GLfloat qdst, rqdst; - - INTERP_F( t, qdst, qout, qin ); - rqdst = 1.0 / qdst; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_S */ - dst++; out++; in++; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_T */ - dst++; out++; in++; - - LE32_OUT_FLOAT( dst, w*rqdst ); /* VERTEX_?_W */ - dst++; out++; in++; -#else /* !DO_PTEX */ -#ifdef MACH64_PREMULT_TEXCOORDS - GLfloat qout = w / LE32_IN_FLOAT( out + 2 ); - GLfloat qin = w / LE32_IN_FLOAT( in + 2 ); - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_S */ - dst++; out++; in++; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_T */ - dst++; out++; in++; -#else /* !MACH64_PREMULT_TEXCOORDS */ - INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_S */ - dst++; out++; in++; - - INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) ); - LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_T */ - dst++; out++; in++; -#endif /* !MACH64_PREMULT_TEXCOORDS */ - LE32_OUT_FLOAT( dst, w ); /* VERTEX_?_W */ - dst++; out++; in++; -#endif /* !DO_PTEX */ - } -#else /* !DO_TEX0 */ - dst += 3; out += 3; in += 3; -#endif /* !DO_TEX0 */ - -#if DO_SPEC - INTERP_UB( t, ((GLubyte *)dst)[0], ((GLubyte *)out)[0], ((GLubyte *)in)[0] ); /* VERTEX_?_SPEC_B */ - INTERP_UB( t, ((GLubyte *)dst)[1], ((GLubyte *)out)[1], ((GLubyte *)in)[1] ); /* VERTEX_?_SPEC_G */ - INTERP_UB( t, ((GLubyte *)dst)[2], ((GLubyte *)out)[2], ((GLubyte *)in)[2] ); /* VERTEX_?_SPEC_R */ -#endif - -#if DO_FOG - INTERP_UB( t, ((GLubyte *)dst)[3], ((GLubyte *)out)[3], ((GLubyte *)in)[3] ); /* VERTEX_?_SPEC_A */ -#endif /* DO_FOG */ - - dst++; out++; in++; - - LE32_OUT( dst, VIEWPORT_Z( dstclip[2] * w ) ); /* VERTEX_?_Z */ - dst++; out++; in++; - - INTERP_UB( t, ((GLubyte *)dst)[0], ((GLubyte *)out)[0], ((GLubyte *)in)[0] ); /* VERTEX_?_B */ - INTERP_UB( t, ((GLubyte *)dst)[1], ((GLubyte *)out)[1], ((GLubyte *)in)[1] ); /* VERTEX_?_G */ - INTERP_UB( t, ((GLubyte *)dst)[2], ((GLubyte *)out)[2], ((GLubyte *)in)[2] ); /* VERTEX_?_R */ - INTERP_UB( t, ((GLubyte *)dst)[3], ((GLubyte *)out)[3], ((GLubyte *)in)[3] ); /* VERTEX_?_A */ - dst++; /*out++; in++;*/ - - LE32_OUT( dst, - (VIEWPORT_X( dstclip[0] * w ) << 16) | /* VERTEX_?_X */ - (VIEWPORT_Y( dstclip[1] * w ) & 0xffff) ); /* VERTEX_?_Y */ - - assert( dst + 1 - (CARD32 *)(ddverts + (edst * size)) == 10 ); - assert( in + 2 - (CARD32 *)(ddverts + (ein * size)) == 10 ); - assert( out + 2 - (CARD32 *)(ddverts + (eout * size)) == 10 ); - - if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) { - fprintf( stderr, "%s: dst vert: %.2f %.2f %.2f %x\n", - __FUNCTION__, - (GLshort)(LE32_IN( dst ) >> 16)/4.0, - (GLshort)(LE32_IN( dst ) & 0xffff)/4.0, - LE32_IN( dst - 2 )/65536.0, - *(GLuint *)(dst - 1) ); - } -} - -#endif /* DO_RGBA && DO_XYZW */ - - -static void TAG(copy_pv)( struct gl_context *ctx, GLuint edst, GLuint esrc ) -{ -#if DO_SPEC || DO_FOG || DO_RGBA - LOCALVARS - GLubyte *verts = GET_VERTEX_STORE(); - GLuint size = GET_VERTEX_SIZE(); - GLuint *dst = (GLuint *)(verts + (edst * size)); - GLuint *src = (GLuint *)(verts + (esrc * size)); -#endif - -#if DO_SPEC || DO_FOG - dst[6] = src[6]; /* VERTEX_?_SPEC_ARGB */ -#endif - -#if DO_RGBA - dst[8] = src[8]; /* VERTEX_?_ARGB */ -#endif -} - -static void TAG(init)( void ) -{ - setup_tab[IND].emit = TAG(emit); - -#if DO_XYZW && DO_RGBA - setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); - setup_tab[IND].interp = TAG(interp); -#endif - - setup_tab[IND].copy_pv = TAG(copy_pv); - -#if DO_TEX1 - setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 10; -#elif DO_TEX0 - setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 7; -#elif DO_SPEC || DO_FOG - setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 4; -#else - setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 3; -#endif - -} - - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/mach64/mach64_reg.h b/src/mesa/drivers/dri/mach64/mach64_reg.h deleted file mode 100644 index cb944e10230..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_reg.h +++ /dev/null @@ -1,406 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#ifndef __MACH64_REG_H__ -#define __MACH64_REG_H__ - -/* - * Not sure how this compares with the G200, but the Rage Pro has two - * banks of registers, with bank 0 at (aperture base + memmap offset - 1KB) - * and bank 1 at (aperture base + memmap offset - 2KB). But, to send them - * via DMA, we need to encode them as memory map select rather than physical - * offsets. - */ -#define DWMREG0 0x0400 -#define DWMREG0_END 0x07ff -#define DWMREG1 0x0000 -#define DWMREG1_END 0x03ff - -#define ISREG0(r) ( ( (r) >= DWMREG0 ) && ( (r) <= DWMREG0_END ) ) -#define ADRINDEX0(r) ( ((r) - DWMREG0) >> 2 ) -#define ADRINDEX1(r) ( ( ((r) - DWMREG1) >> 2 ) | 0x0100 ) -#define ADRINDEX(r) ( ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r) ) - -#define MMREG0 0x0000 -#define MMREG0_END 0x00ff - -#define ISMMREG0(r) ( ( (r) >= MMREG0 ) && ( (r) <= MMREG0_END ) ) -#define MMSELECT0(r) ( ((r)<<2) + DWMREG0 ) -#define MMSELECT1(r) ( ( (((r) & 0xff)<<2) + DWMREG1 ) ) -#define MMSELECT(r) ( ISMMREG0(r) ? MMSELECT0(r) : MMSELECT1(r) ) - -/* FIXME: If register reads are necessary, we should account for endianess here */ -#define MACH64_BASE(reg) ((CARD32)(mmesa->mach64Screen->mmio.map)) -#define MACH64_ADDR(reg) (MACH64_BASE(reg) + reg) - -#define MACH64_DEREF(reg) *(__volatile__ CARD32 *)MACH64_ADDR(reg) -#define MACH64_READ(reg) MACH64_DEREF(reg) - - -/* ================================================================ - * Registers - */ - -#define MACH64_ALPHA_TST_CNTL 0x0550 -# define MACH64_ALPHA_TEST_EN (1 << 0) -# define MACH64_ALPHA_TEST_MASK (7 << 4) -# define MACH64_ALPHA_TEST_NEVER (0 << 4) -# define MACH64_ALPHA_TEST_LESS (1 << 4) -# define MACH64_ALPHA_TEST_LEQUAL (2 << 4) -# define MACH64_ALPHA_TEST_EQUAL (3 << 4) -# define MACH64_ALPHA_TEST_GEQUAL (4 << 4) -# define MACH64_ALPHA_TEST_GREATER (5 << 4) -# define MACH64_ALPHA_TEST_NOTEQUAL (6 << 4) -# define MACH64_ALPHA_TEST_ALWAYS (7 << 4) -# define MACH64_ALPHA_MOD_MSB (1 << 7) -# define MACH64_ALPHA_DST_MASK (7 << 8) -# define MACH64_ALPHA_DST_ZERO (0 << 8) -# define MACH64_ALPHA_DST_ONE (1 << 8) -# define MACH64_ALPHA_DST_SRCALPHA (4 << 8) -# define MACH64_ALPHA_DST_INVSRCALPHA (5 << 8) -# define MACH64_ALPHA_DST_DSTALPHA (6 << 8) -# define MACH64_ALPHA_DST_INVDSTALPHA (7 << 8) -# define MACH64_ALPHA_TST_SRC_TEXEL (0 << 12) -# define MACH64_ALPHA_TST_SRC_SRCALPHA (1 << 12) -# define MACH64_REF_ALPHA_MASK (0xff << 16) -# define MACH64_REF_ALPHA_SHIFT 16 -# define MACH64_COMPOSITE_SHADOW (1 << 30) -# define MACH64_SPECULAR_LIGHT_EN (1 << 31) - -#define MACH64_BUS_CNTL 0x04a0 -# define MACH64_BUS_MSTR_RESET (1 << 1) -# define MACH64_BUS_FLUSH_BUF (1 << 2) -# define MACH64_BUS_MASTER_DIS (1 << 6) -# define MACH64_BUS_EXT_REG_EN (1 << 27) - -#define MACH64_COMPOSITE_SHADOW_ID 0x0798 - -#define MACH64_CLR_CMP_CLR 0x0700 -#define MACH64_CLR_CMP_CNTL 0x0708 -#define MACH64_CLR_CMP_MASK 0x0704 - -#define MACH64_DP_BKGD_CLR 0x06c0 -#define MACH64_DP_FOG_CLR 0x06c4 -#define MACH64_DP_FGRD_BKGD_CLR 0x06e0 -#define MACH64_DP_FRGD_CLR 0x06c4 -#define MACH64_DP_FGRD_CLR_MIX 0x06dc - -#define MACH64_DP_MIX 0x06d4 -# define BKGD_MIX_NOT_D (0 << 0) -# define BKGD_MIX_ZERO (1 << 0) -# define BKGD_MIX_ONE (2 << 0) -# define MACH64_BKGD_MIX_D (3 << 0) -# define BKGD_MIX_NOT_S (4 << 0) -# define BKGD_MIX_D_XOR_S (5 << 0) -# define BKGD_MIX_NOT_D_XOR_S (6 << 0) -# define MACH64_BKGD_MIX_S (7 << 0) -# define BKGD_MIX_NOT_D_OR_NOT_S (8 << 0) -# define BKGD_MIX_D_OR_NOT_S (9 << 0) -# define BKGD_MIX_NOT_D_OR_S (10 << 0) -# define BKGD_MIX_D_OR_S (11 << 0) -# define BKGD_MIX_D_AND_S (12 << 0) -# define BKGD_MIX_NOT_D_AND_S (13 << 0) -# define BKGD_MIX_D_AND_NOT_S (14 << 0) -# define BKGD_MIX_NOT_D_AND_NOT_S (15 << 0) -# define BKGD_MIX_D_PLUS_S_DIV2 (23 << 0) -# define FRGD_MIX_NOT_D (0 << 16) -# define FRGD_MIX_ZERO (1 << 16) -# define FRGD_MIX_ONE (2 << 16) -# define FRGD_MIX_D (3 << 16) -# define FRGD_MIX_NOT_S (4 << 16) -# define FRGD_MIX_D_XOR_S (5 << 16) -# define FRGD_MIX_NOT_D_XOR_S (6 << 16) -# define MACH64_FRGD_MIX_S (7 << 16) -# define FRGD_MIX_NOT_D_OR_NOT_S (8 << 16) -# define FRGD_MIX_D_OR_NOT_S (9 << 16) -# define FRGD_MIX_NOT_D_OR_S (10 << 16) -# define FRGD_MIX_D_OR_S (11 << 16) -# define FRGD_MIX_D_AND_S (12 << 16) -# define FRGD_MIX_NOT_D_AND_S (13 << 16) -# define FRGD_MIX_D_AND_NOT_S (14 << 16) -# define FRGD_MIX_NOT_D_AND_NOT_S (15 << 16) -# define FRGD_MIX_D_PLUS_S_DIV2 (23 << 16) - -#define MACH64_DP_PIX_WIDTH 0x06d0 -# define MACH64_COMPOSITE_PIX_WIDTH_MASK (0xf << 4) -# define MACH64_HOST_TRIPLE_ENABLE (1 << 13) -# define MACH64_BYTE_ORDER_MSB_TO_LSB (0 << 24) -# define MACH64_BYTE_ORDER_LSB_TO_MSB (1 << 24) -# define MACH64_SCALE_PIX_WIDTH_MASK (0xf << 28) - -#define MACH64_DP_SRC 0x06d8 -# define MACH64_BKGD_SRC_BKGD_CLR (0 << 0) -# define MACH64_BKGD_SRC_FRGD_CLR (1 << 0) -# define MACH64_BKGD_SRC_HOST (2 << 0) -# define MACH64_BKGD_SRC_BLIT (3 << 0) -# define MACH64_BKGD_SRC_PATTERN (4 << 0) -# define MACH64_BKGD_SRC_3D (5 << 0) -# define MACH64_FRGD_SRC_BKGD_CLR (0 << 8) -# define MACH64_FRGD_SRC_FRGD_CLR (1 << 8) -# define MACH64_FRGD_SRC_HOST (2 << 8) -# define MACH64_FRGD_SRC_BLIT (3 << 8) -# define MACH64_FRGD_SRC_PATTERN (4 << 8) -# define MACH64_FRGD_SRC_3D (5 << 8) -# define MACH64_MONO_SRC_ONE (0 << 16) -# define MACH64_MONO_SRC_PATTERN (1 << 16) -# define MACH64_MONO_SRC_HOST (2 << 16) -# define MACH64_MONO_SRC_BLIT (3 << 16) - -#define MACH64_DP_WRITE_MASK 0x06c8 - -#define MACH64_DST_CNTL 0x0530 -# define MACH64_DST_X_RIGHT_TO_LEFT (0 << 0) -# define MACH64_DST_X_LEFT_TO_RIGHT (1 << 0) -# define MACH64_DST_Y_BOTTOM_TO_TOP (0 << 1) -# define MACH64_DST_Y_TOP_TO_BOTTOM (1 << 1) -# define MACH64_DST_X_MAJOR (0 << 2) -# define MACH64_DST_Y_MAJOR (1 << 2) -# define MACH64_DST_X_TILE (1 << 3) -# define MACH64_DST_Y_TILE (1 << 4) -# define MACH64_DST_LAST_PEL (1 << 5) -# define MACH64_DST_POLYGON_ENABLE (1 << 6) -# define MACH64_DST_24_ROTATION_ENABLE (1 << 7) - -#define MACH64_DST_HEIGHT_WIDTH 0x0518 -#define MACH64_DST_OFF_PITCH 0x0500 -#define MACH64_DST_WIDTH_HEIGHT 0x06ec -#define MACH64_DST_X_Y 0x06e8 -#define MACH64_DST_Y_X 0x050c - -#define MACH64_FIFO_STAT 0x0710 -# define MACH64_FIFO_SLOT_MASK 0x0000ffff -# define MACH64_FIFO_ERR (1 << 31) - -#define MACH64_GEN_TEST_CNTL 0x04d0 -#define MACH64_GUI_CMDFIFO_DEBUG 0x0170 -#define MACH64_GUI_CMDFIFO_DATA 0x0174 -#define MACH64_GUI_CNTL 0x0178 -#define MACH64_GUI_STAT 0x0738 -# define MACH64_GUI_ACTIVE (1 << 0) -#define MACH64_GUI_TRAJ_CNTL 0x0730 - -#define MACH64_HOST_CNTL 0x0640 -#define MACH64_HOST_DATA0 0x0600 -#define MACH64_HW_DEBUG 0x047c - -#define MACH64_ONE_OVER_AREA 0x029c -#define MACH64_ONE_OVER_AREA_UC 0x0300 - -#define MACH64_PAT_REG0 0x0680 -#define MACH64_PAT_REG1 0x0684 - -#define MACH64_SC_LEFT_RIGHT 0x06a8 -#define MACH64_SC_TOP_BOTTOM 0x06b4 -#define MACH64_SCALE_3D_CNTL 0x05fc -# define MACH64_SCALE_PIX_EXPAND_ZERO_EXTEND (0 << 0) -# define MACH64_SCALE_PIX_EXPAND_DYNAMIC_RANGE (1 << 0) -# define MACH64_SCALE_DITHER_ERROR_DIFFUSE (0 << 1) -# define MACH64_SCALE_DITHER_2D_TABLE (1 << 1) -# define MACH64_DITHER_EN (1 << 2) -# define MACH64_DITHER_INIT_CURRENT (O << 3) -# define MACH64_DITHER_INIT_RESET (1 << 3) -# define MACH64_ROUND_EN (1 << 4) -# define MACH64_TEX_CACHE_DIS (1 << 5) -# define MACH64_SCALE_3D_FCN_MASK (3 << 6) -# define MACH64_SCALE_3D_FCN_NOP (0 << 6) -# define MACH64_SCALE_3D_FCN_SCALE (1 << 6) -# define MACH64_SCALE_3D_FCN_TEXTURE (2 << 6) -# define MACH64_SCALE_3D_FCN_SHADE (3 << 6) -# define MACH64_TEXTURE_DISABLE (1 << 6) -# define MACH64_EDGE_ANTI_ALIAS (1 << 8) -# define MACH64_TEX_CACHE_SPLIT (1 << 9) -# define MACH64_APPLE_YUV_MODE (1 << 10) -# define MACH64_ALPHA_FOG_EN_MASK (3 << 11) -# define MACH64_ALPHA_FOG_DIS (0 << 11) -# define MACH64_ALPHA_FOG_EN_ALPHA (1 << 11) -# define MACH64_ALPHA_FOG_EN_FOG (2 << 11) -# define MACH64_ALPHA_BLEND_SAT (1 << 13) -# define MACH64_RED_DITHER_MAX (1 << 14) -# define MACH64_SIGNED_DST_CLAMP (1 << 15) -# define MACH64_ALPHA_BLEND_SRC_MASK (7 << 16) -# define MACH64_ALPHA_BLEND_SRC_ZERO (0 << 16) -# define MACH64_ALPHA_BLEND_SRC_ONE (1 << 16) -# define MACH64_ALPHA_BLEND_SRC_DSTCOLOR (2 << 16) -# define MACH64_ALPHA_BLEND_SRC_INVDSTCOLOR (3 << 16) -# define MACH64_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) -# define MACH64_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) -# define MACH64_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) -# define MACH64_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) -# define MACH64_ALPHA_BLEND_DST_MASK (7 << 19) -# define MACH64_ALPHA_BLEND_DST_ZERO (0 << 19) -# define MACH64_ALPHA_BLEND_DST_ONE (1 << 19) -# define MACH64_ALPHA_BLEND_DST_SRCCOLOR (2 << 19) -# define MACH64_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 19) -# define MACH64_ALPHA_BLEND_DST_SRCALPHA (4 << 19) -# define MACH64_ALPHA_BLEND_DST_INVSRCALPHA (5 << 19) -# define MACH64_ALPHA_BLEND_DST_DSTALPHA (6 << 19) -# define MACH64_ALPHA_BLEND_DST_INVDSTALPHA (7 << 19) -# define MACH64_TEX_LIGHT_FCN_MASK (3 << 22) -# define MACH64_TEX_LIGHT_FCN_REPLACE (0 << 22) -# define MACH64_TEX_LIGHT_FCN_MODULATE (1 << 22) -# define MACH64_TEX_LIGHT_FCN_ALPHA_DECAL (2 << 22) -# define MACH64_MIP_MAP_DISABLE (1 << 24) -# define MACH64_BILINEAR_TEX_EN (1 << 25) -# define MACH64_TEX_BLEND_FCN_MASK (3 << 26) -# define MACH64_TEX_BLEND_FCN_NEAREST (0 << 26) -# define MACH64_TEX_BLEND_FCN_LINEAR (2 << 26) -# define MACH64_TEX_BLEND_FCN_TRILINEAR (3 << 26) -# define MACH64_TEX_AMASK_AEN (1 << 28) -# define MACH64_TEX_AMASK_BLEND_EDGE (1 << 29) -# define MACH64_TEX_MAP_AEN (1 << 30) -# define MACH64_SRC_3D_HOST_FIFO (1 << 31) -#define MACH64_SCRATCH_REG0 0x0480 -#define MACH64_SCRATCH_REG1 0x0484 -#define MACH64_SECONDARY_TEX_OFF 0x0778 -#define MACH64_SETUP_CNTL 0x0304 -# define MACH64_DONT_START_TRI (1 << 0) -# define MACH64_DONT_START_ANY (1 << 2) -# define MACH64_FLAT_SHADE_MASK (3 << 3) -# define MACH64_FLAT_SHADE_OFF (0 << 3) -# define MACH64_FLAT_SHADE_VERTEX_1 (1 << 3) -# define MACH64_FLAT_SHADE_VERTEX_2 (2 << 3) -# define MACH64_FLAT_SHADE_VERTEX_3 (3 << 3) -# define MACH64_SOLID_MODE_OFF (0 << 5) -# define MACH64_SOLID_MODE_ON (1 << 5) -# define MACH64_LOG_MAX_INC_ADJ (1 << 6) -# define MACH64_SET_UP_CONTINUE (1 << 31) -#define MACH64_SRC_CNTL 0x05b4 -#define MACH64_SRC_HEIGHT1 0x0594 -#define MACH64_SRC_HEIGHT2 0x05ac -#define MACH64_SRC_HEIGHT1_WIDTH1 0x0598 -#define MACH64_SRC_HEIGHT2_WIDTH2 0x05b0 -#define MACH64_SRC_OFF_PITCH 0x0580 -#define MACH64_SRC_WIDTH1 0x0590 -#define MACH64_SRC_Y_X 0x058c - -#define MACH64_TEX_0_OFF 0x05c0 -#define MACH64_TEX_CNTL 0x0774 -# define MACH64_LOD_BIAS_SHIFT 0 -# define MACH64_LOD_BIAS_MASK (0xf << 0) -# define MACH64_COMP_FACTOR_SHIFT 4 -# define MACH64_COMP_FACTOR_MASK (0xf << 4) -# define MACH64_TEXTURE_COMPOSITE (1 << 8) -# define MACH64_COMP_COMBINE_BLEND (0 << 9) -# define MACH64_COMP_COMBINE_MODULATE (1 << 9) -# define MACH64_COMP_BLEND_NEAREST (0 << 11) -# define MACH64_COMP_BLEND_BILINEAR (1 << 11) -# define MACH64_COMP_FILTER_NEAREST (0 << 12) -# define MACH64_COMP_FILTER_BILINEAR (1 << 12) -# define MACH64_COMP_ALPHA (1 << 13) -# define MACH64_TEXTURE_TILING (1 << 14) -# define MACH64_COMPOSITE_TEX_TILING (1 << 15) -# define MACH64_TEX_COLLISION_DISABLE (1 << 16) -# define MACH64_TEXTURE_CLAMP_S (1 << 17) -# define MACH64_TEXTURE_CLAMP_T (1 << 18) -# define MACH64_TEX_ST_MULT_W (0 << 19) -# define MACH64_TEX_ST_DIRECT (1 << 19) -# define MACH64_TEX_SRC_LOCAL (0 << 20) -# define MACH64_TEX_SRC_AGP (1 << 20) -# define MACH64_TEX_UNCOMPRESSED (0 << 21) -# define MACH64_TEX_VQ_COMPRESSED (1 << 21) -# define MACH64_COMP_TEX_UNCOMPRESSED (0 << 22) -# define MACH64_COMP_TEX_VQ_COMPRESSED (1 << 22) -# define MACH64_TEX_CACHE_FLUSH (1 << 23) -# define MACH64_SEC_TEX_CLAMP_S (1 << 24) -# define MACH64_SEC_TEX_CLAMP_T (1 << 25) -# define MACH64_TEX_WRAP_S (1 << 28) -# define MACH64_TEX_WRAP_T (1 << 29) -# define MACH64_TEX_CACHE_SIZE_4K (1 << 30) -# define MACH64_TEX_CACHE_SIZE_2K (1 << 30) -# define MACH64_SECONDARY_STW (1 << 31) -#define MACH64_TEX_PALETTE 0x077c -#define MACH64_TEX_PALETTE_INDEX 0x0740 -#define MACH64_TEX_SIZE_PITCH 0x0770 - -#define MACH64_VERTEX_1_ARGB 0x0254 -#define MACH64_VERTEX_1_S 0x0240 -#define MACH64_VERTEX_1_SECONDARY_S 0x0328 -#define MACH64_VERTEX_1_SECONDARY_T 0x032c -#define MACH64_VERTEX_1_SECONDARY_W 0x0330 -#define MACH64_VERTEX_1_SPEC_ARGB 0x024c -#define MACH64_VERTEX_1_T 0x0244 -#define MACH64_VERTEX_1_W 0x0248 -#define MACH64_VERTEX_1_X_Y 0x0258 -#define MACH64_VERTEX_1_Z 0x0250 -#define MACH64_VERTEX_2_ARGB 0x0274 -#define MACH64_VERTEX_2_S 0x0260 -#define MACH64_VERTEX_2_SECONDARY_S 0x0334 -#define MACH64_VERTEX_2_SECONDARY_T 0x0338 -#define MACH64_VERTEX_2_SECONDARY_W 0x033c -#define MACH64_VERTEX_2_SPEC_ARGB 0x026c -#define MACH64_VERTEX_2_T 0x0264 -#define MACH64_VERTEX_2_W 0x0268 -#define MACH64_VERTEX_2_X_Y 0x0278 -#define MACH64_VERTEX_2_Z 0x0270 -#define MACH64_VERTEX_3_ARGB 0x0294 -#define MACH64_VERTEX_3_S 0x0280 -#define MACH64_VERTEX_3_SECONDARY_S 0x02a0 -#define MACH64_VERTEX_3_SECONDARY_T 0x02a4 -#define MACH64_VERTEX_3_SECONDARY_W 0x02a8 -#define MACH64_VERTEX_3_SPEC_ARGB 0x028c -#define MACH64_VERTEX_3_T 0x0284 -#define MACH64_VERTEX_3_W 0x0288 -#define MACH64_VERTEX_3_X_Y 0x0298 -#define MACH64_VERTEX_3_Z 0x0290 - -#define MACH64_Z_CNTL 0x054c -# define MACH64_Z_EN (1 << 0) -# define MACH64_Z_SRC_2D (1 << 1) -# define MACH64_Z_TEST_MASK (7 << 4) -# define MACH64_Z_TEST_NEVER (0 << 4) -# define MACH64_Z_TEST_LESS (1 << 4) -# define MACH64_Z_TEST_LEQUAL (2 << 4) -# define MACH64_Z_TEST_EQUAL (3 << 4) -# define MACH64_Z_TEST_GEQUAL (4 << 4) -# define MACH64_Z_TEST_GREATER (5 << 4) -# define MACH64_Z_TEST_NOTEQUAL (6 << 4) -# define MACH64_Z_TEST_ALWAYS (7 << 4) -# define MACH64_Z_MASK_EN (1 << 8) -#define MACH64_Z_OFF_PITCH 0x0548 - - - -#define MACH64_DATATYPE_CI8 2 -#define MACH64_DATATYPE_ARGB1555 3 -#define MACH64_DATATYPE_RGB565 4 -#define MACH64_DATATYPE_ARGB8888 6 -#define MACH64_DATATYPE_RGB332 7 -#define MACH64_DATATYPE_Y8 8 -#define MACH64_DATATYPE_RGB8 9 -#define MACH64_DATATYPE_VYUY422 11 -#define MACH64_DATATYPE_YVYU422 12 -#define MACH64_DATATYPE_AYUV444 14 -#define MACH64_DATATYPE_ARGB4444 15 - -#define MACH64_LAST_FRAME_REG MACH64_PAT_REG0 -#define MACH64_LAST_DISPATCH_REG MACH64_PAT_REG1 - -#endif /* __MACH64_REG_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c deleted file mode 100644 index 956bccbcd6c..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ /dev/null @@ -1,462 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos�Fonseca <[email protected]> - */ - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_span.h" - -#include "main/context.h" -#include "main/imports.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" - -#include "utils.h" -#include "vblank.h" - -#include "GL/internal/dri_interface.h" - -/* Mach64 configuration - */ -#include "xmlpool.h" - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) -#if ENABLE_PERF_BOXES - DRI_CONF_PERFORMANCE_BOXES(false) -#endif - DRI_CONF_SECTION_END -DRI_CONF_END; -#if ENABLE_PERF_BOXES -static const GLuint __driNConfigOptions = 3; -#else -static const GLuint __driNConfigOptions = 2; -#endif - -static const __DRIconfig ** -mach64FillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - struct gl_config * m; - GLenum fb_format; - GLenum fb_type; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - unsigned i; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, back_buffer_modes, - back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const __DRIconfig **) configs; -} - - -/* Create the device specific screen private data struct. - */ -static mach64ScreenRec * -mach64CreateScreen( __DRIscreen *sPriv ) -{ - mach64ScreenPtr mach64Screen; - ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv; - int i; - - if (sPriv->devPrivSize != sizeof(ATIDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(ATIDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - if ( MACH64_DEBUG & DEBUG_VERBOSE_DRI ) - fprintf( stderr, "%s\n", __FUNCTION__ ); - - /* Allocate the private area */ - mach64Screen = (mach64ScreenPtr) CALLOC( sizeof(*mach64Screen) ); - if ( !mach64Screen ) return NULL; - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&mach64Screen->optionCache, - __driConfigOptions, __driNConfigOptions); - - mach64Screen->IsPCI = serverInfo->IsPCI; - - { - drm_mach64_getparam_t gp; - int ret; - - gp.param = MACH64_PARAM_IRQ_NR; - gp.value = (void *) &mach64Screen->irq; - - ret = drmCommandWriteRead( sPriv->fd, DRM_MACH64_GETPARAM, - &gp, sizeof(gp)); - if (ret) { - fprintf(stderr, "DRM_MACH64_GETPARAM (MACH64_PARAM_IRQ_NR): %d\n", ret); - FREE( mach64Screen ); - return NULL; - } - } - - mach64Screen->mmio.handle = serverInfo->regs; - mach64Screen->mmio.size = serverInfo->regsSize; - if ( drmMap( sPriv->fd, - mach64Screen->mmio.handle, - mach64Screen->mmio.size, - (drmAddressPtr)&mach64Screen->mmio.map ) != 0 ) { - FREE( mach64Screen ); - return NULL; - } - - mach64Screen->buffers = drmMapBufs( sPriv->fd ); - if ( !mach64Screen->buffers ) { - drmUnmap( (drmAddress)mach64Screen->mmio.map, - mach64Screen->mmio.size ); - FREE( mach64Screen ); - return NULL; - } - - if ( !mach64Screen->IsPCI ) { - mach64Screen->agpTextures.handle = serverInfo->agp; - mach64Screen->agpTextures.size = serverInfo->agpSize; - if ( drmMap( sPriv->fd, - mach64Screen->agpTextures.handle, - mach64Screen->agpTextures.size, - (drmAddressPtr)&mach64Screen->agpTextures.map ) ) { - drmUnmapBufs( mach64Screen->buffers ); - drmUnmap( (drmAddress)mach64Screen->mmio.map, mach64Screen->mmio.size ); - FREE( mach64Screen ); - return NULL; - } - } - - mach64Screen->AGPMode = serverInfo->AGPMode; - - mach64Screen->chipset = serverInfo->chipset; - mach64Screen->width = serverInfo->width; - mach64Screen->height = serverInfo->height; - mach64Screen->mem = serverInfo->mem; - mach64Screen->cpp = serverInfo->cpp; - - mach64Screen->frontOffset = serverInfo->frontOffset; - mach64Screen->frontPitch = serverInfo->frontPitch; - mach64Screen->backOffset = serverInfo->backOffset; - mach64Screen->backPitch = serverInfo->backPitch; - mach64Screen->depthOffset = serverInfo->depthOffset; - mach64Screen->depthPitch = serverInfo->depthPitch; - - mach64Screen->texOffset[MACH64_CARD_HEAP] = serverInfo->textureOffset; - mach64Screen->texSize[MACH64_CARD_HEAP] = serverInfo->textureSize; - mach64Screen->logTexGranularity[MACH64_CARD_HEAP] = - serverInfo->logTextureGranularity; - - if ( mach64Screen->IsPCI ) { - mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS - 1; - mach64Screen->firstTexHeap = MACH64_CARD_HEAP; - mach64Screen->texOffset[MACH64_AGP_HEAP] = 0; - mach64Screen->texSize[MACH64_AGP_HEAP] = 0; - mach64Screen->logTexGranularity[MACH64_AGP_HEAP] = 0; - } else { - if (serverInfo->textureSize > 0) { - mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS; - mach64Screen->firstTexHeap = MACH64_CARD_HEAP; - } else { - mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS - 1; - mach64Screen->firstTexHeap = MACH64_AGP_HEAP; - } - mach64Screen->texOffset[MACH64_AGP_HEAP] = serverInfo->agpTextureOffset; - mach64Screen->texSize[MACH64_AGP_HEAP] = serverInfo->agpSize; - mach64Screen->logTexGranularity[MACH64_AGP_HEAP] = serverInfo->logAgpTextureGranularity; - } - - mach64Screen->driScreen = sPriv; - - i = 0; - if ( mach64Screen->irq != 0 ) { - mach64Screen->extensions[i++] = &driSwapControlExtension.base; - mach64Screen->extensions[i++] = &driMediaStreamCounterExtension.base; - } - mach64Screen->extensions[i++] = NULL; - sPriv->extensions = mach64Screen->extensions; - - return mach64Screen; -} - -/* Destroy the device specific screen private data struct. - */ -static void -mach64DestroyScreen( __DRIscreen *driScreen ) -{ - mach64ScreenRec *mach64Screen = (mach64ScreenRec *) driScreen->private; - - if ( !mach64Screen ) - return; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_DRI ) - fprintf( stderr, "%s\n", __FUNCTION__ ); - - if ( !mach64Screen->IsPCI ) { - drmUnmap( (drmAddress)mach64Screen->agpTextures.map, - mach64Screen->agpTextures.size ); - } - - drmUnmapBufs( mach64Screen->buffers ); - drmUnmap( (drmAddress)mach64Screen->mmio.map, mach64Screen->mmio.size ); - - FREE( mach64Screen ); - driScreen->private = NULL; -} - - -/* Create and initialize the Mesa and driver specific pixmap buffer - * data. - */ -static GLboolean -mach64CreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap ) -{ - mach64ScreenPtr screen = (mach64ScreenPtr) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - NULL, - screen->cpp, - screen->frontOffset, screen->frontPitch, - driDrawPriv); - mach64SetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - NULL, - screen->cpp, - screen->backOffset, screen->backPitch, - driDrawPriv); - mach64SetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, - NULL, screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mach64SetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - /* XXX I don't think 24-bit Z is supported - so this isn't used */ - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z24_S8, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mach64SetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -mach64DestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - - -/* Copy the back color buffer to the front color buffer */ -static void -mach64SwapBuffers(__DRIdrawable *dPriv) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - mach64ContextPtr mmesa; - struct gl_context *ctx; - mmesa = (mach64ContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = mmesa->glCtx; - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - mach64CopyBuffer( dPriv ); - } - } - else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__); - } -} - - -/* Initialize the driver specific screen private data. - */ -static GLboolean -mach64InitDriver( __DRIscreen *driScreen ) -{ - driScreen->private = (void *) mach64CreateScreen( driScreen ); - - if ( !driScreen->private ) { - mach64DestroyScreen( driScreen ); - return GL_FALSE; - } - - return GL_TRUE; -} - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -mach64InitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { 6, 4, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 2, 0, 0 }; - ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions2( "Mach64", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) { - return NULL; - } - - if (!mach64InitDriver(psp)) - return NULL; - - return mach64FillInModes( psp, dri_priv->cpp * 8, 16, 0, 1); -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = mach64InitScreen, - .DestroyScreen = mach64DestroyScreen, - .CreateContext = mach64CreateContext, - .DestroyContext = mach64DestroyContext, - .CreateBuffer = mach64CreateBuffer, - .DestroyBuffer = mach64DestroyBuffer, - .SwapBuffers = mach64SwapBuffers, - .MakeCurrent = mach64MakeCurrent, - .UnbindContext = mach64UnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.h b/src/mesa/drivers/dri/mach64/mach64_screen.h deleted file mode 100644 index 1966809c03c..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_screen.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#ifndef __MACH64_SCREEN_H__ -#define __MACH64_SCREEN_H__ - -#include "xmlconfig.h" - -typedef struct { - drm_handle_t handle; /* Handle to the DRM region */ - drmSize size; /* Size of the DRM region */ - drmAddress *map; /* Mapping of the DRM region */ -} mach64RegionRec, *mach64RegionPtr; - -typedef struct { - int chipset; - int width; - int height; - int mem; - int cpp; - - unsigned int frontOffset; - unsigned int frontPitch; - unsigned int backOffset; - unsigned int backPitch; - - unsigned int depthOffset; - unsigned int depthPitch; - - int IsPCI; - int AGPMode; - unsigned int irq; /* IRQ number (0 means none) */ - - /* Shared Texture data */ - int firstTexHeap, numTexHeaps; - int texOffset[MACH64_NR_TEX_HEAPS]; - int texSize[MACH64_NR_TEX_HEAPS]; - int logTexGranularity[MACH64_NR_TEX_HEAPS]; - - mach64RegionRec mmio; - mach64RegionRec agpTextures; - - drmBufMapPtr buffers; - - __DRIscreen *driScreen; - - driOptionCache optionCache; - - const __DRIextension *extensions[4]; -} mach64ScreenRec, *mach64ScreenPtr; - -#endif /* __MACH64_SCREEN_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_span.c b/src/mesa/drivers/dri/mach64/mach64_span.c deleted file mode 100644 index 4b853c2af34..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_span.c +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos�Fonseca <[email protected]> - */ - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_span.h" - -#include "swrast/swrast.h" - -#define DBG 0 - -#define LOCAL_VARS \ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \ - __DRIscreen *sPriv = mmesa->driScreen; \ - __DRIdrawable *dPriv = mmesa->driDrawable; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint height = dPriv->h; \ - GLushort p; \ - (void) p; - -#define LOCAL_DEPTH_VARS \ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \ - __DRIdrawable *dPriv = mmesa->driDrawable; \ - __DRIscreen *driScreen = mmesa->driScreen; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(driScreen->pFB + drb->offset + \ - (dPriv->x + dPriv->y * drb->pitch) * 2) - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define Y_FLIP( _y ) (height - _y - 1) - -#define HW_LOCK() - -/* FIXME could/should we use dPriv->numClipRects like the other drivers? */ -#define HW_CLIPLOOP() \ - do { \ - int _nc = mmesa->numClipRects; \ - \ - while ( _nc-- ) { \ - int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \ - int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \ - int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \ - int maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY; - -#define HW_ENDCLIPLOOP() \ - } \ - } while (0) - -#define HW_UNLOCK() - - - -/* ================================================================ - * Color buffer - */ - -/* 16 bit, RGB565 color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_RGB -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 - -#define TAG(x) mach64##x##_RGB565 -#define TAG2(x,y) mach64##x##_RGB565##y -#define GET_PTR(X,Y) (sPriv->pFB + drb->offset \ - + ((dPriv->y + (Y)) * drb->pitch + (dPriv->x + (X))) * drb->cpp) -#include "spantmp2.h" - - -/* 32 bit, ARGB8888 color spanline and pixel functions - */ -/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque. - Was there a reason to do so ? If so that'll won't work with that template... */ -#define SPANTMP_PIXEL_FMT GL_BGRA -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV - -#define TAG(x) mach64##x##_ARGB8888 -#define TAG2(x,y) mach64##x##_ARGB8888##y -#define GET_PTR(X,Y) (sPriv->pFB + drb->offset \ - + ((dPriv->y + (Y)) * drb->pitch + (dPriv->x + (X))) * drb->cpp) -#include "spantmp2.h" - - -/* ================================================================ - * Depth buffer - */ - -/* 16 bit depthbuffer functions. - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2) = d; - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2); - -#define TAG(x) mach64##x##_z16 -#include "depthtmp.h" - - -static void mach64SpanRenderStart( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - LOCK_HARDWARE( mmesa ); - FINISH_DMA_LOCKED( mmesa ); -} - -static void mach64SpanRenderFinish( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - _swrast_flush( ctx ); - UNLOCK_HARDWARE( mmesa ); -} - -void mach64DDInitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = mach64SpanRenderStart; - swdd->SpanRenderFinish = mach64SpanRenderFinish; -} - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -mach64SetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis) -{ - if (drb->Base.Format == MESA_FORMAT_RGB565) { - mach64InitPointers_RGB565(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_ARGB8888) { - mach64InitPointers_ARGB8888(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_Z16) { - mach64InitDepthPointers_z16(&drb->Base); - } -} diff --git a/src/mesa/drivers/dri/mach64/mach64_span.h b/src/mesa/drivers/dri/mach64/mach64_span.h deleted file mode 100644 index 2742e93c8e2..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_span.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * - */ - -#ifndef __MACH64_SPAN_H__ -#define __MACH64_SPAN_H__ - -#include "drirenderbuffer.h" - -extern void mach64DDInitSpanFuncs( struct gl_context *ctx ); - -extern void -mach64SetSpanFunctions(driRenderbuffer *rb, const struct gl_config *vis); - -#endif diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c deleted file mode 100644 index c1a4e63204f..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_state.c +++ /dev/null @@ -1,1186 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos�Fonseca <[email protected]> - */ - -#include "mach64_context.h" -#include "mach64_state.h" -#include "mach64_ioctl.h" -#include "mach64_tris.h" -#include "mach64_vb.h" -#include "mach64_tex.h" - -#include "main/enums.h" -#include "main/colormac.h" -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "swrast_setup/swrast_setup.h" - - -/* ============================================================= - * Alpha blending - */ - -static void mach64UpdateAlphaMode( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint a = mmesa->setup.alpha_tst_cntl; - GLuint s = mmesa->setup.scale_3d_cntl; - GLuint m = mmesa->setup.dp_write_mask; - - if ( ctx->Color.AlphaEnabled ) { - GLubyte ref; - - CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef); - - a &= ~(MACH64_ALPHA_TEST_MASK | MACH64_REF_ALPHA_MASK); - - switch ( ctx->Color.AlphaFunc ) { - case GL_NEVER: - a |= MACH64_ALPHA_TEST_NEVER; - break; - case GL_LESS: - a |= MACH64_ALPHA_TEST_LESS; - break; - case GL_LEQUAL: - a |= MACH64_ALPHA_TEST_LEQUAL; - break; - case GL_EQUAL: - a |= MACH64_ALPHA_TEST_EQUAL; - break; - case GL_GEQUAL: - a |= MACH64_ALPHA_TEST_GEQUAL; - break; - case GL_GREATER: - a |= MACH64_ALPHA_TEST_GREATER; - break; - case GL_NOTEQUAL: - a |= MACH64_ALPHA_TEST_NOTEQUAL; - break; - case GL_ALWAYS: - a |= MACH64_ALPHA_TEST_ALWAYS; - break; - } - - a |= (ref << MACH64_REF_ALPHA_SHIFT); - a |= MACH64_ALPHA_TEST_EN; - } else { - a &= ~MACH64_ALPHA_TEST_EN; - } - - FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_FALSE ); - - if ( ctx->Color.BlendEnabled ) { - s &= ~(MACH64_ALPHA_BLEND_SRC_MASK | - MACH64_ALPHA_BLEND_DST_MASK | - MACH64_ALPHA_BLEND_SAT); - - switch ( ctx->Color.Blend[0].SrcRGB ) { - case GL_ZERO: - s |= MACH64_ALPHA_BLEND_SRC_ZERO; - break; - case GL_ONE: - s |= MACH64_ALPHA_BLEND_SRC_ONE; - break; - case GL_DST_COLOR: - s |= MACH64_ALPHA_BLEND_SRC_DSTCOLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - s |= MACH64_ALPHA_BLEND_SRC_INVDSTCOLOR; - break; - case GL_SRC_ALPHA: - s |= MACH64_ALPHA_BLEND_SRC_SRCALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - s |= MACH64_ALPHA_BLEND_SRC_INVSRCALPHA; - break; - case GL_DST_ALPHA: - s |= MACH64_ALPHA_BLEND_SRC_DSTALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - s |= MACH64_ALPHA_BLEND_SRC_INVDSTALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - s |= (MACH64_ALPHA_BLEND_SRC_SRCALPHA | - MACH64_ALPHA_BLEND_SAT); - break; - default: - FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_TRUE ); - } - - switch ( ctx->Color.Blend[0].DstRGB ) { - case GL_ZERO: - s |= MACH64_ALPHA_BLEND_DST_ZERO; - break; - case GL_ONE: - s |= MACH64_ALPHA_BLEND_DST_ONE; - break; - case GL_SRC_COLOR: - s |= MACH64_ALPHA_BLEND_DST_SRCCOLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - s |= MACH64_ALPHA_BLEND_DST_INVSRCCOLOR; - break; - case GL_SRC_ALPHA: - s |= MACH64_ALPHA_BLEND_DST_SRCALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - s |= MACH64_ALPHA_BLEND_DST_INVSRCALPHA; - break; - case GL_DST_ALPHA: - s |= MACH64_ALPHA_BLEND_DST_DSTALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - s |= MACH64_ALPHA_BLEND_DST_INVDSTALPHA; - break; - default: - FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_TRUE ); - } - - m = 0xffffffff; /* Can't color mask and blend at the same time */ - s &= ~MACH64_ALPHA_FOG_EN_FOG; /* Can't fog and blend at the same time */ - s |= MACH64_ALPHA_FOG_EN_ALPHA; - } else { - s &= ~MACH64_ALPHA_FOG_EN_ALPHA; - } - - if ( mmesa->setup.alpha_tst_cntl != a ) { - mmesa->setup.alpha_tst_cntl = a; - mmesa->dirty |= MACH64_UPLOAD_Z_ALPHA_CNTL; - } - if ( mmesa->setup.scale_3d_cntl != s ) { - mmesa->setup.scale_3d_cntl = s; - mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL; - } - if ( mmesa->setup.dp_write_mask != m ) { - mmesa->setup.dp_write_mask = m; - mmesa->dirty |= MACH64_UPLOAD_DP_WRITE_MASK; - } -} - -static void mach64DDAlphaFunc( struct gl_context *ctx, GLenum func, GLfloat ref ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_ALPHA; -} - -static void mach64DDBlendEquationSeparate( struct gl_context *ctx, - GLenum modeRGB, GLenum modeA ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - assert( modeRGB == modeA ); - FLUSH_BATCH( mmesa ); - - /* BlendEquation affects ColorLogicOpEnabled - */ - FALLBACK( MACH64_CONTEXT(ctx), MACH64_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - - /* Can only do blend addition, not min, max, subtract, etc. */ - FALLBACK( MACH64_CONTEXT(ctx), MACH64_FALLBACK_BLEND_EQ, - modeRGB != GL_FUNC_ADD); - - mmesa->new_state |= MACH64_NEW_ALPHA; -} - -static void mach64DDBlendFuncSeparate( struct gl_context *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_ALPHA; -} - - -/* ============================================================= - * Depth testing - */ - -static void mach64UpdateZMode( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint z = mmesa->setup.z_cntl; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) { - fprintf( stderr, "%s:\n", __FUNCTION__ ); - } - - if ( ctx->Depth.Test ) { - z &= ~MACH64_Z_TEST_MASK; - - switch ( ctx->Depth.Func ) { - case GL_NEVER: - z |= MACH64_Z_TEST_NEVER; - break; - case GL_ALWAYS: - z |= MACH64_Z_TEST_ALWAYS; - break; - case GL_LESS: - z |= MACH64_Z_TEST_LESS; - break; - case GL_LEQUAL: - z |= MACH64_Z_TEST_LEQUAL; - break; - case GL_EQUAL: - z |= MACH64_Z_TEST_EQUAL; - break; - case GL_GEQUAL: - z |= MACH64_Z_TEST_GEQUAL; - break; - case GL_GREATER: - z |= MACH64_Z_TEST_GREATER; - break; - case GL_NOTEQUAL: - z |= MACH64_Z_TEST_NOTEQUAL; - break; - } - - z |= MACH64_Z_EN; - } else { - z &= ~MACH64_Z_EN; - } - - if ( ctx->Depth.Mask ) { - z |= MACH64_Z_MASK_EN; - } else { - z &= ~MACH64_Z_MASK_EN; - } - - if ( mmesa->setup.z_cntl != z ) { - mmesa->setup.z_cntl = z; - mmesa->dirty |= MACH64_UPLOAD_Z_ALPHA_CNTL; - } -} - -static void mach64DDDepthFunc( struct gl_context *ctx, GLenum func ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_DEPTH; -} - -static void mach64DDDepthMask( struct gl_context *ctx, GLboolean flag ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_DEPTH; -} - -static void mach64DDClearDepth( struct gl_context *ctx, GLclampd d ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - /* Always have a 16-bit depth buffer. - */ - mmesa->ClearDepth = d * 0xffff; -} - - -/* ============================================================= - * Fog - */ - -static void mach64UpdateFogAttrib( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - CARD32 s = mmesa->setup.scale_3d_cntl; - GLubyte c[4]; - CARD32 col; - - /* Can't fog if blending is on */ - if ( ctx->Color.BlendEnabled ) - return; - - if ( ctx->Fog.Enabled ) { - s |= MACH64_ALPHA_FOG_EN_FOG; - s &= ~(MACH64_ALPHA_BLEND_SRC_MASK | - MACH64_ALPHA_BLEND_DST_MASK | - MACH64_ALPHA_BLEND_SAT); - /* From Utah-glx: "fog color is now dest and fog factor is alpha, so - * use GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA" - */ - s |= (MACH64_ALPHA_BLEND_SRC_SRCALPHA | - MACH64_ALPHA_BLEND_DST_INVSRCALPHA); - /* From Utah-glx: "can't use texture alpha when fogging" */ - s &= ~MACH64_TEX_MAP_AEN; - } else { - s &= ~(MACH64_ALPHA_BLEND_SRC_MASK | - MACH64_ALPHA_BLEND_DST_MASK | - MACH64_ALPHA_BLEND_SAT); - s |= (MACH64_ALPHA_BLEND_SRC_ONE | - MACH64_ALPHA_BLEND_DST_ZERO); - s &= ~MACH64_ALPHA_FOG_EN_FOG; - } - - 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] ); - c[3] = FLOAT_TO_UBYTE( ctx->Fog.Color[3] ); - - col = mach64PackColor( 4, c[0], c[1], c[2], c[3] ); - - if ( mmesa->setup.dp_fog_clr != col ) { - mmesa->setup.dp_fog_clr = col; - mmesa->dirty |= MACH64_UPLOAD_DP_FOG_CLR; - } - if ( mmesa->setup.scale_3d_cntl != s ) { - mmesa->setup.scale_3d_cntl = s; - mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL; - } - -} - -static void mach64DDFogfv( struct gl_context *ctx, GLenum pname, const GLfloat *param ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_FOG; -} - - -/* ============================================================= - * Clipping - */ - -static void mach64UpdateClipping( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - mach64ScreenPtr mach64Screen = mmesa->mach64Screen; - - if ( mmesa->driDrawable ) { - __DRIdrawable *drawable = mmesa->driDrawable; - int x1 = 0; - int y1 = 0; - int x2 = drawable->w - 1; - int y2 = drawable->h - 1; - - if ( ctx->Scissor.Enabled ) { - if ( ctx->Scissor.X > x1 ) { - x1 = ctx->Scissor.X; - } - if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y1 ) { - y1 = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height; - } - if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < x2 ) { - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - } - if ( drawable->h - ctx->Scissor.Y - 1 < y2 ) { - y2 = drawable->h - ctx->Scissor.Y - 1; - } - } - - x1 += drawable->x; - y1 += drawable->y; - x2 += drawable->x; - y2 += drawable->y; - - /* clamp to screen borders */ - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 < 0) x2 = 0; - if (y2 < 0) y2 = 0; - if (x2 > mach64Screen->width-1) x2 = mach64Screen->width-1; - if (y2 > mach64Screen->height-1) y2 = mach64Screen->height-1; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) { - fprintf( stderr, "%s: drawable %3d %3d %3d %3d\n", - __FUNCTION__, - drawable->x, - drawable->y, - drawable->w, - drawable->h ); - fprintf( stderr, "%s: scissor %3d %3d %3d %3d\n", - __FUNCTION__, - ctx->Scissor.X, - ctx->Scissor.Y, - ctx->Scissor.Width, - ctx->Scissor.Height ); - fprintf( stderr, "%s: final %3d %3d %3d %3d\n", - __FUNCTION__, x1, y1, x2, y2 ); - fprintf( stderr, "\n" ); - } - - mmesa->setup.sc_top_bottom = ((y1 << 0) | - (y2 << 16)); - - mmesa->setup.sc_left_right = ((x1 << 0) | - (x2 << 16)); - - /* UPLOAD_MISC reduces the dirty state, we just need to - * emit the scissor to the SAREA. We need to dirty cliprects - * since the scissor and cliprects are intersected to update the - * single hardware scissor - */ - mmesa->dirty |= MACH64_UPLOAD_MISC | MACH64_UPLOAD_CLIPRECTS; - } -} - -static void mach64DDScissor( struct gl_context *ctx, - GLint x, GLint y, GLsizei w, GLsizei h ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_CLIP; -} - - -/* ============================================================= - * Culling - */ - -static void mach64UpdateCull( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLfloat backface_sign = 1; - - if ( ctx->Polygon.CullFlag /*&& ctx->PB->primitive == GL_POLYGON*/ ) { - 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: - case GL_FRONT_AND_BACK: - backface_sign = 0; - break; - } - } else { - backface_sign = 0; - } - - mmesa->backface_sign = backface_sign; - -} - -static void mach64DDCullFace( struct gl_context *ctx, GLenum mode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_CULL; -} - -static void mach64DDFrontFace( struct gl_context *ctx, GLenum mode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_CULL; -} - - -/* ============================================================= - * Masks - */ - -static void mach64UpdateMasks( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint mask = 0xffffffff; - - /* mach64 can't color mask with alpha blending enabled */ - if ( !ctx->Color.BlendEnabled ) { - mask = mach64PackColor( mmesa->mach64Screen->cpp, - ctx->Color.ColorMask[0][RCOMP], - ctx->Color.ColorMask[0][GCOMP], - ctx->Color.ColorMask[0][BCOMP], - ctx->Color.ColorMask[0][ACOMP] ); - } - - if ( mmesa->setup.dp_write_mask != mask ) { - mmesa->setup.dp_write_mask = mask; - mmesa->dirty |= MACH64_UPLOAD_DP_WRITE_MASK; - } -} - -static void mach64DDColorMask( struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_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 mach64UpdateSpecularLighting( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint a = mmesa->setup.alpha_tst_cntl; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) { - fprintf( stderr, "%s:\n", __FUNCTION__ ); - } - - if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR && - ctx->Light.Enabled ) { - a |= MACH64_SPECULAR_LIGHT_EN; - } else { - a &= ~MACH64_SPECULAR_LIGHT_EN; - } - - if ( mmesa->setup.alpha_tst_cntl != a ) { - mmesa->setup.alpha_tst_cntl = a; - mmesa->dirty |= MACH64_UPLOAD_Z_ALPHA_CNTL; - mmesa->new_state |= MACH64_NEW_CONTEXT; - } -} - -static void mach64DDLightModelfv( struct gl_context *ctx, GLenum pname, - const GLfloat *param ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) { - FLUSH_BATCH( mmesa ); - mach64UpdateSpecularLighting(ctx); - } -} - -static void mach64DDShadeModel( struct gl_context *ctx, GLenum mode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint s = mmesa->setup.setup_cntl; - - s &= ~MACH64_FLAT_SHADE_MASK; - - switch ( mode ) { - case GL_FLAT: - s |= MACH64_FLAT_SHADE_VERTEX_3; - break; - case GL_SMOOTH: - s |= MACH64_FLAT_SHADE_OFF; - break; - default: - return; - } - - if ( mmesa->setup.setup_cntl != s ) { - FLUSH_BATCH( mmesa ); - mmesa->setup.setup_cntl = s; - - mmesa->dirty |= MACH64_UPLOAD_SETUP_CNTL; - } -} - - -/* ============================================================= - * Viewport - */ - - -void mach64CalcViewport( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = mmesa->hw_viewport; - - /* See also mach64_translate_vertex. - */ - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX] + (GLfloat)mmesa->drawX + SUBPIXEL_X; - m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = - v[MAT_TY] + mmesa->driDrawable->h + (GLfloat)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 mach64Viewport( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - mach64CalcViewport( ctx ); -} - -static void mach64DepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - mach64CalcViewport( ctx ); -} - - -/* ============================================================= - * Miscellaneous - */ - -static void mach64DDClearColor( struct gl_context *ctx, - const GLfloat color[4] ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLubyte c[4]; - - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - mmesa->ClearColor = mach64PackColor( mmesa->mach64Screen->cpp, - c[0], c[1], c[2], c[3] ); -} - -static void mach64DDLogicOpCode( struct gl_context *ctx, GLenum opcode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - if ( ctx->Color.ColorLogicOpEnabled ) { - FLUSH_BATCH( mmesa ); - - FALLBACK( mmesa, MACH64_FALLBACK_LOGICOP, opcode != GL_COPY); - } -} - -void mach64SetCliprects( struct gl_context *ctx, GLenum mode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - __DRIdrawable *dPriv = mmesa->driDrawable; - - switch ( mode ) { - case GL_FRONT_LEFT: - mmesa->numClipRects = dPriv->numClipRects; - mmesa->pClipRects = dPriv->pClipRects; - mmesa->drawX = dPriv->x; - mmesa->drawY = dPriv->y; - break; - case GL_BACK_LEFT: - if ( dPriv->numBackClipRects == 0 ) { - mmesa->numClipRects = dPriv->numClipRects; - mmesa->pClipRects = dPriv->pClipRects; - mmesa->drawX = dPriv->x; - mmesa->drawY = dPriv->y; - } else { - mmesa->numClipRects = dPriv->numBackClipRects; - mmesa->pClipRects = dPriv->pBackClipRects; - mmesa->drawX = dPriv->backX; - mmesa->drawY = dPriv->backY; - } - break; - default: - return; - } - - mach64UpdateClipping( ctx ); - - mmesa->dirty |= MACH64_UPLOAD_CLIPRECTS; -} - -static void mach64DDDrawBuffer( struct gl_context *ctx, GLenum mode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ - FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE ); - mach64SetCliprects( ctx, GL_FRONT_LEFT ); - if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__); - break; - case BUFFER_BACK_LEFT: - FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE ); - mach64SetCliprects( ctx, GL_BACK_LEFT ); - if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__); - break; - default: - FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_TRUE ); - if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: fallback (mode=%d)\n", __FUNCTION__, mode); - break; - } - - mmesa->setup.dst_off_pitch = (((mmesa->drawPitch/8) << 22) | - (mmesa->drawOffset >> 3)); - - mmesa->dirty |= MACH64_UPLOAD_DST_OFF_PITCH; -} - -static void mach64DDReadBuffer( struct gl_context *ctx, GLenum mode ) -{ - /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */ -} - -/* ============================================================= - * State enable/disable - */ - -static void mach64DDEnable( struct gl_context *ctx, GLenum cap, GLboolean state ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %s = %s )\n", - __FUNCTION__, _mesa_lookup_enum_by_nr( cap ), - state ? "GL_TRUE" : "GL_FALSE" ); - } - - switch ( cap ) { - case GL_ALPHA_TEST: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_ALPHA; - break; - - case GL_BLEND: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_ALPHA; - - /* enable(GL_BLEND) affects ColorLogicOpEnabled. - */ - FALLBACK( mmesa, MACH64_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - break; - - case GL_CULL_FACE: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_CULL; - break; - - case GL_DEPTH_TEST: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_DEPTH; - break; - - case GL_DITHER: - do { - GLuint s = mmesa->setup.scale_3d_cntl; - FLUSH_BATCH( mmesa ); - - if ( ctx->Color.DitherFlag ) { - /* Dithering causes problems w/ 24bpp depth */ - if ( mmesa->mach64Screen->cpp == 4 ) - s |= MACH64_ROUND_EN; - else - s |= MACH64_DITHER_EN; - } else { - s &= ~MACH64_DITHER_EN; - s &= ~MACH64_ROUND_EN; - } - - if ( mmesa->setup.scale_3d_cntl != s ) { - mmesa->setup.scale_3d_cntl = s; - mmesa->dirty |= ( MACH64_UPLOAD_SCALE_3D_CNTL ); - } - } while (0); - break; - - case GL_FOG: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_FOG; - break; - - case GL_INDEX_LOGIC_OP: - case GL_COLOR_LOGIC_OP: - FLUSH_BATCH( mmesa ); - FALLBACK( mmesa, MACH64_FALLBACK_LOGICOP, - state && ctx->Color.LogicOp != GL_COPY ); - break; - - case GL_LIGHTING: - mach64UpdateSpecularLighting(ctx); - break; - - case GL_SCISSOR_TEST: - FLUSH_BATCH( mmesa ); - mmesa->scissor = state; - mmesa->new_state |= MACH64_NEW_CLIP; - break; - - case GL_STENCIL_TEST: - FLUSH_BATCH( mmesa ); - FALLBACK( mmesa, MACH64_FALLBACK_STENCIL, state ); - break; - - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_TEXTURE; - break; - - default: - return; - } -} - -/* ============================================================= - * Render mode - */ - -static void mach64DDRenderMode( struct gl_context *ctx, GLenum mode ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - FALLBACK( mmesa, MACH64_FALLBACK_RENDER_MODE, (mode != GL_RENDER) ); -} - -/* ============================================================= - * State initialization, management - */ - -static void mach64DDPrintDirty( const char *msg, GLuint state ) -{ - fprintf( stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s\n", - msg, - state, - (state & MACH64_UPLOAD_DST_OFF_PITCH) ? "dst_off_pitch, " : "", - (state & MACH64_UPLOAD_Z_ALPHA_CNTL) ? "z_alpha_cntl, " : "", - (state & MACH64_UPLOAD_SCALE_3D_CNTL) ? "scale_3d_cntl, " : "", - (state & MACH64_UPLOAD_DP_FOG_CLR) ? "dp_fog_clr, " : "", - (state & MACH64_UPLOAD_DP_WRITE_MASK) ? "dp_write_mask, " : "", - (state & MACH64_UPLOAD_DP_PIX_WIDTH) ? "dp_pix_width, " : "", - (state & MACH64_UPLOAD_SETUP_CNTL) ? "setup_cntl, " : "", - (state & MACH64_UPLOAD_MISC) ? "misc, " : "", - (state & MACH64_UPLOAD_TEXTURE) ? "texture, " : "", - (state & MACH64_UPLOAD_TEX0IMAGE) ? "tex0 image, " : "", - (state & MACH64_UPLOAD_TEX1IMAGE) ? "tex1 image, " : "", - (state & MACH64_UPLOAD_CLIPRECTS) ? "cliprects, " : "" ); -} - -/* - * 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 mach64EmitHwStateLocked( mach64ContextPtr mmesa ) -{ - drm_mach64_sarea_t *sarea = mmesa->sarea; - drm_mach64_context_regs_t *regs = &(mmesa->setup); - mach64TexObjPtr t0 = mmesa->CurrentTexObj[0]; - mach64TexObjPtr t1 = mmesa->CurrentTexObj[1]; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) { - mach64DDPrintDirty( __FUNCTION__, mmesa->dirty ); - } - - if ( t0 && t1 && mmesa->mach64Screen->numTexHeaps > 1 ) { - if (t0->heap != t1->heap || - (mmesa->dirty & MACH64_UPLOAD_TEX0IMAGE) || - (mmesa->dirty & MACH64_UPLOAD_TEX1IMAGE)) - mach64UploadMultiTexImages( mmesa, t0, t1 ); - } else { - if ( mmesa->dirty & MACH64_UPLOAD_TEX0IMAGE ) { - if ( t0 ) mach64UploadTexImages( mmesa, t0 ); - } - if ( mmesa->dirty & MACH64_UPLOAD_TEX1IMAGE ) { - if ( t1 ) mach64UploadTexImages( mmesa, t1 ); - } - } - - if ( mmesa->dirty & (MACH64_UPLOAD_CONTEXT | MACH64_UPLOAD_MISC) ) { - memcpy( &sarea->context_state, regs, - MACH64_NR_CONTEXT_REGS * sizeof(GLuint) ); - } - - if ( mmesa->dirty & MACH64_UPLOAD_TEXTURE ) { - mach64EmitTexStateLocked( mmesa, t0, t1 ); - } - - sarea->vertsize = mmesa->vertex_size; - - /* Turn off the texture cache flushing. - */ - mmesa->setup.tex_cntl &= ~MACH64_TEX_CACHE_FLUSH; - - sarea->dirty |= mmesa->dirty; - - mmesa->dirty &= MACH64_UPLOAD_CLIPRECTS; -} - -static void mach64DDPrintState( const char *msg, GLuint flags ) -{ - fprintf( stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n", - msg, - flags, - (flags & MACH64_NEW_CONTEXT) ? "context, " : "", - (flags & MACH64_NEW_ALPHA) ? "alpha, " : "", - (flags & MACH64_NEW_DEPTH) ? "depth, " : "", - (flags & MACH64_NEW_FOG) ? "fog, " : "", - (flags & MACH64_NEW_CLIP) ? "clip, " : "", - (flags & MACH64_NEW_TEXTURE) ? "texture, " : "", - (flags & MACH64_NEW_CULL) ? "cull, " : "", - (flags & MACH64_NEW_MASKS) ? "masks, " : "", - (flags & MACH64_NEW_WINDOW) ? "window, " : "" ); -} - -/* Update the hardware state */ -void mach64DDUpdateHWState( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - int new_state = mmesa->new_state; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) { - fprintf( stderr, "%s:\n", __FUNCTION__ ); - } - - if ( new_state ) - { - FLUSH_BATCH( mmesa ); - - mmesa->new_state = 0; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) - mach64DDPrintState( __FUNCTION__, new_state ); - - /* Update the various parts of the context's state. - */ - if ( new_state & MACH64_NEW_ALPHA ) - mach64UpdateAlphaMode( ctx ); - - if ( new_state & MACH64_NEW_DEPTH ) - mach64UpdateZMode( ctx ); - - if ( new_state & MACH64_NEW_FOG ) - mach64UpdateFogAttrib( ctx ); - - if ( new_state & MACH64_NEW_CLIP ) - mach64UpdateClipping( ctx ); - - if ( new_state & MACH64_NEW_WINDOW ) - mach64CalcViewport( ctx ); - - if ( new_state & MACH64_NEW_CULL ) - mach64UpdateCull( ctx ); - - if ( new_state & MACH64_NEW_MASKS ) - mach64UpdateMasks( ctx ); - - if ( new_state & MACH64_NEW_TEXTURE ) - mach64UpdateTextureState( ctx ); - } -} - - -static void mach64DDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - MACH64_CONTEXT(ctx)->NewGLState |= new_state; -} - - -/* Initialize the context's hardware state */ -void mach64DDInitState( mach64ContextPtr mmesa ) -{ - GLuint format; - - switch ( mmesa->mach64Screen->cpp ) { - case 2: - format = MACH64_DATATYPE_RGB565; - break; - case 4: - format = MACH64_DATATYPE_ARGB8888; - break; - default: - fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" ); - exit( -1 ); - } - - /* Always have a 16-bit depth buffer - * but Z coordinates are specified in 16.1 format to the setup engine. - */ - mmesa->depth_scale = 2.0; - - mmesa->ClearColor = 0x00000000; - mmesa->ClearDepth = 0x0000ffff; - - mmesa->Fallback = 0; - - if ( mmesa->glCtx->Visual.doubleBufferMode ) { - mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->backOffset; - mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->backPitch; - } else { - mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->frontOffset; - mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->frontPitch; - } - - /* Harware state: - */ - mmesa->setup.dst_off_pitch = (((mmesa->drawPitch/8) << 22) | - (mmesa->drawOffset >> 3)); - - mmesa->setup.z_off_pitch = (((mmesa->mach64Screen->depthPitch/8) << 22) | - (mmesa->mach64Screen->depthOffset >> 3)); - - mmesa->setup.z_cntl = (MACH64_Z_TEST_LESS | - MACH64_Z_MASK_EN); - - mmesa->setup.alpha_tst_cntl = (MACH64_ALPHA_TEST_ALWAYS | - MACH64_ALPHA_DST_SRCALPHA | - MACH64_ALPHA_TST_SRC_TEXEL | - (0 << MACH64_REF_ALPHA_SHIFT)); - - mmesa->setup.scale_3d_cntl = (MACH64_SCALE_PIX_EXPAND_DYNAMIC_RANGE | - /* MACH64_SCALE_DITHER_ERROR_DIFFUSE | */ - MACH64_SCALE_DITHER_2D_TABLE | - /* MACH64_DITHER_INIT_CURRENT | */ - MACH64_DITHER_INIT_RESET | - MACH64_SCALE_3D_FCN_SHADE | - MACH64_ALPHA_FOG_DIS | - MACH64_ALPHA_BLEND_SRC_ONE | - MACH64_ALPHA_BLEND_DST_ZERO | - MACH64_TEX_LIGHT_FCN_MODULATE | - MACH64_MIP_MAP_DISABLE | - MACH64_BILINEAR_TEX_EN | - MACH64_TEX_BLEND_FCN_LINEAR); - - /* GL spec says dithering initially enabled, but dithering causes - * problems w/ 24bpp depth - */ - if ( mmesa->mach64Screen->cpp == 4 ) - mmesa->setup.scale_3d_cntl |= MACH64_ROUND_EN; - else - mmesa->setup.scale_3d_cntl |= MACH64_DITHER_EN; - - mmesa->setup.sc_left_right = 0x1fff0000; - mmesa->setup.sc_top_bottom = 0x3fff0000; - - mmesa->setup.dp_fog_clr = 0x00ffffff; - mmesa->setup.dp_write_mask = 0xffffffff; - - mmesa->setup.dp_pix_width = ((format << 0) | - (format << 4) | - (format << 8) | - (format << 16) | - (format << 28)); - - mmesa->setup.dp_mix = (MACH64_BKGD_MIX_S | - MACH64_FRGD_MIX_S); - mmesa->setup.dp_src = (MACH64_BKGD_SRC_3D | - MACH64_FRGD_SRC_3D | - MACH64_MONO_SRC_ONE); - - mmesa->setup.clr_cmp_cntl = 0x00000000; - mmesa->setup.gui_traj_cntl = (MACH64_DST_X_LEFT_TO_RIGHT | - MACH64_DST_Y_TOP_TO_BOTTOM); - - mmesa->setup.setup_cntl = (MACH64_FLAT_SHADE_OFF | - MACH64_SOLID_MODE_OFF | - MACH64_LOG_MAX_INC_ADJ); - mmesa->setup.setup_cntl = 0; - - mmesa->setup.tex_size_pitch = 0x00000000; - - mmesa->setup.tex_cntl = ((0 << MACH64_LOD_BIAS_SHIFT) | - (0 << MACH64_COMP_FACTOR_SHIFT) | - MACH64_COMP_COMBINE_MODULATE | - MACH64_COMP_BLEND_NEAREST | - MACH64_COMP_FILTER_NEAREST | - /* MACH64_TEXTURE_TILING | */ -#ifdef MACH64_PREMULT_TEXCOORDS - MACH64_TEX_ST_DIRECT | -#endif - MACH64_TEX_SRC_LOCAL | - MACH64_TEX_UNCOMPRESSED | - MACH64_TEX_CACHE_FLUSH | - MACH64_TEX_CACHE_SIZE_4K); - - mmesa->setup.secondary_tex_off = 0x00000000; - mmesa->setup.tex_offset = 0x00000000; - - mmesa->new_state = MACH64_NEW_ALL; -} - -/* Initialize the driver's state functions. - */ -void mach64DDInitStateFuncs( struct gl_context *ctx ) -{ - ctx->Driver.UpdateState = mach64DDInvalidateState; - - ctx->Driver.ClearColor = mach64DDClearColor; - ctx->Driver.DrawBuffer = mach64DDDrawBuffer; - ctx->Driver.ReadBuffer = mach64DDReadBuffer; - - ctx->Driver.ColorMask = mach64DDColorMask; - ctx->Driver.AlphaFunc = mach64DDAlphaFunc; - ctx->Driver.BlendEquationSeparate = mach64DDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = mach64DDBlendFuncSeparate; - ctx->Driver.ClearDepth = mach64DDClearDepth; - ctx->Driver.CullFace = mach64DDCullFace; - ctx->Driver.FrontFace = mach64DDFrontFace; - ctx->Driver.DepthFunc = mach64DDDepthFunc; - ctx->Driver.DepthMask = mach64DDDepthMask; - ctx->Driver.Enable = mach64DDEnable; - ctx->Driver.Fogfv = mach64DDFogfv; - ctx->Driver.Hint = NULL; - ctx->Driver.Lightfv = NULL; - ctx->Driver.LightModelfv = mach64DDLightModelfv; - ctx->Driver.LogicOpcode = mach64DDLogicOpCode; - ctx->Driver.PolygonMode = NULL; - ctx->Driver.PolygonStipple = NULL; - ctx->Driver.RenderMode = mach64DDRenderMode; - ctx->Driver.Scissor = mach64DDScissor; - ctx->Driver.ShadeModel = mach64DDShadeModel; - - ctx->Driver.DepthRange = mach64DepthRange; - ctx->Driver.Viewport = mach64Viewport; -} diff --git a/src/mesa/drivers/dri/mach64/mach64_state.h b/src/mesa/drivers/dri/mach64/mach64_state.h deleted file mode 100644 index 41c4d01d1df..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_state.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - */ - -#ifndef __MACH64_STATE_H__ -#define __MACH64_STATE_H__ - -#include "mach64_context.h" - -extern void mach64DDInitState( mach64ContextPtr mmesa ); -extern void mach64DDInitStateFuncs( struct gl_context *ctx ); - -extern void mach64SetCliprects( struct gl_context *ctx, GLenum mode ); -extern void mach64CalcViewport( struct gl_context *ctx ); - -extern void mach64DDUpdateState( struct gl_context *ctx ); -extern void mach64DDUpdateHWState( struct gl_context *ctx ); - -extern void mach64EmitHwStateLocked( mach64ContextPtr mmesa ); - -#endif diff --git a/src/mesa/drivers/dri/mach64/mach64_tex.c b/src/mesa/drivers/dri/mach64/mach64_tex.c deleted file mode 100644 index 8e10b314b64..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_tex.c +++ /dev/null @@ -1,563 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_tex.h" - -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/texstore.h" -#include "main/teximage.h" -#include "main/texobj.h" -#include "main/imports.h" - - -static void mach64SetTexWrap( mach64TexObjPtr t, - GLenum swrap, GLenum twrap ) -{ - switch ( swrap ) { - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - case GL_CLAMP_TO_BORDER: - t->ClampS = GL_TRUE; - break; - case GL_REPEAT: - t->ClampS = GL_FALSE; - break; - } - - switch ( twrap ) { - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - case GL_CLAMP_TO_BORDER: - t->ClampT = GL_TRUE; - break; - case GL_REPEAT: - t->ClampT = GL_FALSE; - break; - } -} - -static void mach64SetTexFilter( mach64TexObjPtr t, - GLenum minf, GLenum magf ) -{ - switch ( minf ) { - case GL_NEAREST: - case GL_NEAREST_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - t->BilinearMin = GL_FALSE; - break; - case GL_LINEAR: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_LINEAR: - t->BilinearMin = GL_TRUE; - break; - } - - switch ( magf ) { - case GL_NEAREST: - t->BilinearMag = GL_FALSE; - break; - case GL_LINEAR: - t->BilinearMag = GL_TRUE; - break; - } -} - -static void mach64SetTexBorderColor( mach64TexObjPtr t, const GLfloat c[4] ) -{ -#if 0 - GLuint border = mach64PackColor( 4, c[0], c[1], c[2], c[3] ); -#endif -} - - -static mach64TexObjPtr -mach64AllocTexObj( struct gl_texture_object *texObj ) -{ - mach64TexObjPtr t; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) - fprintf( stderr, "%s( %p )\n", __FUNCTION__, texObj ); - - t = (mach64TexObjPtr) CALLOC_STRUCT( mach64_texture_object ); - texObj->DriverData = t; - if ( !t ) - return NULL; - - /* Initialize non-image-dependent parts of the state: - */ - t->base.tObj = texObj; - t->base.dirty_images[0] = (1 << 0); - - t->bufAddr = 0; - - make_empty_list( (driTextureObject *) t ); - - mach64SetTexWrap( t, texObj->Sampler.WrapS, texObj->Sampler.WrapT ); - mach64SetTexFilter( t, texObj->Sampler.MinFilter, texObj->Sampler.MagFilter ); - mach64SetTexBorderColor( t, texObj->Sampler.BorderColor.f ); - - return t; -} - - -/* Called by the _mesa_store_teximage[123]d() functions. */ -static gl_format -mach64ChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - (void) format; - (void) type; - - switch ( internalFormat ) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - case 2: - case GL_LUMINANCE_ALPHA: - 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 GL_COMPRESSED_LUMINANCE_ALPHA: - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_COMPRESSED_RGBA: - if (mmesa->mach64Screen->cpp == 4) - return MESA_FORMAT_ARGB8888; - else - return MESA_FORMAT_ARGB4444; - - case GL_RGB5_A1: - if (mmesa->mach64Screen->cpp == 4) - return MESA_FORMAT_ARGB8888; - else - return MESA_FORMAT_ARGB1555; - - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - case GL_RGBA4: - if (mmesa->mach64Screen->cpp == 4) - return MESA_FORMAT_ARGB8888; - else - return MESA_FORMAT_ARGB4444; - - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - case GL_COMPRESSED_RGB: - if (mmesa->mach64Screen->cpp == 4) - return MESA_FORMAT_ARGB8888; - else - return MESA_FORMAT_RGB565; - - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - if (mmesa->mach64Screen->cpp == 4) - return MESA_FORMAT_ARGB8888; /* inefficient but accurate */ - else - return MESA_FORMAT_ARGB1555; - - case GL_INTENSITY4: - case GL_INTENSITY: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - if (mmesa->mach64Screen->cpp == 4) - return MESA_FORMAT_ARGB8888; /* inefficient but accurate */ - else - return MESA_FORMAT_ARGB4444; - - 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_FORMAT_CI8; - - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_APPLE || - type == GL_UNSIGNED_BYTE) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - - default: - _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ ); - return MESA_FORMAT_NONE; - } -} - -static void mach64TexImage1D( struct gl_context *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 ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) mach64AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - return; - } - } - - /* Note, this will call mach64ChooseTextureFormat */ - _mesa_store_teximage1d( ctx, target, level, internalFormat, - width, border, format, type, - pixels, packing, texObj, texImage ); - - mmesa->new_state |= MACH64_NEW_TEXTURE; -} - -static void mach64TexSubImage1D( struct gl_context *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 ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - assert( t ); /* this _should_ be true */ - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) mach64AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); - return; - } - } - - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, packing, texObj, - texImage); - - mmesa->new_state |= MACH64_NEW_TEXTURE; -} - -static void mach64TexImage2D( struct gl_context *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 ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) mach64AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - - /* Note, this will call mach64ChooseTextureFormat */ - _mesa_store_teximage2d( ctx, target, level, internalFormat, - width, height, border, format, type, pixels, - &ctx->Unpack, texObj, texImage ); - - mmesa->new_state |= MACH64_NEW_TEXTURE; -} - -static void mach64TexSubImage2D( struct gl_context *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 ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - assert( t ); /* this _should_ be true */ - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) mach64AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - return; - } - } - - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); - - mmesa->new_state |= MACH64_NEW_TEXTURE; -} - -/* ================================================================ - * Device Driver API texture functions - */ - -static void mach64DDTexEnv( struct gl_context *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); -#if 0 - struct gl_texture_unit *texUnit; - GLubyte c[4]; -#endif - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %s )\n", - __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) ); - } - - switch ( pname ) { - case GL_TEXTURE_ENV_MODE: - FLUSH_BATCH( mmesa ); - mmesa->new_state |= MACH64_NEW_TEXTURE | MACH64_NEW_ALPHA; - break; - -#if 0 - case GL_TEXTURE_ENV_COLOR: - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - 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] ); - mmesa->env_color = mach64PackColor( 32, c[0], c[1], c[2], c[3] ); - if ( mmesa->setup.constant_color_c != mmesa->env_color ) { - FLUSH_BATCH( mmesa ); - mmesa->setup.constant_color_c = mmesa->env_color; - - mmesa->new_state |= MACH64_NEW_TEXTURE; - - /* More complex multitexture/multipass fallbacks for GL_BLEND - * can be done later, but this allows a single pass GL_BLEND - * in some cases (ie. Performer town demo). - */ - mmesa->blend_flags &= ~MACH64_BLEND_ENV_COLOR; - if ( mmesa->env_color != 0x00000000 && - mmesa->env_color != 0xff000000 && - mmesa->env_color != 0x00ffffff && - mmesa->env_color != 0xffffffff )) { - mmesa->blend_flags |= MACH64_BLEND_ENV_COLOR; - } - } - break; -#endif - - default: - return; - } -} - -static void mach64DDTexParameter( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - mach64TexObjPtr t = (mach64TexObjPtr)tObj->DriverData; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %s )\n", - __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) ); - } - - if ( ( target != GL_TEXTURE_2D ) && - ( target != GL_TEXTURE_1D ) ) { - return; - } - - if (!t) { - t = mach64AllocTexObj(tObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexParameter"); - return; - } - } - - switch ( pname ) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - if ( t->base.bound ) FLUSH_BATCH( mmesa ); - mach64SetTexFilter( t, tObj->Sampler.MinFilter, tObj->Sampler.MagFilter ); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - if ( t->base.bound ) FLUSH_BATCH( mmesa ); - mach64SetTexWrap( t, tObj->Sampler.WrapS, tObj->Sampler.WrapT ); - break; - - case GL_TEXTURE_BORDER_COLOR: - if ( t->base.bound ) FLUSH_BATCH( mmesa ); - mach64SetTexBorderColor( t, tObj->Sampler.BorderColor.f ); - break; - - case GL_TEXTURE_BASE_LEVEL: - /* From Radeon/Rage128: - * This isn't the most efficient solution but there doesn't appear to - * be a nice alternative. Since there's no LOD clamping, - * we just have to rely on loading the right subset of mipmap levels - * to simulate a clamped LOD. - * - * For mach64 we're only concerned with the base level - * since that's the only texture we upload. - */ - if ( t->base.bound ) FLUSH_BATCH( mmesa ); - driSwapOutTextureObject( (driTextureObject *) t ); - break; - - default: - return; - } - - mmesa->new_state |= MACH64_NEW_TEXTURE; -} - -static void mach64DDBindTexture( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLint unit = ctx->Texture.CurrentUnit; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p ) unit=%d\n", - __FUNCTION__, tObj, unit ); - } - - FLUSH_BATCH( mmesa ); - - if ( mmesa->CurrentTexObj[unit] ) { - mmesa->CurrentTexObj[unit]->base.bound &= ~(1 << unit); - mmesa->CurrentTexObj[unit] = NULL; - } - - mmesa->new_state |= MACH64_NEW_TEXTURE; -} - -static void mach64DDDeleteTexture( struct gl_context *ctx, - struct gl_texture_object *tObj ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - driTextureObject * t = (driTextureObject *) tObj->DriverData; - - if ( t ) { - if ( t->bound && mmesa ) { - FLUSH_BATCH( mmesa ); - - mmesa->new_state |= MACH64_NEW_TEXTURE; - } - - driDestroyTextureObject( t ); - - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); - } -} - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -mach64NewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - mach64AllocTexObj( obj ); - return obj; -} - -void mach64InitTextureFuncs( struct dd_function_table *functions ) -{ - functions->TexEnv = mach64DDTexEnv; - functions->ChooseTextureFormat = mach64ChooseTextureFormat; - functions->TexImage1D = mach64TexImage1D; - functions->TexSubImage1D = mach64TexSubImage1D; - functions->TexImage2D = mach64TexImage2D; - functions->TexSubImage2D = mach64TexSubImage2D; - functions->TexParameter = mach64DDTexParameter; - functions->BindTexture = mach64DDBindTexture; - functions->NewTextureObject = mach64NewTextureObject; - functions->DeleteTexture = mach64DDDeleteTexture; - functions->IsTextureResident = driIsTextureResident; - - driInitTextureFormats(); -} diff --git a/src/mesa/drivers/dri/mach64/mach64_tex.h b/src/mesa/drivers/dri/mach64/mach64_tex.h deleted file mode 100644 index 03699828538..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_tex.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#ifndef __MACH64_TEX_H__ -#define __MACH64_TEX_H__ - -extern void mach64UpdateTextureState( struct gl_context *ctx ); - -extern void mach64UploadTexImages( mach64ContextPtr mach64ctx, - mach64TexObjPtr t ); - -extern void mach64UploadMultiTexImages( mach64ContextPtr mach64ctx, - mach64TexObjPtr t0, mach64TexObjPtr t1 ); - -extern void mach64DestroyTexObj( mach64ContextPtr mach64ctx, - mach64TexObjPtr t ); - -extern void mach64EmitTexStateLocked( mach64ContextPtr mmesa, - mach64TexObjPtr t0, - mach64TexObjPtr t1 ); - -extern void mach64InitTextureFuncs( struct dd_function_table *functions ); - -/* ================================================================ - * Color conversion macros: - */ - -#define MACH64PACKCOLOR332(r, g, b) \ - (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6)) - -#define MACH64PACKCOLOR1555(r, g, b, a) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define MACH64PACKCOLOR565(r, g, b) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define MACH64PACKCOLOR888(r, g, b) \ - (((r) << 16) | ((g) << 8) | (b)) - -#define MACH64PACKCOLOR8888(r, g, b, a) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define MACH64PACKCOLOR4444(r, g, b, a) \ - ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4)) - -static INLINE GLuint mach64PackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return MACH64PACKCOLOR565( r, g, b ); - case 4: - return MACH64PACKCOLOR8888( r, g, b, a ); - default: - return 0; - } -} - -#endif diff --git a/src/mesa/drivers/dri/mach64/mach64_texmem.c b/src/mesa/drivers/dri/mach64/mach64_texmem.c deleted file mode 100644 index b09954ce235..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_texmem.c +++ /dev/null @@ -1,511 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jose Fonseca <[email protected]> - */ - -#include "main/context.h" -#include "main/macros.h" -#include "main/simple_list.h" -#include "main/imports.h" - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_tex.h" - - -/* Destroy hardware state associated with texture `t'. - */ -void mach64DestroyTexObj( mach64ContextPtr mmesa, mach64TexObjPtr t ) -{ - unsigned i; - - /* See if it was the driver's current object. - */ - if ( mmesa != NULL ) - { - for ( i = 0 ; i < mmesa->glCtx->Const.MaxTextureUnits ; i++ ) - { - if ( t == mmesa->CurrentTexObj[ i ] ) { - assert( t->base.bound & (1 << i) ); - mmesa->CurrentTexObj[ i ] = NULL; - } - } - } -} - -/* Upload the texture image associated with texture `t' at level `level' - * at the address relative to `start'. - */ -static void mach64UploadAGPSubImage( mach64ContextPtr mmesa, - mach64TexObjPtr t, int level, - int x, int y, int width, int height ) -{ - mach64ScreenRec *mach64Screen = mmesa->mach64Screen; - struct gl_texture_image *image; - int texelsPerDword = 0; - int dwords; - GLuint texelBytes; - - /* Ensure we have a valid texture to upload */ - if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) ) - return; - - image = t->base.tObj->Image[0][level]; - if ( !image ) - return; - - texelBytes = _mesa_get_format_bytes(image->TexFormat); - - switch ( 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 - - dwords = width * height / texelsPerDword; - -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - mmesa->c_agpTextureBytes += (dwords << 2); -#endif - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "mach64UploadSubImage: %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\n", - (GLuint)t->bufAddr, (GLint)width, dwords ); - } - - assert(image->Data); - - { - CARD32 *dst = (CARD32 *)((char *)mach64Screen->agpTextures.map + t->base.memBlock->ofs); - const GLubyte *src = (const GLubyte *) image->Data + - (y * image->Width + x) * texelBytes; - const GLuint bytes = width * height * texelBytes; - memcpy(dst, src, bytes); - } - -} - -/* Upload the texture image associated with texture `t' at level `level' - * at the address relative to `start'. - */ -static void mach64UploadLocalSubImage( mach64ContextPtr mmesa, - mach64TexObjPtr 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; - const int maxdwords = (MACH64_BUFFER_MAX_DWORDS - (MACH64_HOSTDATA_BLIT_OFFSET / 4)); - CARD32 pitch, offset; - int i; - GLuint texelBytes; - - /* Ensure we have a valid texture to upload */ - if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) ) - return; - - image = t->base.tObj->Image[0][level]; - if ( !image ) - return; - - texelBytes = _mesa_get_format_bytes(image->TexFormat); - - switch ( 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; - - /* 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 64 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 >= 64 ) { - /* The texture walker and the blitter look identical */ - pitch = imageWidth >> 3; - } else { - int factor; - int y2; - int start, end; - - start = (y * imageWidth) & ~63; - end = (y + height) * imageWidth; - - if ( end - start < 64 ) { - /* Handle the case where the total number of texels - * uploaded is < 64. - */ - x = 0; - y = start / 64; - width = end - start; - height = 1; - } else { - /* Upload some number of full 64 texel blit rows */ - factor = 64 / imageWidth; - - y2 = y + height - 1; - y /= factor; - y2 /= factor; - - x = 0; - width = 64; - height = y2 - y + 1; - } - - /* Fixed pitch of 64 */ - pitch = 8; - } - - dwords = width * height / texelsPerDword; - offset = t->bufAddr; - -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - mmesa->c_textureBytes += (dwords << 2); -#endif - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "mach64UploadSubImage: %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\n", - (GLuint)offset, (GLint)width, dwords ); - } - - /* Subdivide the texture if required (account for the registers added by the drm) */ - if ( dwords <= maxdwords ) { - rows = height; - } else { - rows = (maxdwords * texelsPerDword) / (2 * width); - } - - for ( i = 0, remaining = height ; - remaining > 0 ; - remaining -= rows, y += rows, i++ ) - { - height = MIN2(remaining, rows); - - assert(image->Data); - - { - const GLubyte *src = (const GLubyte *) image->Data + - (y * image->Width + x) * texelBytes; - - mach64FireBlitLocked( mmesa, (void *)src, offset, pitch, format, - x, y, width, height ); - } - - } - - mmesa->new_state |= MACH64_NEW_CONTEXT; - mmesa->dirty |= MACH64_UPLOAD_CONTEXT | MACH64_UPLOAD_MISC; -} - - -/* 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. - */ -void mach64UploadTexImages( mach64ContextPtr mmesa, mach64TexObjPtr t ) -{ - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p, %p )\n", - __FUNCTION__, mmesa->glCtx, t ); - } - - assert(t); - assert(t->base.tObj); - - if ( !t->base.memBlock ) { - int heap; - - /* NULL heaps are skipped */ - heap = driAllocateTexture( mmesa->texture_heaps, MACH64_NR_TEX_HEAPS, - (driTextureObject *) t ); - - if ( heap == -1 ) { - fprintf( stderr, "%s: upload texture failure, sz=%d\n", __FUNCTION__, - t->base.totalSize ); - exit(-1); - return; - } - - t->heap = heap; - - /* Set the base offset of the texture image */ - assert(t->base.memBlock); - t->bufAddr = mmesa->mach64Screen->texOffset[heap] + t->base.memBlock->ofs; - - /* Force loading the new state into the hardware */ - mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL | - MACH64_UPLOAD_TEXTURE); - } - - /* Let the world know we've used this memory recently */ - driUpdateTextureLRU( (driTextureObject *) t ); - - /* Upload any images that are new */ - if ( t->base.dirty_images[0] ) { - const GLint j = t->base.tObj->BaseLevel; - if (t->heap == MACH64_AGP_HEAP) { - /* Need to make sure any vertex buffers in the queue complete */ - mach64WaitForIdleLocked( mmesa ); - mach64UploadAGPSubImage( mmesa, t, j, 0, 0, - t->base.tObj->Image[0][j]->Width, - t->base.tObj->Image[0][j]->Height ); - } else { - mach64UploadLocalSubImage( mmesa, t, j, 0, 0, - t->base.tObj->Image[0][j]->Width, - t->base.tObj->Image[0][j]->Height ); - } - - mmesa->setup.tex_cntl |= MACH64_TEX_CACHE_FLUSH; - t->base.dirty_images[0] = 0; - } - - mmesa->dirty |= MACH64_UPLOAD_TEXTURE; -} - - -/* Allocate memory from the same texture heap `heap' for both textures - * `u0' and `u1'. - */ -static int mach64AllocateMultiTex( mach64ContextPtr mmesa, - mach64TexObjPtr u0, - mach64TexObjPtr u1, - int heap, GLboolean alloc_u0 ) -{ - /* Both objects should be bound */ - assert( u0->base.bound && u1->base.bound ); - - if ( alloc_u0 ) { - /* Evict u0 from its current heap */ - if ( u0->base.memBlock ) { - assert( u0->heap != heap ); - driSwapOutTextureObject( (driTextureObject *) u0 ); - } - - /* Try to allocate u0 in the chosen heap */ - u0->heap = driAllocateTexture( &mmesa->texture_heaps[heap], 1, - (driTextureObject *) u0 ); - - if ( u0->heap == -1 ) { - return -1; - } - } - - /* Evict u1 from its current heap */ - if ( u1->base.memBlock ) { - assert( u1->heap != heap ); - driSwapOutTextureObject( (driTextureObject *) u1 ); - } - - /* Try to allocate u1 in the same heap as u0 */ - u1->heap = driAllocateTexture( &mmesa->texture_heaps[heap], 1, - (driTextureObject *) u1 ); - - if ( u1->heap == -1 ) { - return -1; - } - - /* Bound objects are not evicted */ - assert( u0->base.memBlock && u1->base.memBlock ); - assert( u0->heap == u1->heap ); - - return heap; -} - -/* The mach64 needs to have both primary and secondary textures in either - * local or AGP memory, so we need a "buddy system" to make sure that allocation - * succeeds or fails for both textures. - */ -void mach64UploadMultiTexImages( mach64ContextPtr mmesa, - mach64TexObjPtr t0, - mach64TexObjPtr t1 ) -{ - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p, %p %p )\n", - __FUNCTION__, mmesa->glCtx, t0, t1 ); - } - - assert(t0 && t1); - assert(t0->base.tObj && t1->base.tObj); - - if ( !t0->base.memBlock || !t1->base.memBlock || t0->heap != t1->heap ) { - mach64TexObjPtr u0 = NULL; - mach64TexObjPtr u1 = NULL; - unsigned totalSize = t0->base.totalSize + t1->base.totalSize; - - int heap, ret; - - /* Check if one of the textures is already swapped in a heap and the - * other texture fits in that heap. - */ - if ( t0->base.memBlock && totalSize <= t0->base.heap->size ) { - u0 = t0; - u1 = t1; - } else if ( t1->base.memBlock && totalSize <= t1->base.heap->size ) { - u0 = t1; - u1 = t0; - } - - if ( u0 ) { - heap = u0->heap; - - ret = mach64AllocateMultiTex( mmesa, u0, u1, heap, GL_FALSE ); - } else { - /* Both textures are swapped out or collocation is impossible */ - u0 = t0; - u1 = t1; - - /* Choose the heap appropriately */ - heap = MACH64_CARD_HEAP; - - if ( totalSize > mmesa->texture_heaps[heap]->size ) { - heap = MACH64_AGP_HEAP; - } - - ret = mach64AllocateMultiTex( mmesa, u0, u1, heap, GL_TRUE ); - } - - if ( ret == -1 && heap == MACH64_CARD_HEAP ) { - /* Try AGP if local memory failed */ - heap = MACH64_AGP_HEAP; - - ret = mach64AllocateMultiTex( mmesa, u0, u1, heap, GL_TRUE ); - } - - if ( ret == -1 ) { - /* FIXME: - * Swap out all textures from the AGP heap and re-run allocation, this - * should succeed in all cases. - */ - fprintf( stderr, "%s: upload multi-texture failure, sz0=%d sz1=%d\n", - __FUNCTION__, t0->base.totalSize, t1->base.totalSize ); - exit(-1); - } - - /* Set the base offset of the texture image */ - assert(t0->base.memBlock); - t0->bufAddr = mmesa->mach64Screen->texOffset[heap] + t0->base.memBlock->ofs; - assert(t1->base.memBlock); - t1->bufAddr = mmesa->mach64Screen->texOffset[heap] + t1->base.memBlock->ofs; - - /* Force loading the new state into the hardware */ - mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL | - MACH64_UPLOAD_TEXTURE); - } - - /* Let the world know we've used this memory recently */ - driUpdateTextureLRU( (driTextureObject *) t0 ); - driUpdateTextureLRU( (driTextureObject *) t1 ); - - /* Upload any images that are new */ - if ( t0->base.dirty_images[0] ) { - const GLint j0 = t0->base.tObj->BaseLevel; - if (t0->heap == MACH64_AGP_HEAP) { - /* Need to make sure any vertex buffers in the queue complete */ - mach64WaitForIdleLocked( mmesa ); - mach64UploadAGPSubImage( mmesa, t0, j0, 0, 0, - t0->base.tObj->Image[0][j0]->Width, - t0->base.tObj->Image[0][j0]->Height ); - } else { - mach64UploadLocalSubImage( mmesa, t0, j0, 0, 0, - t0->base.tObj->Image[0][j0]->Width, - t0->base.tObj->Image[0][j0]->Height ); - } - mmesa->setup.tex_cntl |= MACH64_TEX_CACHE_FLUSH; - t0->base.dirty_images[0] = 0; - } - if ( t1->base.dirty_images[0] ) { - const GLint j1 = t1->base.tObj->BaseLevel; - if (t1->heap == MACH64_AGP_HEAP) { - /* Need to make sure any vertex buffers in the queue complete */ - mach64WaitForIdleLocked( mmesa ); - mach64UploadAGPSubImage( mmesa, t1, j1, 0, 0, - t1->base.tObj->Image[0][j1]->Width, - t1->base.tObj->Image[0][j1]->Height ); - } else { - mach64UploadLocalSubImage( mmesa, t1, j1, 0, 0, - t1->base.tObj->Image[0][j1]->Width, - t1->base.tObj->Image[0][j1]->Height ); - } - - mmesa->setup.tex_cntl |= MACH64_TEX_CACHE_FLUSH; - t1->base.dirty_images[0] = 0; - } - - mmesa->dirty |= MACH64_UPLOAD_TEXTURE; -} diff --git a/src/mesa/drivers/dri/mach64/mach64_texstate.c b/src/mesa/drivers/dri/mach64/mach64_texstate.c deleted file mode 100644 index 70365c8461f..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_texstate.c +++ /dev/null @@ -1,522 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/context.h" -#include "main/macros.h" - -#include "mach64_context.h" -#include "mach64_ioctl.h" -#include "mach64_tris.h" -#include "mach64_tex.h" - -static void mach64SetTexImages( mach64ContextPtr mmesa, - const struct gl_texture_object *tObj ) -{ - mach64TexObjPtr t = (mach64TexObjPtr) tObj->DriverData; - struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel]; - int totalSize; - - assert(t); - assert(baseImage); - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) - fprintf( stderr, "%s( %p )\n", __FUNCTION__, tObj ); - - switch (baseImage->TexFormat) { - case MESA_FORMAT_ARGB8888: - t->textureFormat = MACH64_DATATYPE_ARGB8888; - break; - case MESA_FORMAT_ARGB4444: - t->textureFormat = MACH64_DATATYPE_ARGB4444; - break; - case MESA_FORMAT_RGB565: - t->textureFormat = MACH64_DATATYPE_RGB565; - break; - case MESA_FORMAT_ARGB1555: - t->textureFormat = MACH64_DATATYPE_ARGB1555; - break; - case MESA_FORMAT_RGB332: - t->textureFormat = MACH64_DATATYPE_RGB332; - break; - case MESA_FORMAT_RGB888: - t->textureFormat = MACH64_DATATYPE_RGB8; - break; - case MESA_FORMAT_CI8: - t->textureFormat = MACH64_DATATYPE_CI8; - break; - case MESA_FORMAT_YCBCR: - t->textureFormat = MACH64_DATATYPE_YVYU422; - break; - case MESA_FORMAT_YCBCR_REV: - t->textureFormat = MACH64_DATATYPE_VYUY422; - break; - default: - _mesa_problem(mmesa->glCtx, "Bad texture format in %s", __FUNCTION__); - }; - - totalSize = ( baseImage->Height * - baseImage->Width * - _mesa_get_format_bytes(baseImage->TexFormat) ); - - totalSize = (totalSize + 31) & ~31; - - t->base.totalSize = totalSize; - t->base.firstLevel = tObj->BaseLevel; - t->base.lastLevel = tObj->BaseLevel; - - /* Set the texture format */ - if ( ( baseImage->_BaseFormat == GL_RGBA ) || - ( baseImage->_BaseFormat == GL_ALPHA ) || - ( baseImage->_BaseFormat == GL_LUMINANCE_ALPHA ) ) { - t->hasAlpha = 1; - } else { - t->hasAlpha = 0; - } - - t->widthLog2 = baseImage->WidthLog2; - t->heightLog2 = baseImage->HeightLog2; - t->maxLog2 = baseImage->MaxLog2; -} - -static void mach64UpdateTextureEnv( struct gl_context *ctx, int unit ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLint source = mmesa->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[0][tObj->BaseLevel]->_BaseFormat; - GLuint s = mmesa->setup.scale_3d_cntl; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p, %d )\n", - __FUNCTION__, ctx, unit ); - } - -/* REPLACE MODULATE DECAL GL_BLEND - * - * ALPHA C = Cf C = Cf undef C = Cf - * A = At A = AfAt A = AfAt - * - * LUMINANCE C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt - * A = Af A = Af A = Af - * - * LUMINANCE_ALPHA C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt - * A = At A = AfAt A = AfAt - * - * INTENSITY C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt - * A = At A = AfAt A = Af(1-At)+AcAt - * - * RGB C = Ct C = CfCt C = Ct C = Cf(1-Ct)+CcCt - * A = Af A = Af A = Af A = Af - * - * RGBA C = Ct C = CfCt C = Cf(1-At)+CtAt C = Cf(1-Ct)+CcCt - * A = At A = AfAt A = Af A = AfAt - */ - - - if ( unit == 0 ) { - s &= ~MACH64_TEX_LIGHT_FCN_MASK; - - /* Set the texture environment state - * Need to verify these are working correctly, but the - * texenv Mesa demo seems to work. - */ - switch ( texUnit->EnvMode ) { - case GL_REPLACE: - switch ( format ) { - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - /* Not compliant - can't get At */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - default: - s |= MACH64_TEX_LIGHT_FCN_REPLACE; - } - break; - case GL_MODULATE: - switch ( format ) { - case GL_ALPHA: - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - case GL_RGB: - case GL_LUMINANCE: - /* These should be compliant */ - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - case GL_RGBA: - /* Should fallback when blending enabled for complete compliance */ - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - default: - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - } - break; - case GL_DECAL: - switch ( format ) { - case GL_RGBA: - s |= MACH64_TEX_LIGHT_FCN_ALPHA_DECAL; - break; - case GL_RGB: - s |= MACH64_TEX_LIGHT_FCN_REPLACE; - break; - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - /* undefined - disable texturing, pass fragment unmodified */ - /* Also, pass fragment alpha instead of texture alpha */ - s &= ~MACH64_TEX_MAP_AEN; - s |= MACH64_TEXTURE_DISABLE; - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - case GL_LUMINANCE: - case GL_INTENSITY: - /* undefined - disable texturing, pass fragment unmodified */ - s |= MACH64_TEXTURE_DISABLE; - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - default: - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - } - break; - case GL_BLEND: - /* GL_BLEND not supported by RagePRO, use software */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - case GL_ADD: - case GL_COMBINE: - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - break; - default: - s |= MACH64_TEX_LIGHT_FCN_MODULATE; - } - - if ( mmesa->setup.scale_3d_cntl != s ) { - mmesa->setup.scale_3d_cntl = s; - mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL; - } - - } else { - /* blend = 0, modulate = 1 - initialize to blend */ - mmesa->setup.tex_cntl &= ~MACH64_COMP_COMBINE_MODULATE; - /* Set the texture composite function for multitexturing*/ - switch ( texUnit->EnvMode ) { - case GL_BLEND: - /* GL_BLEND not supported by RagePRO, use software */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - break; - case GL_MODULATE: - /* Should fallback when blending enabled for complete compliance */ - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - break; - case GL_REPLACE: - switch ( format ) { - case GL_ALPHA: - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - break; - default: /* not supported by RagePRO */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - } - break; - case GL_DECAL: - switch ( format ) { - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - /* undefined, disable compositing and pass fragment unmodified */ - mmesa->setup.tex_cntl &= ~MACH64_TEXTURE_COMPOSITE; - break; - default: /* not supported by RagePRO */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - } - break; - case GL_ADD: - case GL_COMBINE: - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - break; - default: - mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; - } - } -} - - -static void mach64UpdateTextureUnit( struct gl_context *ctx, int unit ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - const struct gl_texture_object *tObj = ctx->Texture.Unit[source]._Current; - mach64TexObjPtr t = tObj->DriverData; - GLuint d = mmesa->setup.dp_pix_width; - GLuint s = mmesa->setup.scale_3d_cntl; - - assert(unit == 0 || unit == 1); /* only two tex units */ - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p, %d ) enabled=0x%x 0x%x\n", - __FUNCTION__, ctx, unit, ctx->Texture.Unit[0]._ReallyEnabled, - ctx->Texture.Unit[1]._ReallyEnabled); - } - - if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) { - - assert(t); /* should have driver tex data by now */ - - /* Fallback if there's a texture border */ - if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) { - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - return; - } - - /* Upload teximages */ - if (t->base.dirty_images[0]) { - mach64SetTexImages( mmesa, tObj ); - mmesa->dirty |= (MACH64_UPLOAD_TEX0IMAGE << unit); - } - - /* Bind to the given texture unit */ - mmesa->CurrentTexObj[unit] = t; - t->base.bound |= (1 << unit); - - if ( t->base.memBlock ) - driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */ - - /* register setup */ - if ( unit == 0 ) { - d &= ~MACH64_SCALE_PIX_WIDTH_MASK; - d |= (t->textureFormat << 28); - - s &= ~(MACH64_TEXTURE_DISABLE | - MACH64_TEX_CACHE_SPLIT | - MACH64_TEX_BLEND_FCN_MASK | - MACH64_TEX_MAP_AEN); - - if ( mmesa->multitex ) { - s |= MACH64_TEX_BLEND_FCN_TRILINEAR | MACH64_TEX_CACHE_SPLIT; - } else if ( t->BilinearMin ) { - s |= MACH64_TEX_BLEND_FCN_LINEAR; - } else { - s |= MACH64_TEX_BLEND_FCN_NEAREST; - } - if ( t->BilinearMag ) { - s |= MACH64_BILINEAR_TEX_EN; - } else { - s &= ~MACH64_BILINEAR_TEX_EN; - } - - if ( t->hasAlpha ) { - s |= MACH64_TEX_MAP_AEN; - } - - mmesa->setup.tex_cntl &= ~(MACH64_TEXTURE_CLAMP_S | - MACH64_TEXTURE_CLAMP_T | - MACH64_SECONDARY_STW); - - if ( t->ClampS ) { - mmesa->setup.tex_cntl |= MACH64_TEXTURE_CLAMP_S; - } - if ( t->ClampT ) { - mmesa->setup.tex_cntl |= MACH64_TEXTURE_CLAMP_T; - } - - mmesa->setup.tex_size_pitch |= ((t->widthLog2 << 0) | - (t->maxLog2 << 4) | - (t->heightLog2 << 8)); - } else { - - /* Enable texture mapping mode */ - s &= ~MACH64_TEXTURE_DISABLE; - - d &= ~MACH64_COMPOSITE_PIX_WIDTH_MASK; - d |= (t->textureFormat << 4); - - mmesa->setup.tex_cntl &= ~(MACH64_COMP_ALPHA | - MACH64_SEC_TEX_CLAMP_S | - MACH64_SEC_TEX_CLAMP_T); - mmesa->setup.tex_cntl |= (MACH64_TEXTURE_COMPOSITE | - MACH64_SECONDARY_STW); - - if ( t->BilinearMin ) { - mmesa->setup.tex_cntl |= MACH64_COMP_BLEND_BILINEAR; - } else { - mmesa->setup.tex_cntl &= ~MACH64_COMP_BLEND_BILINEAR; - } - if ( t->BilinearMag ) { - mmesa->setup.tex_cntl |= MACH64_COMP_FILTER_BILINEAR; - } else { - mmesa->setup.tex_cntl &= ~MACH64_COMP_FILTER_BILINEAR; - } - - if ( t->hasAlpha ) { - mmesa->setup.tex_cntl |= MACH64_COMP_ALPHA; - } - if ( t->ClampS ) { - mmesa->setup.tex_cntl |= MACH64_SEC_TEX_CLAMP_S; - } - if ( t->ClampT ) { - mmesa->setup.tex_cntl |= MACH64_SEC_TEX_CLAMP_T; - } - - mmesa->setup.tex_size_pitch |= ((t->widthLog2 << 16) | - (t->maxLog2 << 20) | - (t->heightLog2 << 24)); - } - - if ( mmesa->setup.scale_3d_cntl != s ) { - mmesa->setup.scale_3d_cntl = s; - mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL; - } - - if ( mmesa->setup.dp_pix_width != d ) { - mmesa->setup.dp_pix_width = d; - mmesa->dirty |= MACH64_UPLOAD_DP_PIX_WIDTH; - } - } - else if (texUnit->_ReallyEnabled) { - /* 3D or cube map texture enabled - fallback */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); - } - else { - /* texture unit disabled */ - } -} - - -/* Update the hardware texture state */ -void mach64UpdateTextureState( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p ) en=0x%x 0x%x\n", - __FUNCTION__, ctx, ctx->Texture.Unit[0]._ReallyEnabled, - ctx->Texture.Unit[1]._ReallyEnabled); - } - - /* Clear any texturing fallbacks */ - FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_FALSE ); - - /* Unbind any currently bound textures */ - if ( mmesa->CurrentTexObj[0] ) mmesa->CurrentTexObj[0]->base.bound = 0; - if ( mmesa->CurrentTexObj[1] ) mmesa->CurrentTexObj[1]->base.bound = 0; - mmesa->CurrentTexObj[0] = NULL; - mmesa->CurrentTexObj[1] = NULL; - - /* Disable all texturing until it is known to be good */ - mmesa->setup.scale_3d_cntl |= MACH64_TEXTURE_DISABLE; - mmesa->setup.scale_3d_cntl &= ~MACH64_TEX_MAP_AEN; - mmesa->setup.tex_cntl &= ~MACH64_TEXTURE_COMPOSITE; - - mmesa->setup.tex_size_pitch = 0x00000000; - - mmesa->tmu_source[0] = 0; - mmesa->tmu_source[1] = 1; - mmesa->multitex = 0; - - if (ctx->Texture._EnabledUnits & 0x2) { - /* unit 1 enabled */ - if (ctx->Texture._EnabledUnits & 0x1) { - /* units 0 and 1 enabled */ - mmesa->multitex = 1; - mach64UpdateTextureUnit( ctx, 0 ); - mach64UpdateTextureEnv( ctx, 0 ); - mach64UpdateTextureUnit( ctx, 1 ); - mach64UpdateTextureEnv( ctx, 1 ); - } else { - mmesa->tmu_source[0] = 1; - mmesa->tmu_source[1] = 0; - mach64UpdateTextureUnit( ctx, 0 ); - mach64UpdateTextureEnv( ctx, 0 ); - } - } else if (ctx->Texture._EnabledUnits & 0x1) { - /* only unit 0 enabled */ - mach64UpdateTextureUnit( ctx, 0 ); - mach64UpdateTextureEnv( ctx, 0 ); - } - - mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL | - MACH64_UPLOAD_TEXTURE); -} - - -/* Due to the way we must program texture state into the Rage Pro, - * we must leave these calculations to the absolute last minute. - */ -void mach64EmitTexStateLocked( mach64ContextPtr mmesa, - mach64TexObjPtr t0, - mach64TexObjPtr t1 ) -{ - drm_mach64_sarea_t *sarea = mmesa->sarea; - drm_mach64_context_regs_t *regs = &(mmesa->setup); - - /* for multitex, both textures must be local or AGP */ - if ( t0 && t1 ) - assert(t0->heap == t1->heap); - - if ( t0 ) { - if (t0->heap == MACH64_CARD_HEAP) { -#if ENABLE_PERF_BOXES - mmesa->c_texsrc_card++; -#endif - mmesa->setup.tex_cntl &= ~MACH64_TEX_SRC_AGP; - } else { -#if ENABLE_PERF_BOXES - mmesa->c_texsrc_agp++; -#endif - mmesa->setup.tex_cntl |= MACH64_TEX_SRC_AGP; - } - mmesa->setup.tex_offset = t0->bufAddr; - } - - if ( t1 ) { - mmesa->setup.secondary_tex_off = t1->bufAddr; - } - - memcpy( &sarea->context_state.tex_size_pitch, ®s->tex_size_pitch, - MACH64_NR_TEXTURE_REGS * sizeof(GLuint) ); -} - diff --git a/src/mesa/drivers/dri/mach64/mach64_tris.c b/src/mesa/drivers/dri/mach64/mach64_tris.c deleted file mode 100644 index 024ee2f4353..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_tris.c +++ /dev/null @@ -1,1927 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/macros.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 "mach64_tris.h" -#include "mach64_state.h" -#include "mach64_context.h" -#include "mach64_vb.h" -#include "mach64_ioctl.h" - -static const GLuint hw_prim[GL_POLYGON+1] = { - MACH64_PRIM_POINTS, - MACH64_PRIM_LINES, - MACH64_PRIM_LINE_LOOP, - MACH64_PRIM_LINE_STRIP, - MACH64_PRIM_TRIANGLES, - MACH64_PRIM_TRIANGLE_STRIP, - MACH64_PRIM_TRIANGLE_FAN, - MACH64_PRIM_QUADS, - MACH64_PRIM_QUAD_STRIP, - MACH64_PRIM_POLYGON, -}; - -static void mach64RasterPrimitive( struct gl_context *ctx, GLuint hwprim ); -static void mach64RenderPrimitive( struct gl_context *ctx, GLenum prim ); - - -/* FIXME: Remove this when native template is finished. */ -#define MACH64_PRINT_BUFFER 0 - -/*********************************************************************** - * Emit primitives as inline vertices * - ***********************************************************************/ - -#if defined(USE_X86_ASM) -#define DO_COPY_VERTEX( vb, vertsize, v, n, m ) \ -do { \ - register const CARD32 *__p __asm__( "esi" ) = (CARD32 *)v + 10 - vertsize; \ - register int __s __asm__( "ecx" ) = vertsize; \ - if ( vertsize > 7 ) { \ - *vb++ = (2 << 16) | ADRINDEX( MACH64_VERTEX_##n##_SECONDARY_S ); \ - __asm__ __volatile__( "movsl ; movsl ; movsl" \ - : "=D" (vb), "=S" (__p) \ - : "0" (vb), "1" (__p) ); \ - __s -= 3; \ - } \ - *vb++ = ((__s - 1 + m) << 16) | \ - (ADRINDEX( MACH64_VERTEX_##n##_X_Y ) - (__s - 1) ); \ - __asm__ __volatile__( "rep ; movsl" \ - : "=%c" (__s), "=D" (vb), "=S" (__p) \ - : "0" (__s), "1" (vb), "2" (__p) ); \ -} while (0) -#else -#define DO_COPY_VERTEX( vb, vertsize, v, n, m ) \ -do { \ - CARD32 *__p = (CARD32 *)v + 10 - vertsize; \ - int __s = vertsize; \ - if ( vertsize > 7 ) { \ - LE32_OUT( vb++, (2 << 16) | \ - ADRINDEX( MACH64_VERTEX_##n##_SECONDARY_S ) ); \ - *vb++ = *__p++; \ - *vb++ = *__p++; \ - *vb++ = *__p++; \ - __s -= 3; \ - } \ - LE32_OUT( vb++, ((__s - 1 + m) << 16) | \ - (ADRINDEX( MACH64_VERTEX_##n##_X_Y ) - (__s - 1)) ); \ - while ( __s-- ) { \ - *vb++ = *__p++; \ - } \ -} while (0) -#endif - -#define COPY_VERTEX( vb, vertsize, v, n ) DO_COPY_VERTEX( vb, vertsize, v, n, 0 ) -#define COPY_VERTEX_OOA( vb, vertsize, v, n ) DO_COPY_VERTEX( vb, vertsize, v, n, 1 ) - - -static INLINE void mach64_draw_quad( mach64ContextPtr mmesa, - mach64VertexPtr v0, - mach64VertexPtr v1, - mach64VertexPtr v2, - mach64VertexPtr v3 ) -{ -#if MACH64_NATIVE_VTXFMT - struct gl_context *ctx = mmesa->glCtx; - const GLuint vertsize = mmesa->vertex_size; - GLint a; - GLfloat ooa; - GLuint xy; - const GLuint xyoffset = 9; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 4 + 2; - CARD32 *vb, *vbchk; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1:\n"); - mach64_print_vertex( ctx, v0 ); - fprintf(stderr,"Vertex 2:\n"); - mach64_print_vertex( ctx, v1 ); - fprintf(stderr,"Vertex 3:\n"); - mach64_print_vertex( ctx, v2 ); - fprintf(stderr,"Vertex 4:\n"); - mach64_print_vertex( ctx, v3 ); - } - - xy = LE32_IN( &v0->ui[xyoffset] ); - xx[0] = (GLshort)( xy >> 16 ); - yy[0] = (GLshort)( xy & 0xffff ); - - xy = LE32_IN( &v1->ui[xyoffset] ); - xx[1] = (GLshort)( xy >> 16 ); - yy[1] = (GLshort)( xy & 0xffff ); - - xy = LE32_IN( &v3->ui[xyoffset] ); - xx[2] = (GLshort)( xy >> 16 ); - yy[2] = (GLshort)( xy & 0xffff ); - - a = (xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2]); - - if ( (mmesa->backface_sign && - ((a < 0 && !signbit( mmesa->backface_sign )) || - (a > 0 && signbit( mmesa->backface_sign )))) ) { - /* cull quad */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Quad culled\n"); - return; - } - - ooa = 16.0 / a; - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) ); - vbchk = vb + vbsiz; - - COPY_VERTEX( vb, vertsize, v0, 1 ); - COPY_VERTEX( vb, vertsize, v1, 2 ); - COPY_VERTEX_OOA( vb, vertsize, v3, 3 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - xy = LE32_IN( &v2->ui[xyoffset] ); - xx[0] = (GLshort)( xy >> 16 ); - yy[0] = (GLshort)( xy & 0xffff ); - - a = (xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2]); - - ooa = 16.0 / a; - - COPY_VERTEX_OOA( vb, vertsize, v2, 1 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - assert( vb == vbchk ); - -#if MACH64_PRINT_BUFFER - { - int i; - fprintf(stderr, "quad:\n"); - for (i = 0; i < vbsiz; i++) - fprintf(stderr, " %08lx\n", *(vb - vbsiz + i)); - fprintf(stderr, "\n"); - } -#endif -#else - GLuint vertsize = mmesa->vertex_size; - GLint coloridx; - GLfloat ooa; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = - (( - 1 + - (vertsize > 6 ? 2 : 0) + - (vertsize > 4 ? 2 : 0) + - 3 + - (mmesa->multitex ? 4 : 0) - ) * 4 + 4); - CARD32 *vb; - unsigned vbidx = 0; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v0->v.x, v0->v.y, v0->v.z, v0->v.w, v0->v.u0, v0->v.v0, v0->v.u1, v0->v.v1); - fprintf(stderr,"Vertex 2: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v1->v.x, v1->v.y, v1->v.z, v1->v.w, v1->v.u0, v1->v.v0, v1->v.u1, v1->v.v1); - fprintf(stderr,"Vertex 3: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v2->v.x, v2->v.y, v2->v.z, v2->v.w, v2->v.u0, v2->v.v0, v2->v.u1, v2->v.v1); - fprintf(stderr,"Vertex 4: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v3->v.x, v3->v.y, v3->v.z, v3->v.w, v3->v.u0, v3->v.v0, v3->v.u1, v3->v.v1); - } - -#if MACH64_CLIENT_STATE_EMITS - /* Enable for interleaved client-side state emits */ - LOCK_HARDWARE( mmesa ); - if ( mmesa->dirty ) { - mach64EmitHwStateLocked( mmesa ); - } - if ( mmesa->sarea->dirty ) { - mach64UploadHwStateLocked( mmesa ); - } - UNLOCK_HARDWARE( mmesa ); -#endif - - xx[0] = (GLint)(v0->v.x * 4); - yy[0] = (GLint)(v0->v.y * 4); - - xx[1] = (GLint)(v1->v.x * 4); - yy[1] = (GLint)(v1->v.y * 4); - - xx[2] = (GLint)(v3->v.x * 4); - yy[2] = (GLint)(v3->v.y * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - - if ( ooa * mmesa->backface_sign < 0 ) { - /* cull quad */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Quad culled\n"); - return; - } - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 ); - - ooa = 1.0 / ooa; - - coloridx = (vertsize > 4) ? 4: 3; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v0->ui[8] ); /* MACH64_VERTEX_1_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v0->ui[9] ); /* MACH64_VERTEX_1_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_SECONDARY_W */ - } - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_2_S */ - LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_2_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_W */ - LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_2_Z */ - vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v1->ui[8] ); /* MACH64_VERTEX_2_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v1->ui[9] ); /* MACH64_VERTEX_2_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_SECONDARY_W */ - } - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v3->ui[6] ); /* MACH64_VERTEX_3_S */ - LE32_OUT( &vb[vbidx++], v3->ui[7] ); /* MACH64_VERTEX_3_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v3->ui[3] ); /* MACH64_VERTEX_3_W */ - LE32_OUT( &vb[vbidx++], v3->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v3->v.z) << 15) ); /* MACH64_VERTEX_3_Z */ - vb[vbidx++] = v3->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v3->ui[8] ); /* MACH64_VERTEX_3_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v3->ui[9] ); /* MACH64_VERTEX_3_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v3->ui[3] ); /* MACH64_VERTEX_3_SECONDARY_W */ - } - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - xx[0] = (GLint)(v2->v.x * 4); - yy[0] = (GLint)(v2->v.y * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - ooa = 1.0 / ooa; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v2->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v2->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v2->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v2->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v2->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v2->ui[8] ); /* MACH64_VERTEX_1_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v2->ui[9] ); /* MACH64_VERTEX_1_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_1_SECONDARY_W */ - } - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - assert(vbsiz == vbidx); - -#if MACH64_PRINT_BUFFER - { - int i; - fprintf(stderr, "quad:\n"); - for (i = 0; i < vbsiz; i++) - fprintf(stderr, " %08lx\n", *(vb + i)); - fprintf(stderr, "\n"); - } -#endif -#endif -} - -static INLINE void mach64_draw_triangle( mach64ContextPtr mmesa, - mach64VertexPtr v0, - mach64VertexPtr v1, - mach64VertexPtr v2 ) -{ -#if MACH64_NATIVE_VTXFMT - struct gl_context *ctx = mmesa->glCtx; - GLuint vertsize = mmesa->vertex_size; - GLint a; - GLfloat ooa; - GLuint xy; - const GLuint xyoffset = 9; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 3 + 1; - CARD32 *vb, *vbchk; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1:\n"); - mach64_print_vertex( ctx, v0 ); - fprintf(stderr,"Vertex 2:\n"); - mach64_print_vertex( ctx, v1 ); - fprintf(stderr,"Vertex 3:\n"); - mach64_print_vertex( ctx, v2 ); - } - - xy = LE32_IN( &v0->ui[xyoffset] ); - xx[0] = (GLshort)( xy >> 16 ); - yy[0] = (GLshort)( xy & 0xffff ); - - xy = LE32_IN( &v1->ui[xyoffset] ); - xx[1] = (GLshort)( xy >> 16 ); - yy[1] = (GLshort)( xy & 0xffff ); - - xy = LE32_IN( &v2->ui[xyoffset] ); - xx[2] = (GLshort)( xy >> 16 ); - yy[2] = (GLshort)( xy & 0xffff ); - - a = (xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2]); - - if ( mmesa->backface_sign && - ((a < 0 && !signbit( mmesa->backface_sign )) || - (a > 0 && signbit( mmesa->backface_sign ))) ) { - /* cull triangle */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Triangle culled\n"); - return; - } - - ooa = 16.0 / a; - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) ); - vbchk = vb + vbsiz; - - COPY_VERTEX( vb, vertsize, v0, 1 ); - COPY_VERTEX( vb, vertsize, v1, 2 ); - COPY_VERTEX_OOA( vb, vertsize, v2, 3 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - assert( vb == vbchk ); - -#if MACH64_PRINT_BUFFER - { - int i; - fprintf(stderr, "tri:\n"); - for (i = 0; i < vbsiz; i++) - fprintf(stderr, " %08lx\n", *(vb - vbsiz + i)); - fprintf(stderr, "\n"); - } -#endif -#else - GLuint vertsize = mmesa->vertex_size; - GLint coloridx; - GLfloat ooa; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = - (( - 1 + - (vertsize > 6 ? 2 : 0) + - (vertsize > 4 ? 2 : 0) + - 3 + - (mmesa->multitex ? 4 : 0) - ) * 3 + 2); - CARD32 *vb; - unsigned vbidx = 0; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v0->v.x, v0->v.y, v0->v.z, v0->v.w, v0->v.u0, v0->v.v0, v0->v.u1, v0->v.v1); - fprintf(stderr,"Vertex 2: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v1->v.x, v1->v.y, v1->v.z, v1->v.w, v1->v.u0, v1->v.v0, v1->v.u1, v1->v.v1); - fprintf(stderr,"Vertex 3: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n", - v2->v.x, v2->v.y, v2->v.z, v2->v.w, v2->v.u0, v2->v.v0, v2->v.u1, v2->v.v1); - } - -#if MACH64_CLIENT_STATE_EMITS - /* Enable for interleaved client-side state emits */ - LOCK_HARDWARE( mmesa ); - if ( mmesa->dirty ) { - mach64EmitHwStateLocked( mmesa ); - } - if ( mmesa->sarea->dirty ) { - mach64UploadHwStateLocked( mmesa ); - } - UNLOCK_HARDWARE( mmesa ); -#endif - - xx[0] = (GLint)(v0->v.x * 4); - yy[0] = (GLint)(v0->v.y * 4); - - xx[1] = (GLint)(v1->v.x * 4); - yy[1] = (GLint)(v1->v.y * 4); - - xx[2] = (GLint)(v2->v.x * 4); - yy[2] = (GLint)(v2->v.y * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - - if ( ooa * mmesa->backface_sign < 0 ) { - /* cull triangle */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Triangle culled\n"); - return; - } - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 ); - - ooa = 1.0 / ooa; - - coloridx = (vertsize > 4) ? 4: 3; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v0->ui[8] ); /* MACH64_VERTEX_1_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v0->ui[9] ); /* MACH64_VERTEX_1_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_SECONDARY_W */ - } - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_2_S */ - LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_2_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_W */ - LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_2_Z */ - vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v1->ui[8] ); /* MACH64_VERTEX_2_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v1->ui[9] ); /* MACH64_VERTEX_2_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_SECONDARY_W */ - } - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v2->ui[6] ); /* MACH64_VERTEX_3_S */ - LE32_OUT( &vb[vbidx++], v2->ui[7] ); /* MACH64_VERTEX_3_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_3_W */ - LE32_OUT( &vb[vbidx++], v2->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v2->v.z) << 15) ); /* MACH64_VERTEX_3_Z */ - vb[vbidx++] = v2->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */ - - if (mmesa->multitex) { - /* setup for 3 sequential reg writes */ - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_SECONDARY_S) ); - LE32_OUT( &vb[vbidx++], v2->ui[8] ); /* MACH64_VERTEX_3_SECONDARY_S */ - LE32_OUT( &vb[vbidx++], v2->ui[9] ); /* MACH64_VERTEX_3_SECONDARY_T */ - LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_3_SECONDARY_W */ - } - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - assert(vbsiz == vbidx); - -#if MACH64_PRINT_BUFFER - { - int i; - fprintf(stderr, "tri:\n"); - for (i = 0; i < vbsiz; ++i) - fprintf(stderr, " %08lx\n", *(vb + i)); - fprintf(stderr, "\n"); - } -#endif -#endif -} - -static INLINE void mach64_draw_line( mach64ContextPtr mmesa, - mach64VertexPtr v0, - mach64VertexPtr v1 ) -{ -#if MACH64_NATIVE_VTXFMT - struct gl_context *ctx = mmesa->glCtx; - const GLuint vertsize = mmesa->vertex_size; - /* 2 fractional bits for hardware: */ - const int width = (int) (2.0 * CLAMP(mmesa->glCtx->Line.Width, - mmesa->glCtx->Const.MinLineWidth, - mmesa->glCtx->Const.MaxLineWidth)); - GLfloat ooa; - GLuint *pxy0, *pxy1; - GLuint xy0old, xy0, xy1old, xy1; - const GLuint xyoffset = 9; - GLint x0, y0, x1, y1; - GLint dx, dy, ix, iy; - unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 4 + 2; - CARD32 *vb, *vbchk; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1:\n"); - mach64_print_vertex( ctx, v0 ); - fprintf(stderr,"Vertex 2:\n"); - mach64_print_vertex( ctx, v1 ); - } - - pxy0 = &v0->ui[xyoffset]; - xy0old = *pxy0; - xy0 = LE32_IN( &xy0old ); - x0 = (GLshort)( xy0 >> 16 ); - y0 = (GLshort)( xy0 & 0xffff ); - - pxy1 = &v1->ui[xyoffset]; - xy1old = *pxy1; - xy1 = LE32_IN( &xy1old ); - x1 = (GLshort)( xy1 >> 16 ); - y1 = (GLshort)( xy1 & 0xffff ); - - if ( (dx = x1 - x0) < 0 ) { - dx = -dx; - } - if ( (dy = y1 - y0) < 0 ) { - dy = -dy; - } - - /* adjust vertices depending on line direction */ - if ( dx > dy ) { - ix = 0; - iy = width; - ooa = 8.0 / ((x1 - x0) * width); - } else { - ix = width; - iy = 0; - ooa = 8.0 / ((y0 - y1) * width); - } - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) ); - vbchk = vb + vbsiz; - - LE32_OUT( pxy0, (( x0 - ix ) << 16) | (( y0 - iy ) & 0xffff) ); - COPY_VERTEX( vb, vertsize, v0, 1 ); - LE32_OUT( pxy1, (( x1 - ix ) << 16) | (( y1 - iy ) & 0xffff) ); - COPY_VERTEX( vb, vertsize, v1, 2 ); - LE32_OUT( pxy0, (( x0 + ix ) << 16) | (( y0 + iy ) & 0xffff) ); - COPY_VERTEX_OOA( vb, vertsize, v0, 3 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - ooa = -ooa; - - LE32_OUT( pxy1, (( x1 + ix ) << 16) | (( y1 + iy ) & 0xffff) ); - COPY_VERTEX_OOA( vb, vertsize, v1, 1 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - *pxy0 = xy0old; - *pxy1 = xy1old; -#else /* !MACH64_NATIVE_VTXFMT */ - GLuint vertsize = mmesa->vertex_size; - GLint coloridx; - float width = 1.0; /* Only support 1 pix lines now */ - GLfloat ooa; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = - (( - 1 + - (vertsize > 6 ? 2 : 0) + - (vertsize > 4 ? 2 : 0) + - 3 + - (mmesa->multitex ? 4 : 0) - ) * 4 + 4); - CARD32 *vb; - unsigned vbidx = 0; - - GLfloat hw, dx, dy, ix, iy; - GLfloat x0 = v0->v.x; - GLfloat y0 = v0->v.y; - GLfloat x1 = v1->v.x; - GLfloat y1 = v1->v.y; - -#if MACH64_CLIENT_STATE_EMITS - /* Enable for interleaved client-side state emits */ - LOCK_HARDWARE( mmesa ); - if ( mmesa->dirty ) { - mach64EmitHwStateLocked( mmesa ); - } - if ( mmesa->sarea->dirty ) { - mach64UploadHwStateLocked( mmesa ); - } - UNLOCK_HARDWARE( mmesa ); -#endif - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n", - v0->v.x, v0->v.y, v0->v.z, v0->v.w); - fprintf(stderr,"Vertex 2: x: %.2f, y: %.2f, z: %.2f, w: %f\n", - v1->v.x, v1->v.y, v1->v.z, v1->v.w); - } - - hw = 0.5F * width; - if (hw > 0.1F && hw < 0.5F) { - hw = 0.5F; - } - - /* adjust vertices depending on line direction */ - dx = v0->v.x - v1->v.x; - dy = v0->v.y - v1->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; - } - - xx[0] = (GLint)((x0 - ix) * 4); - yy[0] = (GLint)((y0 - iy) * 4); - - xx[1] = (GLint)((x1 - ix) * 4); - yy[1] = (GLint)((y1 - iy) * 4); - - xx[2] = (GLint)((x0 + ix) * 4); - yy[2] = (GLint)((y0 + iy) * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - - if ( ooa * mmesa->backface_sign < 0 ) { - /* cull line */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Line culled\n"); - return; - } - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 ); - - ooa = 1.0 / ooa; - - coloridx = (vertsize > 4) ? 4: 3; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_2_S */ - LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_2_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_W */ - LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_2_Z */ - vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */ - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_3_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_3_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_3_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_3_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */ - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - xx[0] = (GLint)((x1 + ix) * 4); - yy[0] = (GLint)((y1 + iy) * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - ooa = 1.0 / ooa; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - assert(vbsiz == vbidx); -#endif -} - -static INLINE void mach64_draw_point( mach64ContextPtr mmesa, - mach64VertexPtr v0 ) -{ -#if MACH64_NATIVE_VTXFMT - struct gl_context *ctx = mmesa->glCtx; - const GLuint vertsize = mmesa->vertex_size; - /* 2 fractional bits for hardware: */ - GLint sz = (GLint) (2.0 * CLAMP(mmesa->glCtx->Point.Size, - ctx->Const.MinPointSize, - ctx->Const.MaxPointSize)); - GLfloat ooa; - GLuint *pxy; - GLuint xyold, xy; - const GLuint xyoffset = 9; - GLint x, y; - unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 4 + 2; - CARD32 *vb, *vbchk; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1:\n"); - mach64_print_vertex( ctx, v0 ); - } - - if( !sz ) - sz = 1; /* round to the nearest supported size */ - - pxy = &v0->ui[xyoffset]; - xyold = *pxy; - xy = LE32_IN( &xyold ); - x = (GLshort)( xy >> 16 ); - y = (GLshort)( xy & 0xffff ); - - ooa = 4.0 / (sz * sz); - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) ); - vbchk = vb + vbsiz; - - LE32_OUT( pxy, (( x - sz ) << 16) | (( y - sz ) & 0xffff) ); - COPY_VERTEX( vb, vertsize, v0, 1 ); - LE32_OUT( pxy, (( x + sz ) << 16) | (( y - sz ) & 0xffff) ); - COPY_VERTEX( vb, vertsize, v0, 2 ); - LE32_OUT( pxy, (( x - sz ) << 16) | (( y + sz ) & 0xffff) ); - COPY_VERTEX_OOA( vb, vertsize, v0, 3 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - ooa = -ooa; - - LE32_OUT( pxy, (( x + sz ) << 16) | (( y + sz ) & 0xffff) ); - COPY_VERTEX_OOA( vb, vertsize, v0, 1 ); - LE32_OUT( vb++, *(CARD32 *)&ooa ); - - *pxy = xyold; -#else /* !MACH64_NATIVE_VTXFMT */ - GLuint vertsize = mmesa->vertex_size; - GLint coloridx; - float sz = 1.0; /* Only support 1 pix points now */ - GLfloat ooa; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = - (( - 1 + - (vertsize > 6 ? 2 : 0) + - (vertsize > 4 ? 2 : 0) + - 3 + - (mmesa->multitex ? 4 : 0) - ) * 4 + 4); - CARD32 *vb; - unsigned vbidx = 0; - - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) { - fprintf(stderr, "%s:\n", __FUNCTION__); - fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n", - v0->v.x, v0->v.y, v0->v.z, v0->v.w); - } - -#if MACH64_CLIENT_STATE_EMITS - /* Enable for interleaved client-side state emits */ - LOCK_HARDWARE( mmesa ); - if ( mmesa->dirty ) { - mach64EmitHwStateLocked( mmesa ); - } - if ( mmesa->sarea->dirty ) { - mach64UploadHwStateLocked( mmesa ); - } - UNLOCK_HARDWARE( mmesa ); -#endif - - xx[0] = (GLint)((v0->v.x - sz) * 4); - yy[0] = (GLint)((v0->v.y - sz) * 4); - - xx[1] = (GLint)((v0->v.x + sz) * 4); - yy[1] = (GLint)((v0->v.y - sz) * 4); - - xx[2] = (GLint)((v0->v.x - sz) * 4); - yy[2] = (GLint)((v0->v.y + sz) * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - - if ( ooa * mmesa->backface_sign < 0 ) { - /* cull quad */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Point culled\n"); - return; - } - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 ); - - ooa = 1.0 / ooa; - - coloridx = (vertsize > 4) ? 4: 3; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_2_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_2_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_2_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_2_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */ - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_3_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_3_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_3_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_3_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */ - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - xx[0] = (GLint)((v0->v.x + sz) * 4); - yy[0] = (GLint)((v0->v.y + sz) * 4); - - ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2])); - ooa = 1.0 / ooa; - - /* setup for 3,5, or 7 sequential reg writes based on vertex format */ - switch (vertsize) { - case 6: - LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) ); - break; - case 4: - LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) ); - break; - default: /* vertsize >= 8 */ - LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) ); - break; - } - if (vertsize > 6) { - LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */ - LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */ - } - if (vertsize > 4) { - LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */ - LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */ - } - LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */ - vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */ - LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */ - - LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) ); - LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa ); - - assert(vbsiz == vbidx); -#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 \ - mach64_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 \ - mach64_draw_quad( mmesa, a, b, c, d ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - mmesa->draw_line( mmesa, v0, v1 ); \ - else \ - mach64_draw_line( mmesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - mmesa->draw_point( mmesa, v0 ); \ - else \ - mach64_draw_point( mmesa, v0 ); \ -} while (0) - - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define MACH64_OFFSET_BIT 0x01 -#define MACH64_TWOSIDE_BIT 0x02 -#define MACH64_UNFILLED_BIT 0x04 -#define MACH64_FALLBACK_BIT 0x08 -#define MACH64_MAX_TRIFUNC 0x10 - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[MACH64_MAX_TRIFUNC]; - - -#define DO_FALLBACK (IND & MACH64_FALLBACK_BIT) -#define DO_OFFSET (IND & MACH64_OFFSET_BIT) -#define DO_UNFILLED (IND & MACH64_UNFILLED_BIT) -#define DO_TWOSIDE (IND & MACH64_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_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX mach64Vertex -#define TAB rast_tab - -#if MACH64_NATIVE_VTXFMT - -/* #define DEPTH_SCALE 65536.0 */ -#define DEPTH_SCALE 1 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) ((GLfloat)(GLshort)(LE32_IN( &(_v)->ui[xyoffset] ) & 0xffff) / 4.0) -#define VERT_Y(_v) ((GLfloat)(GLshort)(LE32_IN( &(_v)->ui[xyoffset] ) >> 16) / 4.0) -#define VERT_Z(_v) ((GLfloat) LE32_IN( &(_v)->ui[zoffset] )) -#define INSANE_VERTICES -#define VERT_SET_Z(_v,val) LE32_OUT( &(_v)->ui[zoffset], (GLuint)(val) ) -#define VERT_Z_ADD(_v,val) LE32_OUT( &(_v)->ui[zoffset], LE32_IN( &(_v)->ui[zoffset] ) + (GLuint)(val) ) -#define AREA_IS_CCW( a ) ((a) < 0) -#define GET_VERTEX(e) (mmesa->verts + ((e) * mmesa->vertex_size * sizeof(int))) - -#define MACH64_COLOR( dst, src ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[3], src[3]); \ -} while (0) - -#define MACH64_SPEC( dst, src ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \ -} while (0) - -#define VERT_SET_RGBA( v, c ) MACH64_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) MACH64_SPEC( v->ub4[specoffset], c ) -#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V( v0->ub4[specoffset], v1->ub4[specoffset] ) -#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[specoffset] -#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[specoffset] = spec[idx] - -#define LOCAL_VARS(n) \ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \ - GLuint color[n] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - GLuint vertex_size = mmesa->vertex_size; \ - const GLuint xyoffset = 9; \ - const GLuint coloroffset = 8; \ - const GLuint zoffset = 7; \ - const GLuint specoffset = 6; \ - GLboolean havespec = vertex_size >= 4 ? 1 : 0; \ - (void) color; (void) spec; (void) vertex_size; \ - (void) xyoffset; (void) coloroffset; (void) zoffset; \ - (void) specoffset; (void) havespec; - -#else - -#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) (mmesa->verts + ((e) * mmesa->vertex_size * sizeof(int))) - -#define MACH64_COLOR( dst, src ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[3], src[3]); \ -} while (0) - -#define MACH64_SPEC( dst, src ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \ -} while (0) - -#define VERT_SET_RGBA( v, c ) MACH64_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) MACH64_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) \ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \ - GLuint color[n], spec[n]; \ - GLuint coloroffset = (mmesa->vertex_size == 4 ? 3 : 4); \ - GLboolean havespec = (mmesa->vertex_size == 4 ? 0 : 1); \ - (void) color; (void) spec; (void) coloroffset; (void) havespec; - -#endif - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (mmesa->hw_primitive != hw_prim[x]) \ - mach64RasterPrimitive( ctx, hw_prim[x] ) -#define RENDER_PRIMITIVE mmesa->render_primitive -#define IND MACH64_FALLBACK_BIT -#define TAG(x) x -#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 (MACH64_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_OFFSET_BIT|MACH64_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT|MACH64_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_UNFILLED_BIT|MACH64_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT|MACH64_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_UNFILLED_BIT|MACH64_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT| \ - MACH64_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_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(); -} - - -/*********************************************************************** - * 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 -mach64_fallback_tri( mach64ContextPtr mmesa, - mach64Vertex *v0, - mach64Vertex *v1, - mach64Vertex *v2 ) -{ - struct gl_context *ctx = mmesa->glCtx; - SWvertex v[3]; - mach64_translate_vertex( ctx, v0, &v[0] ); - mach64_translate_vertex( ctx, v1, &v[1] ); - mach64_translate_vertex( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - - -static void -mach64_fallback_line( mach64ContextPtr mmesa, - mach64Vertex *v0, - mach64Vertex *v1 ) -{ - struct gl_context *ctx = mmesa->glCtx; - SWvertex v[2]; - mach64_translate_vertex( ctx, v0, &v[0] ); - mach64_translate_vertex( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -static void -mach64_fallback_point( mach64ContextPtr mmesa, - mach64Vertex *v0 ) -{ - struct gl_context *ctx = mmesa->glCtx; - SWvertex v[1]; - mach64_translate_vertex( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} - - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define VERT(x) (mach64Vertex *)(mach64verts + ((x) * vertsize * sizeof(int))) -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - mach64_draw_point( mmesa, VERT(start) ) -#define RENDER_LINE( v0, v1 ) \ - mach64_draw_line( mmesa, VERT(v0), VERT(v1) ) -#define RENDER_TRI( v0, v1, v2 ) \ - mach64_draw_triangle( mmesa, VERT(v0), VERT(v1), VERT(v2) ) -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - mach64_draw_quad( mmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) -#define INIT(x) do { \ - if (0) fprintf(stderr, "%s\n", __FUNCTION__); \ - mach64RenderPrimitive( ctx, x ); \ -} while (0) -#undef LOCAL_VARS -#define LOCAL_VARS \ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \ - const GLuint vertsize = mmesa->vertex_size; \ - const char *mach64verts = (char *)mmesa->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) mach64_##x##_verts -#include "tnl/t_vb_rendertmp.h" -#undef ELT -#undef TAG -#define TAG(x) mach64_##x##_elts -#define ELT(x) elt[x] -#include "tnl/t_vb_rendertmp.h" - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void mach64RenderClippedPoly( struct gl_context *ctx, const GLuint *elts, - GLuint n ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->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 mach64RenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -#if MACH64_NATIVE_VTXFMT -static void mach64FastRenderClippedPoly( struct gl_context *ctx, const GLuint *elts, - GLuint n ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - const GLuint vertsize = mmesa->vertex_size; - GLint a; - union { - GLfloat f; - CARD32 u; - } ooa; - GLuint xy; - const GLuint xyoffset = 9; - GLint xx[3], yy[3]; /* 2 fractional bits for hardware */ - unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * n + (n-2); - CARD32 *vb, *vbchk; - GLubyte *mach64verts = (GLubyte *)mmesa->verts; - mach64VertexPtr v0, v1, v2; - int i; - - v0 = (mach64VertexPtr)VERT(elts[1]); - v1 = (mach64VertexPtr)VERT(elts[2]); - v2 = (mach64VertexPtr)VERT(elts[0]); - - xy = LE32_IN( &v0->ui[xyoffset] ); - xx[0] = (GLshort)( xy >> 16 ); - yy[0] = (GLshort)( xy & 0xffff ); - - xy = LE32_IN( &v1->ui[xyoffset] ); - xx[1] = (GLshort)( xy >> 16 ); - yy[1] = (GLshort)( xy & 0xffff ); - - xy = LE32_IN( &v2->ui[xyoffset] ); - xx[2] = (GLshort)( xy >> 16 ); - yy[2] = (GLshort)( xy & 0xffff ); - - a = (xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2]); - - if ( (mmesa->backface_sign && - ((a < 0 && !signbit( mmesa->backface_sign )) || - (a > 0 && signbit( mmesa->backface_sign )))) ) { - /* cull polygon */ - if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) - fprintf(stderr,"Polygon culled\n"); - return; - } - - ooa.f = 16.0 / a; - - vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) ); - vbchk = vb + vbsiz; - - COPY_VERTEX( vb, vertsize, v0, 1 ); - COPY_VERTEX( vb, vertsize, v1, 2 ); - COPY_VERTEX_OOA( vb, vertsize, v2, 3 ); - LE32_OUT( vb++, ooa.u ); - - i = 3; - while (1) { - if (i >= n) - break; - v0 = (mach64VertexPtr)VERT(elts[i]); - i++; - - xy = LE32_IN( &v0->ui[xyoffset] ); - xx[0] = (GLshort)( xy >> 16 ); - yy[0] = (GLshort)( xy & 0xffff ); - - a = (xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2]); - ooa.f = 16.0 / a; - - COPY_VERTEX_OOA( vb, vertsize, v0, 1 ); - LE32_OUT( vb++, ooa.u ); - - if (i >= n) - break; - v1 = (mach64VertexPtr)VERT(elts[i]); - i++; - - xy = LE32_IN( &v1->ui[xyoffset] ); - xx[1] = (GLshort)( xy >> 16 ); - yy[1] = (GLshort)( xy & 0xffff ); - - a = (xx[0] - xx[2]) * (yy[1] - yy[2]) - - (yy[0] - yy[2]) * (xx[1] - xx[2]); - ooa.f = 16.0 / a; - - COPY_VERTEX_OOA( vb, vertsize, v1, 2 ); - LE32_OUT( vb++, ooa.u ); - } - - assert( vb == vbchk ); -} -#else -static void mach64FastRenderClippedPoly( struct gl_context *ctx, const GLuint *elts, - GLuint n ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - const GLuint vertsize = mmesa->vertex_size; - GLubyte *mach64verts = (GLubyte *)mmesa->verts; - const GLuint *start = (const GLuint *)VERT(elts[0]); - int i; - - for (i = 2 ; i < n ; i++) { - mach64_draw_triangle( mmesa, - VERT(elts[i-1]), - VERT(elts[i]), - (mach64VertexPtr) start - ); - } -} -#endif /* MACH64_NATIVE_VTXFMT */ - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - -#define _MACH64_NEW_RENDER_STATE (_DD_NEW_POINT_SMOOTH | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_LINE_STIPPLE | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_TRI_STIPPLE | \ - _NEW_POLYGONSTIPPLE | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET) \ - -#define POINT_FALLBACK (DD_POINT_SMOOTH) -#define LINE_FALLBACK (DD_LINE_SMOOTH|DD_LINE_STIPPLE) -#define TRI_FALLBACK (DD_TRI_SMOOTH|DD_TRI_STIPPLE) -#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 mach64ChooseRenderState(struct gl_context *ctx) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { - mmesa->draw_point = mach64_draw_point; - mmesa->draw_line = mach64_draw_line; - mmesa->draw_tri = mach64_draw_triangle; - - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= MACH64_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= MACH64_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= MACH64_UNFILLED_BIT; - } - - /* Hook in fallbacks for specific primitives. - */ - if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) { - if (flags & POINT_FALLBACK) mmesa->draw_point = mach64_fallback_point; - if (flags & LINE_FALLBACK) mmesa->draw_line = mach64_fallback_line; - if (flags & TRI_FALLBACK) mmesa->draw_tri = mach64_fallback_tri; - index |= MACH64_FALLBACK_BIT; - } - } - - if (index != mmesa->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 = mach64_render_tab_verts; - tnl->Driver.Render.PrimTabElts = mach64_render_tab_elts; - tnl->Driver.Render.ClippedLine = rast_tab[index].line; - tnl->Driver.Render.ClippedPolygon = mach64FastRenderClippedPoly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = mach64RenderClippedLine; - tnl->Driver.Render.ClippedPolygon = mach64RenderClippedPoly; - } - - mmesa->RenderIndex = index; - } -} - -/**********************************************************************/ -/* Validate state at pipeline start */ -/**********************************************************************/ - -static void mach64RunPipeline( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - if (mmesa->new_state) - mach64DDUpdateHWState( ctx ); - - if (!mmesa->Fallback && mmesa->NewGLState) { - if (mmesa->NewGLState & _MACH64_NEW_VERTEX_STATE) - mach64ChooseVertexState( ctx ); - - if (mmesa->NewGLState & _MACH64_NEW_RENDER_STATE) - mach64ChooseRenderState( ctx ); - - mmesa->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. - */ - -static void mach64RasterPrimitive( struct gl_context *ctx, GLuint hwprim ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - - mmesa->new_state |= MACH64_NEW_CONTEXT; - mmesa->dirty |= MACH64_UPLOAD_CONTEXT; - - if (mmesa->hw_primitive != hwprim) { - FLUSH_BATCH( mmesa ); - mmesa->hw_primitive = hwprim; - } -} - -static void mach64RenderPrimitive( struct gl_context *ctx, GLenum prim ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint hw = hw_prim[prim]; - - mmesa->render_primitive = prim; - - if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - - mach64RasterPrimitive( ctx, hw ); -} - - -static void mach64RenderStart( struct gl_context *ctx ) -{ - /* Check for projective texturing. Make sure all texcoord - * pointers point to something. (fix in mesa?) - */ - mach64CheckTexSizes( ctx ); -} - -static void mach64RenderFinish( struct gl_context *ctx ) -{ - if (MACH64_CONTEXT(ctx)->RenderIndex & MACH64_FALLBACK_BIT) - _swrast_flush( ctx ); -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - -static const char * const fallbackStrings[] = { - "Texture mode", - "glDrawBuffer(GL_FRONT_AND_BACK)", - "glReadBuffer", - "glEnable(GL_STENCIL) without hw stencil buffer", - "glRenderMode(selection or feedback)", - "glLogicOp (mode != GL_COPY)", - "GL_SEPARATE_SPECULAR_COLOR", - "glBlendEquation (mode != ADD)", - "glBlendFunc", - "Rasterization disable", -}; - - -static const char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - -void mach64Fallback( struct gl_context *ctx, GLuint bit, GLboolean mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint oldfallback = mmesa->Fallback; - - if (mode) { - mmesa->Fallback |= bit; - if (oldfallback == 0) { - FLUSH_BATCH( mmesa ); - _swsetup_Wakeup( ctx ); - mmesa->RenderIndex = ~0; - if (MACH64_DEBUG & DEBUG_VERBOSE_FALLBACK) { - fprintf(stderr, "Mach64 begin rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } - else { - mmesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - tnl->Driver.Render.Start = mach64RenderStart; - tnl->Driver.Render.PrimitiveNotify = mach64RenderPrimitive; - tnl->Driver.Render.Finish = mach64RenderFinish; - tnl->Driver.Render.BuildVertices = mach64BuildVertices; - mmesa->NewGLState |= (_MACH64_NEW_RENDER_STATE| - _MACH64_NEW_VERTEX_STATE); - if (MACH64_DEBUG & DEBUG_VERBOSE_FALLBACK) { - fprintf(stderr, "Mach64 end rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } -} - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - -void mach64InitTriFuncs( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - } - - tnl->Driver.RunPipeline = mach64RunPipeline; - tnl->Driver.Render.Start = mach64RenderStart; - tnl->Driver.Render.Finish = mach64RenderFinish; - tnl->Driver.Render.PrimitiveNotify = mach64RenderPrimitive; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = mach64BuildVertices; -} diff --git a/src/mesa/drivers/dri/mach64/mach64_tris.h b/src/mesa/drivers/dri/mach64/mach64_tris.h deleted file mode 100644 index 84f613c4abd..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_tris.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#ifndef __MACH64_TRIS_H__ -#define __MACH64_TRIS_H__ - -#include "main/mtypes.h" - -extern void mach64InitTriFuncs( struct gl_context *ctx ); - - -extern void mach64Fallback( struct gl_context *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( mmesa, bit, mode ) mach64Fallback( mmesa->glCtx, bit, mode ) - - -#endif /* __MACH64_TRIS_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_vb.c b/src/mesa/drivers/dri/mach64/mach64_vb.c deleted file mode 100644 index d0c04d3d034..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_vb.c +++ /dev/null @@ -1,641 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" - -#include "mach64_context.h" -#include "mach64_vb.h" -#include "mach64_ioctl.h" -#include "mach64_tris.h" - - -#define MACH64_TEX1_BIT 0x1 -#define MACH64_TEX0_BIT 0x2 -#define MACH64_RGBA_BIT 0x4 -#define MACH64_SPEC_BIT 0x8 -#define MACH64_FOG_BIT 0x10 -#define MACH64_XYZW_BIT 0x20 -#define MACH64_PTEX_BIT 0x40 -#define MACH64_MAX_SETUP 0x80 - -static struct { - void (*emit)( struct gl_context *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( struct gl_context *ctx ); - GLuint vertex_size; - GLuint vertex_format; -} setup_tab[MACH64_MAX_SETUP]; - -#define TINY_VERTEX_FORMAT 1 -#define NOTEX_VERTEX_FORMAT 2 -#define TEX0_VERTEX_FORMAT 3 -#define TEX1_VERTEX_FORMAT 4 -#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 & MACH64_XYZW_BIT) -#define DO_RGBA (IND & MACH64_RGBA_BIT) -#define DO_SPEC (IND & MACH64_SPEC_BIT) -#define DO_FOG (IND & MACH64_FOG_BIT) -#define DO_TEX0 (IND & MACH64_TEX0_BIT) -#define DO_TEX1 (IND & MACH64_TEX1_BIT) -#define DO_TEX2 0 -#define DO_TEX3 0 -#define DO_PTEX (IND & MACH64_PTEX_BIT) - -#define VERTEX mach64Vertex -#define LOCALVARS mach64ContextPtr mmesa = MACH64_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_SIZE() mmesa->vertex_size * sizeof(GLuint) - -#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 \ - const GLfloat dx = - (GLfloat)mmesa->drawX - SUBPIXEL_X; \ - const GLfloat dy = (mmesa->driDrawable->h + \ - (GLfloat)mmesa->drawY + SUBPIXEL_Y); \ - const GLfloat sz = 1.0 / mmesa->depth_scale - -#if MACH64_NATIVE_VTXFMT - -#define UNVIEWPORT_X(x) ((GLfloat)(x) / 4.0) + dx -#define UNVIEWPORT_Y(y) - ((GLfloat)(y) / 4.0) + dy -#define UNVIEWPORT_Z(z) (GLfloat)((z) >> 15) * sz - -#else - -#define UNVIEWPORT_X(x) x + dx; -#define UNVIEWPORT_Y(y) - y + dy; -#define UNVIEWPORT_Z(z) z * sz; - -#endif - -#define PTEX_FALLBACK() FALLBACK(MACH64_CONTEXT(ctx), MACH64_FALLBACK_TEXTURE, 1) - -#define IMPORT_FLOAT_COLORS mach64_import_float_colors -#define IMPORT_FLOAT_SPEC_COLORS mach64_import_float_spec_colors - -#define INTERP_VERTEX setup_tab[mmesa->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[mmesa->SetupIndex].copy_pv - -/*********************************************************************** - * Generate pv-copying and translation functions * - ***********************************************************************/ - -#if MACH64_NATIVE_VTXFMT - -#define TAG(x) mach64_##x -#include "mach64_native_vb.c" - -#else - -#define TAG(x) mach64_##x -#include "tnl_dd/t_dd_vb.c" - -#endif - -/*********************************************************************** - * Generate vertex emit and interp functions * - ***********************************************************************/ - - -#if MACH64_NATIVE_VTXFMT - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT) -#define TAG(x) x##_wg -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_wgs -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_wgt0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_wgst0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\ - MACH64_TEX1_BIT) -#define TAG(x) x##_wgst0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\ - MACH64_PTEX_BIT) -#define TAG(x) x##_wgspt0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT) -#define TAG(x) x##_wgf -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_wgfs -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\ - MACH64_TEX1_BIT) -#define TAG(x) x##_wgft0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\ - MACH64_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\ - MACH64_TEX0_BIT) -#define TAG(x) x##_wgfst0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\ - MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_wgfst0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\ - MACH64_TEX0_BIT|MACH64_PTEX_BIT) -#define TAG(x) x##_wgfspt0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_TEX0_BIT) -#define TAG(x) x##_t0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_FOG_BIT) -#define TAG(x) x##_f -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_ft0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_ft0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT) -#define TAG(x) x##_g -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_gs -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_gst0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT) -#define TAG(x) x##_gf -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_gfs -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_gft0t1 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gfst0 -#include "mach64_native_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\ - MACH64_TEX1_BIT) -#define TAG(x) x##_gfst0t1 -#include "mach64_native_vbtmp.h" - -#else - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT) -#define TAG(x) x##_wg -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_wgs -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_wgt0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_wgst0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\ - MACH64_TEX1_BIT) -#define TAG(x) x##_wgst0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\ - MACH64_PTEX_BIT) -#define TAG(x) x##_wgspt0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT) -#define TAG(x) x##_wgf -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_wgfs -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\ - MACH64_TEX1_BIT) -#define TAG(x) x##_wgft0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\ - MACH64_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\ - MACH64_TEX0_BIT) -#define TAG(x) x##_wgfst0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\ - MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_wgfst0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\ - MACH64_TEX0_BIT|MACH64_PTEX_BIT) -#define TAG(x) x##_wgfspt0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_TEX0_BIT) -#define TAG(x) x##_t0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_FOG_BIT) -#define TAG(x) x##_f -#include "mach64_vbtmp.h" - -#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_ft0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_ft0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT) -#define TAG(x) x##_g -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_gs -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_gst0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT) -#define TAG(x) x##_gf -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT) -#define TAG(x) x##_gfs -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT) -#define TAG(x) x##_gft0t1 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT) -#define TAG(x) x##_gfst0 -#include "mach64_vbtmp.h" - -#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\ - MACH64_TEX1_BIT) -#define TAG(x) x##_gfst0t1 -#include "mach64_vbtmp.h" - -#endif - -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 mach64PrintSetupFlags( char *msg, GLuint flags ) -{ - fprintf( stderr, "%s: %d %s%s%s%s%s%s%s\n", - msg, - (int)flags, - (flags & MACH64_XYZW_BIT) ? " xyzw," : "", - (flags & MACH64_RGBA_BIT) ? " rgba," : "", - (flags & MACH64_SPEC_BIT) ? " spec," : "", - (flags & MACH64_FOG_BIT) ? " fog," : "", - (flags & MACH64_TEX0_BIT) ? " tex-0," : "", - (flags & MACH64_TEX1_BIT) ? " tex-1," : "", - (flags & MACH64_PTEX_BIT) ? " ptex," : ""); -} - - - - -void mach64CheckTexSizes( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - - if (!setup_tab[mmesa->SetupIndex].check_tex_sizes(ctx)) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Invalidate stored verts - */ - mmesa->SetupNewInputs = ~0; - mmesa->SetupIndex |= MACH64_PTEX_BIT; - - 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; - } - } -} - -void mach64BuildVertices( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - GLuint stride = mmesa->vertex_size * sizeof(int); - GLubyte *v = ((GLubyte *)mmesa->verts + (start * stride)); - - newinputs |= mmesa->SetupNewInputs; - mmesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[mmesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= MACH64_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= MACH64_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= MACH64_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= MACH64_TEX1_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= MACH64_FOG_BIT; - - if (mmesa->SetupIndex & MACH64_PTEX_BIT) - ind = ~0; - - ind &= mmesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - -void mach64ChooseVertexState( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); - GLuint ind = MACH64_XYZW_BIT|MACH64_RGBA_BIT; - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - ind |= MACH64_SPEC_BIT; - - if (ctx->Fog.Enabled) - ind |= MACH64_FOG_BIT; - - if (ctx->Texture._EnabledUnits) { - ind |= MACH64_TEX0_BIT; - if (ctx->Texture.Unit[0]._ReallyEnabled && - ctx->Texture.Unit[1]._ReallyEnabled) { - ind |= MACH64_TEX1_BIT; - } - } - - mmesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = mach64_interp_extras; - tnl->Driver.Render.CopyPV = mach64_copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } - -#if 0 - if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) { - mach64PrintSetupFlags( __FUNCTION__, ind ); - } -#endif - - if (setup_tab[ind].vertex_format != mmesa->vertex_format) { - FLUSH_BATCH(mmesa); - mmesa->vertex_format = setup_tab[ind].vertex_format; - mmesa->vertex_size = setup_tab[ind].vertex_size; - } -} - - -#if 0 -void mach64_emit_contiguous_verts( struct gl_context *ctx, - GLuint start, - GLuint count ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint vertex_size = mmesa->vertex_size * 4; - GLuint *dest = mach64AllocDmaLow( mmesa, (count-start) * vertex_size); - setup_tab[mmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size ); -} -#endif - - -void mach64InitVB( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - mmesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - } -} - - -void mach64FreeVB( struct gl_context *ctx ) -{ - mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); - if (mmesa->verts) { - _mesa_align_free(mmesa->verts); - mmesa->verts = 0; - } -} diff --git a/src/mesa/drivers/dri/mach64/mach64_vb.h b/src/mesa/drivers/dri/mach64/mach64_vb.h deleted file mode 100644 index 8d9cd5b492c..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_vb.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - -#ifndef __MACH64_VB_H__ -#define __MACH64_VB_H__ - -#include "main/mtypes.h" -#include "swrast/swrast.h" -#include "mach64_context.h" - -/* premultiply texture coordinates by homogenous coordinate */ -#define MACH64_PREMULT_TEXCOORDS - -#define _MACH64_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_UNFILLED | \ - _NEW_TEXTURE | \ - _NEW_FOG) - - -extern void mach64CheckTexSizes( struct gl_context *ctx ); -extern void mach64ChooseVertexState( struct gl_context *ctx ); - -extern void mach64BuildVertices( struct gl_context *ctx, GLuint start, GLuint count, - GLuint newinputs ); - -extern void mach64PrintSetupFlags(char *msg, GLuint flags ); - -extern void mach64InitVB( struct gl_context *ctx ); -extern void mach64FreeVB( struct gl_context *ctx ); - -#if 0 -extern void mach64_emit_contiguous_verts( struct gl_context *ctx, - GLuint start, - GLuint count ); - -extern void mach64_emit_indexed_verts( struct gl_context *ctx, - GLuint start, - GLuint count ); -#endif - -extern void mach64_translate_vertex( struct gl_context *ctx, - const mach64Vertex *src, - SWvertex *dst ); - -extern void mach64_print_vertex( struct gl_context *ctx, const mach64Vertex *v ); - - -#endif /* __MACH64_VB_H__ */ diff --git a/src/mesa/drivers/dri/mach64/mach64_vbtmp.h b/src/mesa/drivers/dri/mach64/mach64_vbtmp.h deleted file mode 100644 index a126dcae40f..00000000000 --- a/src/mesa/drivers/dri/mach64/mach64_vbtmp.h +++ /dev/null @@ -1,770 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <[email protected]> - * - * Modified for mach64 by: - * Leif Delgass <[email protected]> - * Jos� Fonseca <[email protected]> - */ - - -/* Unlike the other templates here, this assumes quite a bit about the - * underlying hardware. Specifically it assumes a d3d-like vertex - * format, with a layout more or less constrained to look like the - * following: - * - * union { - * struct { - * float x, y, z, w; - * struct { char r, g, b, a; } color; - * struct { char r, g, b, fog; } spec; - * float u0, v0; - * float u1, v1; - * float u2, v2; - * float u3, v3; - * } v; - * struct { - * float x, y, z, w; - * struct { char r, g, b, a; } color; - * struct { char r, g, b, fog; } spec; - * float u0, v0, q0; - * float u1, v1, q1; - * float u2, v2, q2; - * float u3, v3, q3; - * } pv; - * struct { - * float x, y, z; - * struct { char r, g, b, a; } color; - * } tv; - * float f[16]; - * unsigned int ui[16]; - * unsigned char ub4[4][16]; - * } - * - - * DO_XYZW: Emit xyz and maybe w coordinates. - * DO_RGBA: Emit color. - * DO_SPEC: Emit specular color. - * DO_FOG: Emit fog coordinate in specular alpha. - * DO_TEX0: Emit tex0 u,v coordinates. - * DO_TEX1: Emit tex1 u,v coordinates. - * DO_TEX2: Emit tex2 u,v coordinates. - * DO_TEX3: Emit tex3 u,v coordinates. - * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible. - * - * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra). - * - * HAVE_HW_VIEWPORT: Hardware performs viewport transform. - * HAVE_HW_DIVIDE: Hardware performs perspective divide. - * - * HAVE_TINY_VERTICES: Hardware understands v.tv format. - * HAVE_PTEX_VERTICES: Hardware understands v.pv format. - * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0. - * - * Additionally, this template assumes it is emitting *transformed* - * vertices; the modifications to emit untransformed vertices (ie. to - * t&l hardware) are probably too great to cooexist with the code - * already in this file. - * - * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if - * only TEX0 is enabled, in order to maintain a vertex size which is - * an exact number of quadwords. - */ - -#if (HAVE_HW_VIEWPORT) -#define VIEWPORT_X(dst,x) dst = x -#define VIEWPORT_Y(dst,y) dst = y -#define VIEWPORT_Z(dst,z) dst = z -#else -#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] -#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] -#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] -#endif - -#if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES) -#error "can't cope with this combination" -#endif - -#ifndef LOCALVARS -#define LOCALVARS -#endif - -#ifndef CHECK_HW_DIVIDE -#define CHECK_HW_DIVIDE 1 -#endif - -#if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES) - -static void TAG(emit)( struct gl_context *ctx, - GLuint start, GLuint end, - void *dest, - GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4]; - GLfloat (*tc2)[4], (*tc3)[4]; - GLfloat (*spec)[4]; - GLfloat (*col)[4]; - GLuint col_stride; - GLuint tc0_stride, tc1_stride, spec_stride, fog_stride; - GLuint tc2_stride, tc3_stride; - GLuint tc0_size, tc1_size; - GLuint tc2_size, tc3_size; - GLfloat (*coord)[4]; - GLuint coord_stride; - VERTEX *v = (VERTEX *)dest; - const GLfloat *s = GET_VIEWPORT_MAT(); - const GLubyte *mask = VB->ClipMask; - int i; - -/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */ -/* __FUNCTION__, VB->importable_data, start, end); */ - - if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) { - (void) s; - coord = VB->ClipPtr->data; - coord_stride = VB->ClipPtr->stride; - } - else { - coord = VB->NdcPtr->data; - coord_stride = VB->NdcPtr->stride; - } - - if (DO_TEX3) { - const GLuint t3 = GET_TEXSOURCE(3); - tc3 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->data; - tc3_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->stride; - if (DO_PTEX) - tc3_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t3]->size; - } - - if (DO_TEX2) { - const GLuint t2 = GET_TEXSOURCE(2); - tc2 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->data; - tc2_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->stride; - if (DO_PTEX) - tc2_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t2]->size; - } - - if (DO_TEX1) { - const GLuint t1 = GET_TEXSOURCE(1); - tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->data; - tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->stride; - if (DO_PTEX) - tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t1]->size; - } - - if (DO_TEX0) { - const GLuint t0 = GET_TEXSOURCE(0); - tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->stride; - tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->data; - if (DO_PTEX) - tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + t0]->size; - } - - if (DO_RGBA) { - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; - } - - if (DO_SPEC) { - spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data; - spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride; - } else { - spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - spec_stride = 0; - } - - if (DO_FOG) { - if (VB->AttribPtr[_TNL_ATTRIB_FOG]) { - fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data; - fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride; - } else { - static GLfloat tmp[4] = {0, 0, 0, 0}; - fog = &tmp; - fog_stride = 0; - } - } - - /* May have nonstandard strides: - */ - if (start) { - coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride); - if (DO_TEX0) - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride); - if (DO_TEX1) - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); - if (DO_TEX2) - tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + start * tc2_stride); - if (DO_TEX3) - tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + start * tc3_stride); - if (DO_RGBA) - STRIDE_4F(col, start * col_stride); - if (DO_SPEC) - STRIDE_4F(spec, start * spec_stride); - if (DO_FOG) - STRIDE_4F(fog, start * fog_stride); - // fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride); - /* STRIDE_F(fog, start * fog_stride); */ - } - - for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) { - if (DO_XYZW) { - if (HAVE_HW_VIEWPORT || mask[i] == 0) { - /* unclipped */ - VIEWPORT_X(v->v.x, coord[0][0]); - VIEWPORT_Y(v->v.y, coord[0][1]); - VIEWPORT_Z(v->v.z, coord[0][2]); - v->v.w = coord[0][3]; - } else { - /* clipped */ - v->v.w = 1.0; - } - if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) { - fprintf(stderr, "%s: vert (importable) %d: %.2f %.2f %.2f %f\n", - __FUNCTION__, i, v->v.x, v->v.y, v->v.z, v->v.w); - } - coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride); - } - if (DO_RGBA) { - if (HAVE_RGBA_COLOR) { - *(GLuint *)&v->v.color = *(GLuint *)&col[0]; - STRIDE_4F(col, col_stride); - } else { - v->v.color.blue = col[0][2]; - v->v.color.green = col[0][1]; - v->v.color.red = col[0][0]; - v->v.color.alpha = col[0][3]; - STRIDE_4F(col, col_stride); - } - } - if (DO_SPEC) { - v->v.specular.red = spec[0][0]; - v->v.specular.green = spec[0][1]; - v->v.specular.blue = spec[0][2]; - STRIDE_4F(spec, spec_stride); - } - if (DO_FOG) { - v->v.specular.alpha = fog[0][0] * 255.0; - /* STRIDE_F(fog, fog_stride); */ - fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); - } - if (DO_TEX0) { - v->v.u0 = tc0[0][0]; - v->v.v0 = tc0[0][1]; - if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) { - fprintf(stderr, "%s: vert (importable) %d: u0: %.2f, v0: %.2f, w: %f\n", - __FUNCTION__, i, v->v.u0, v->v.v0, v->v.w); - } -#ifdef MACH64_PREMULT_TEXCOORDS - v->v.u0 *= v->v.w; - v->v.v0 *= v->v.w; -#endif - if (DO_PTEX) { - if (HAVE_PTEX_VERTICES) { - if (tc0_size == 4) - v->pv.q0 = tc0[0][3]; - else - v->pv.q0 = 1.0; - } - else if (tc0_size == 4) { -#ifdef MACH64_PREMULT_TEXCOORDS - v->v.w *= tc0[0][3]; -#else - float rhw = 1.0 / tc0[0][3]; - v->v.w *= tc0[0][3]; - v->v.u0 *= rhw; - v->v.v0 *= rhw; -#endif - } - } - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); - } - if (DO_TEX1) { - if (DO_PTEX) { - v->pv.u1 = tc1[0][0]; - v->pv.v1 = tc1[0][1]; - if (tc1_size == 4) - v->pv.q1 = tc1[0][3]; - else - v->pv.q1 = 1.0; - } - else { - v->v.u1 = tc1[0][0]; - v->v.v1 = tc1[0][1]; - } -#ifdef MACH64_PREMULT_TEXCOORDS - v->v.u1 *= v->v.w; - v->v.v1 *= v->v.w; -#endif - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); - } - else if (DO_PTEX) { - *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */ - } - if (DO_TEX2) { - if (DO_PTEX) { - v->pv.u2 = tc2[0][0]; - v->pv.v2 = tc2[0][1]; - if (tc2_size == 4) - v->pv.q2 = tc2[0][3]; - else - v->pv.q2 = 1.0; - } - else { - v->v.u2 = tc2[0][0]; - v->v.v2 = tc2[0][1]; - } - tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + tc2_stride); - } - if (DO_TEX3) { - if (DO_PTEX) { - v->pv.u3 = tc3[0][0]; - v->pv.v3 = tc3[0][1]; - if (tc3_size == 4) - v->pv.q3 = tc3[0][3]; - else - v->pv.q3 = 1.0; - } - else { - v->v.u3 = tc3[0][0]; - v->v.v3 = tc3[0][1]; - } - tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + tc3_stride); - } - } -} - -#else -#if DO_XYZW - -#if HAVE_HW_DIVIDE -#error "cannot use tiny vertices with hw perspective divide" -#endif - -static void TAG(emit)( struct gl_context *ctx, GLuint start, GLuint end, - void *dest, GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*col)[4]; - GLuint col_stride; - GLfloat (*coord)[4] = VB->NdcPtr->data; - GLuint coord_stride = VB->NdcPtr->stride; - GLfloat *v = (GLfloat *)dest; - const GLubyte *mask = VB->ClipMask; - const GLfloat *s = GET_VIEWPORT_MAT(); - int i; - - (void) s; - - ASSERT(stride == 4); - - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; - - /* Pack what's left into a 4-dword vertex. Color is in a different - * place, and there is no 'w' coordinate. - */ - if (start) { - coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride); - STRIDE_4F(col, start * col_stride); - } - - for (i=start; i < end; i++, v+=4) { - if (HAVE_HW_VIEWPORT || mask[i] == 0) { - VIEWPORT_X(v[0], coord[0][0]); - VIEWPORT_Y(v[1], coord[0][1]); - VIEWPORT_Z(v[2], coord[0][2]); - } - coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride); - if (DO_RGBA) { - if (HAVE_RGBA_COLOR) { - *(GLuint *)&v[3] = *(GLuint *)col; - } - else { - GLubyte *b = (GLubyte *)&v[3]; - UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]); - } - STRIDE_4F( col, col_stride ); - } - if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) { - fprintf(stderr, "vert (importable) %d: %.2f %.2f %.2f %x\n", - i, v[0], v[1], v[2], *(int *)&v[3]); - } - } -} -#else -static void TAG(emit)( struct gl_context *ctx, GLuint start, GLuint end, - void *dest, GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*col)[4]; - GLuint col_stride; - GLfloat *v = (GLfloat *)dest; - int i; - - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; - - if (start) - STRIDE_4F(col, col_stride * start); - - /* Need to figure out where color is: - */ - if (GET_VERTEX_FORMAT() == TINY_VERTEX_FORMAT) - v += 3; - else - v += 4; - - for (i=start; i < end; i++, STRIDE_F(v, stride)) { - if (HAVE_RGBA_COLOR) { - *(GLuint *)v = *(GLuint *)col[0]; - } - else { - GLubyte *b = (GLubyte *)v; - UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]); - } - STRIDE_4F( col, col_stride ); - } -} -#endif /* emit */ -#endif /* emit */ - -#if (DO_XYZW) && (DO_RGBA) - - -#if (HAVE_PTEX_VERTICES) -static GLboolean TAG(check_tex_sizes)( struct gl_context *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* Force 'missing' texcoords to something valid. - */ - if (DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX2] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX2] = VB->AttribPtr[_TNL_ATTRIB_TEX3]; - - if (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX1] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX1] = VB->AttribPtr[_TNL_ATTRIB_TEX2]; - - if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1]; - - if (DO_PTEX) - return GL_TRUE; - - if ((DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(3)]->size == 4) || - (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(2)]->size == 4) || - (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4) || - (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4)) - return GL_FALSE; - - return GL_TRUE; -} -#else -static GLboolean TAG(check_tex_sizes)( struct gl_context *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* Force 'missing' texcoords to something valid. - */ - if (DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX2] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX2] = VB->AttribPtr[_TNL_ATTRIB_TEX3]; - - if (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX1] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX1] = VB->AttribPtr[_TNL_ATTRIB_TEX2]; - - if (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1]; - - if (DO_PTEX) - return GL_TRUE; - - /* No hardware support for projective texture. Can fake it for - * TEX0 only. - */ - if ((DO_TEX3 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(3)]->size == 4) || - (DO_TEX2 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(2)]->size == 4) || - (DO_TEX1 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(1)]->size == 4)) { - PTEX_FALLBACK(); - return GL_FALSE; - } - - if (DO_TEX0 && VB->AttribPtr[_TNL_ATTRIB_TEX0 + GET_TEXSOURCE(0)]->size == 4) { - if (DO_TEX1 || DO_TEX2 || DO_TEX3) { - PTEX_FALLBACK(); - } - return GL_FALSE; - } - - return GL_TRUE; -} -#endif /* ptex */ - - -static void TAG(interp)( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte *ddverts = GET_VERTEX_STORE(); - GLuint size = GET_VERTEX_SIZE(); - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - GLfloat w; - const GLfloat *s = GET_VIEWPORT_MAT(); - - VERTEX *dst = (VERTEX *)(ddverts + (edst * size)); - VERTEX *in = (VERTEX *)(ddverts + (ein * size)); - VERTEX *out = (VERTEX *)(ddverts + (eout * size)); - - (void)s; - - if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) { - VIEWPORT_X( dst->v.x, dstclip[0] ); - VIEWPORT_Y( dst->v.y, dstclip[1] ); - VIEWPORT_Z( dst->v.z, dstclip[2] ); - w = dstclip[3]; - } - else { - w = (dstclip[3] == 0.0F) ? 1.0 : (1.0 / dstclip[3]); - VIEWPORT_X( dst->v.x, dstclip[0] * w ); - VIEWPORT_Y( dst->v.y, dstclip[1] * w ); - VIEWPORT_Z( dst->v.z, dstclip[2] * w ); - } - - if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) { - fprintf( stderr, "%s: dst vert: %.2f %.2f %.2f %f\n", - __FUNCTION__, - dst->v.x, - dst->v.y, - dst->v.z, - w ); - } - - if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) || - DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 || - DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) { - - dst->v.w = w; - - 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 (DO_SPEC) { - INTERP_UB( t, dst->ub4[5][0], out->ub4[5][0], in->ub4[5][0] ); - INTERP_UB( t, dst->ub4[5][1], out->ub4[5][1], in->ub4[5][1] ); - INTERP_UB( t, dst->ub4[5][2], out->ub4[5][2], in->ub4[5][2] ); - } - if (DO_FOG) { - INTERP_UB( t, dst->ub4[5][3], out->ub4[5][3], in->ub4[5][3] ); - } - if (DO_TEX0) { - if (DO_PTEX) { - if (HAVE_PTEX_VERTICES) { - INTERP_F( t, dst->pv.u0, out->pv.u0, in->pv.u0 ); - INTERP_F( t, dst->pv.v0, out->pv.v0, in->pv.v0 ); - INTERP_F( t, dst->pv.q0, out->pv.q0, in->pv.q0 ); - } else { - GLfloat wout = VB->NdcPtr->data[eout][3]; - GLfloat win = VB->NdcPtr->data[ein][3]; - GLfloat qout = out->pv.w / wout; - GLfloat qin = in->pv.w / win; - GLfloat qdst, rqdst; - - ASSERT( !HAVE_HW_DIVIDE ); - - INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin ); - INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin ); - INTERP_F( t, qdst, qout, qin ); - - rqdst = 1.0 / qdst; - dst->v.u0 *= rqdst; - dst->v.v0 *= rqdst; - dst->v.w *= rqdst; - } - } - else { -#ifdef MACH64_PREMULT_TEXCOORDS - GLfloat qout = 1 / out->v.w; - GLfloat qin = 1 / in->v.w; - - INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin); - INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin); - - dst->v.u0 *= w; - dst->v.v0 *= w; -#else - INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 ); - INTERP_F( t, dst->v.v0, out->v.v0, in->v.v0 ); -#endif - } - } - if (DO_TEX1) { - if (DO_PTEX) { - INTERP_F( t, dst->pv.u1, out->pv.u1, in->pv.u1 ); - INTERP_F( t, dst->pv.v1, out->pv.v1, in->pv.v1 ); - INTERP_F( t, dst->pv.q1, out->pv.q1, in->pv.q1 ); - } else { -#ifdef MACH64_PREMULT_TEXCOORDS - GLfloat qout = 1 / out->v.w; - GLfloat qin = 1 / in->v.w; - - INTERP_F( t, dst->v.u1, out->v.u1 * qout, in->v.u1 * qin ); - INTERP_F( t, dst->v.v1, out->v.v1 * qout, in->v.v1 * qin ); - - dst->v.u1 *= w; - dst->v.v1 *= w; -#else - INTERP_F( t, dst->v.u1, out->v.u1, in->v.u1 ); - INTERP_F( t, dst->v.v1, out->v.v1, in->v.v1 ); -#endif - } - } - else if (DO_PTEX) { - dst->pv.q0 = 0.0; /* must be a valid float on radeon */ - } - if (DO_TEX2) { - if (DO_PTEX) { - INTERP_F( t, dst->pv.u2, out->pv.u2, in->pv.u2 ); - INTERP_F( t, dst->pv.v2, out->pv.v2, in->pv.v2 ); - INTERP_F( t, dst->pv.q2, out->pv.q2, in->pv.q2 ); - } else { - INTERP_F( t, dst->v.u2, out->v.u2, in->v.u2 ); - INTERP_F( t, dst->v.v2, out->v.v2, in->v.v2 ); - } - } - if (DO_TEX3) { - if (DO_PTEX) { - INTERP_F( t, dst->pv.u3, out->pv.u3, in->pv.u3 ); - INTERP_F( t, dst->pv.v3, out->pv.v3, in->pv.v3 ); - INTERP_F( t, dst->pv.q3, out->pv.q3, in->pv.q3 ); - } else { - INTERP_F( t, dst->v.u3, out->v.u3, in->v.u3 ); - INTERP_F( t, dst->v.v3, out->v.v3, in->v.v3 ); - } - } - } 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 /* rgba && xyzw */ - - -static void TAG(init)( void ) -{ - setup_tab[IND].emit = TAG(emit); - -#if (DO_XYZW && DO_RGBA) - setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); - setup_tab[IND].interp = TAG(interp); -#endif - - if (DO_SPEC) - setup_tab[IND].copy_pv = copy_pv_rgba4_spec5; - else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 || - DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) - setup_tab[IND].copy_pv = copy_pv_rgba4; - else - setup_tab[IND].copy_pv = copy_pv_rgba3; - - if (DO_TEX3) { - if (DO_PTEX) { - ASSERT(HAVE_PTEX_VERTICES); - setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 18; - } - else { - setup_tab[IND].vertex_format = TEX3_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 14; - } - } - else if (DO_TEX2) { - if (DO_PTEX) { - ASSERT(HAVE_PTEX_VERTICES); - setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 18; - } - else { - setup_tab[IND].vertex_format = TEX2_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 12; - } - } - else if (DO_TEX1) { - if (DO_PTEX) { - ASSERT(HAVE_PTEX_VERTICES); - setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 12; - } - else { - setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 10; - } - } - else if (DO_TEX0) { - if (DO_PTEX && HAVE_PTEX_VERTICES) { - setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 12; - } else { - setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 8; - } - } - else if (!HAVE_HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) { - setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 4; - } else if (HAVE_NOTEX_VERTICES) { - setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 6; - } else { - setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 8; - } - -} - - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/mach64/server/mach64_dri.h b/src/mesa/drivers/dri/mach64/server/mach64_dri.h deleted file mode 100644 index 1477443f790..00000000000 --- a/src/mesa/drivers/dri/mach64/server/mach64_dri.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * Copyright 2000 Gareth Hughes - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION 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 <[email protected]> - * Leif Delgass <[email protected]> - */ - -#ifndef __MACH64_DRI_H__ -#define __MACH64_DRI_H__ 1 - -#include "xf86drm.h" - -typedef struct { - drm_handle_t fbHandle; - - drm_handle_t regsHandle; - drmSize regsSize; - - int IsPCI; - - drm_handle_t agpHandle; /* Handle from drmAgpAlloc */ - unsigned long agpOffset; - drmSize agpSize; - int agpMode; - - /* DMA descriptor ring */ - unsigned long ringStart; /* Offset into AGP space */ - drm_handle_t ringHandle; /* Handle from drmAddMap */ - drmSize ringMapSize; /* Size of map */ - int ringSize; /* Size of ring (in kB) */ - drmAddress ringMap; /* Map */ - - /* vertex buffer data */ - unsigned long bufferStart; /* Offset into AGP space */ - drm_handle_t bufferHandle; /* Handle from drmAddMap */ - drmSize bufferMapSize; /* Size of map */ - int bufferSize; /* Size of buffers (in MB) */ - drmAddress bufferMap; /* Map */ - - drmBufMapPtr drmBuffers; /* Buffer map */ - int numBuffers; /* Number of buffers */ - - /* AGP Texture data */ - unsigned long agpTexStart; /* Offset into AGP space */ - drm_handle_t agpTexHandle; /* Handle from drmAddMap */ - drmSize agpTexMapSize; /* Size of map */ - int agpTexSize; /* Size of AGP tex space (in MB) */ - drmAddress agpTexMap; /* Map */ - int log2AGPTexGran; - - int fbX; - int fbY; - int backX; - int backY; - int depthX; - int depthY; - - int frontOffset; - int frontPitch; - int backOffset; - int backPitch; - int depthOffset; - int depthPitch; - - int textureOffset; - int textureSize; - int logTextureGranularity; -} ATIDRIServerInfoRec, *ATIDRIServerInfoPtr; - -typedef struct { - int chipset; - int width; - int height; - int mem; - int cpp; - - int IsPCI; - int AGPMode; - - unsigned int frontOffset; - unsigned int frontPitch; - - unsigned int backOffset; - unsigned int backPitch; - - unsigned int depthOffset; - unsigned int depthPitch; - - unsigned int textureOffset; - unsigned int textureSize; - int logTextureGranularity; - - drm_handle_t regs; - drmSize regsSize; - - drm_handle_t agp; - drmSize agpSize; - unsigned int agpTextureOffset; - unsigned int agpTextureSize; - int logAgpTextureGranularity; -} ATIDRIRec, *ATIDRIPtr; - -#endif /* __MACH64_DRI_H__ */ diff --git a/src/mesa/drivers/dri/mga/Doxyfile b/src/mesa/drivers/dri/mga/Doxyfile deleted file mode 100644 index 0d0c134a728..00000000000 --- a/src/mesa/drivers/dri/mga/Doxyfile +++ /dev/null @@ -1,234 +0,0 @@ -# Doxyfile 1.3.3-Gideon - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = mga -PROJECT_NUMBER = $VERSION$ -OUTPUT_DIRECTORY = -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = NO -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -EXTRACT_LOCAL_CLASSES = YES -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ALIASES = -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SHOW_USED_FILES = YES -SUBGROUPING = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = /home/newtree/temp/src/mesa/drivers/dri/mga -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.C \ - *.H \ - *.tlh \ - *.diff \ - *.patch \ - *.moc \ - *.xpm \ - *.dox -RECURSIVE = yes -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = YES -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = yes -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = NO -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 1000 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = search.cgi -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = /usr/local/bin/ -EXT_DOC_PATHS = diff --git a/src/mesa/drivers/dri/mga/Makefile b/src/mesa/drivers/dri/mga/Makefile deleted file mode 100644 index 9948ee767ac..00000000000 --- a/src/mesa/drivers/dri/mga/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# src/mesa/drivers/dri/mga/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = mga_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - mgadd.c \ - mgaioctl.c \ - mgarender.c \ - mgastate.c \ - mgatris.c \ - mgapixel.c \ - mgaspan.c \ - mgatex.c \ - mgatexmem.c \ - mga_texstate.c \ - mga_texcombine.c \ - mgavb.c \ - mga_xmesa.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - - -ASM_SOURCES = - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/mga/README b/src/mesa/drivers/dri/mga/README deleted file mode 100644 index a7133fa66f4..00000000000 --- a/src/mesa/drivers/dri/mga/README +++ /dev/null @@ -1,26 +0,0 @@ -MGA DRI driver ported from XF86DRI to FBDRI -by Denis Oliver Kropp <[email protected]> - - -INFO - -This driver has been ported from the head branch of XFree86 to -the embedded-1-branch of Mesa. - - -STATUS - -Already working very well as far as I've tested it (16/32 bit). -glxgears runs at 935 fps (G550 32MB AGP 4x, Athlon 1.33) vs 744 fps with XFree. -Other demos (terrain, fire, etc.) have been successfully tested as well. - - -TODO - -- mgaEngineShutdown -- mgaEngineRestore -- SGRAM detection -- remove some unused bits from server/* -- subset driver support -- mgaWaitForVBlank -- deinitialization (from MGADRICloseScreen) a la radeonDestroyScreen diff --git a/src/mesa/drivers/dri/mga/mga_texcombine.c b/src/mesa/drivers/dri/mga/mga_texcombine.c deleted file mode 100644 index 1488a89bb65..00000000000 --- a/src/mesa/drivers/dri/mga/mga_texcombine.c +++ /dev/null @@ -1,672 +0,0 @@ -/* - * Copyright (c) 2003 Ville Syrjala - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION 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: - * Ville Syrjala <[email protected]> - */ - -#include "main/glheader.h" - -#include "mgacontext.h" -#include "mgatex.h" -#include "mgaregs.h" - -/* - * GL_ARB_texture_env_combine - * GL_EXT_texture_env_combine - * GL_ARB_texture_env_crossbar - * GL_ATI_texture_env_combine3 - */ - -#define ARG_DISABLE 0xffffffff -#define MGA_ARG1 0 -#define MGA_ARG2 1 -#define MGA_ALPHA 2 - -GLboolean mgaUpdateTextureEnvCombine( struct gl_context *ctx, int unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - const int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit); - GLuint numColorArgs = 0, numAlphaArgs = 0; - GLuint arg1[3], arg2[3], alpha[3]; - int args[3]; - int i; - - switch (texUnit->Combine.ModeRGB) { - case GL_REPLACE: - numColorArgs = 1; - break; - case GL_MODULATE: - case GL_ADD: - case GL_ADD_SIGNED: - case GL_SUBTRACT: - numColorArgs = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - numColorArgs = 3; - break; - default: - return GL_FALSE; - } - - switch (texUnit->Combine.ModeA) { - case GL_REPLACE: - numAlphaArgs = 1; - break; - case GL_MODULATE: - case GL_ADD: - case GL_ADD_SIGNED: - case GL_SUBTRACT: - numAlphaArgs = 2; - break; - default: - return GL_FALSE; - } - - /* Start fresh :) */ - *reg = 0; - - /* COLOR */ - for (i = 0; i < 3; i++) { - arg1[i] = 0; - arg2[i] = 0; - alpha[i] = 0; - } - - for (i = 0;i < numColorArgs; i++) { - switch (texUnit->Combine.SourceRGB[i]) { - case GL_TEXTURE: - arg1[i] |= 0; - arg2[i] |= ARG_DISABLE; - alpha[i] |= TD0_color_alpha_currtex; - break; - case GL_TEXTURE0: - if (source == 0) { - arg1[i] |= 0; - arg2[i] |= ARG_DISABLE; - alpha[i] |= TD0_color_alpha_currtex; - } else { - if (ctx->Texture._EnabledUnits != 0x03) { - /* disable texturing */ - mmesa->setup.dwgctl &= DC_opcod_MASK; - mmesa->setup.dwgctl |= DC_opcod_trap; - mmesa->hw.alpha_sel = AC_alphasel_diffused; - /* return GL_TRUE since we don't need a fallback */ - return GL_TRUE; - } - arg1[i] |= ARG_DISABLE; - arg2[i] |= ARG_DISABLE; - alpha[i] |= TD0_color_alpha_prevtex; - } - break; - case GL_TEXTURE1: - if (source == 0) { - if (ctx->Texture._EnabledUnits != 0x03) { - /* disable texturing */ - mmesa->setup.dwgctl &= DC_opcod_MASK; - mmesa->setup.dwgctl |= DC_opcod_trap; - mmesa->hw.alpha_sel = AC_alphasel_diffused; - /* return GL_TRUE since we don't need a fallback */ - return GL_TRUE; - } - arg1[i] |= ARG_DISABLE; - /* G400 specs (TDUALSTAGE0) */ - arg2[i] |= TD0_color_arg2_prevstage; - alpha[i] |= TD0_color_alpha_prevstage; - } else { - arg1[i] |= 0; - arg2[i] |= ARG_DISABLE; - alpha[i] |= TD0_color_alpha_currtex; - } - break; - case GL_CONSTANT: - if (mmesa->fcol_used && - mmesa->envcolor[source] != mmesa->envcolor[!source]) - return GL_FALSE; - - arg1[i] |= ARG_DISABLE; - arg2[i] |= TD0_color_arg2_fcol; - alpha[i] |= TD0_color_alpha_fcol; - - mmesa->setup.fcol = mmesa->envcolor[source]; - mmesa->fcol_used = GL_TRUE; - break; - case GL_PRIMARY_COLOR: - arg1[i] |= ARG_DISABLE; - /* G400 specs (TDUALSTAGE1) */ - if (unit == 0 || (mmesa->setup.tdualstage0 & - ((TD0_color_sel_mul & TD0_color_sel_add) | - (TD0_alpha_sel_mul & TD0_alpha_sel_add)))) { - arg2[i] |= TD0_color_arg2_diffuse; - alpha[i] |= TD0_color_alpha_diffuse; - } else { - arg2[i] |= ARG_DISABLE; - alpha[i] |= ARG_DISABLE; - } - break; - case GL_PREVIOUS: - arg1[i] |= ARG_DISABLE; - if (unit == 0) { - arg2[i] |= TD0_color_arg2_diffuse; - alpha[i] |= TD0_color_alpha_diffuse; - } else { - arg2[i] |= TD0_color_arg2_prevstage; - alpha[i] |= TD0_color_alpha_prevstage; - } - break; - default: - return GL_FALSE; - } - - switch (texUnit->Combine.OperandRGB[i]) { - case GL_SRC_COLOR: - arg1[i] |= 0; - arg2[i] |= 0; - if (texUnit->Combine.SourceRGB[i] == GL_CONSTANT && - RGBA_EQUAL( mmesa->envcolor[source] )) { - alpha[i] |= 0; - } else { - alpha[i] |= ARG_DISABLE; - } - break; - case GL_ONE_MINUS_SRC_COLOR: - arg1[i] |= TD0_color_arg1_inv_enable; - arg2[i] |= TD0_color_arg2_inv_enable; - if (texUnit->Combine.SourceRGB[i] == GL_CONSTANT && - RGBA_EQUAL( mmesa->envcolor[source] )) { - alpha[i] |= (TD0_color_alpha1inv_enable | - TD0_color_alpha2inv_enable); - } else { - alpha[i] |= ARG_DISABLE; - } - break; - case GL_SRC_ALPHA: - arg1[i] |= TD0_color_arg1_replicatealpha_enable; - arg2[i] |= TD0_color_arg2_replicatealpha_enable; - alpha[i] |= 0; - break; - case GL_ONE_MINUS_SRC_ALPHA: - arg1[i] |= (TD0_color_arg1_replicatealpha_enable | - TD0_color_arg1_inv_enable); - arg2[i] |= (TD0_color_arg2_replicatealpha_enable | - TD0_color_arg2_inv_enable); - alpha[i] |= (TD0_color_alpha1inv_enable | - TD0_color_alpha2inv_enable); - break; - } - } - - switch (texUnit->Combine.ModeRGB) { - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - /* Special handling for ATI_texture_env_combine3. - * If Arg1 == Arg0 or Arg1 == Arg2 we can use arg1 or arg2 as input for - * both multiplier and adder. - */ - /* Arg1 == arg1 */ - if (arg1[1] == arg1[0]) { - if ((arg1[1] | arg2[2]) != ARG_DISABLE) { - *reg |= arg1[1] | arg2[2]; - args[0] = MGA_ARG1; args[1] = MGA_ARG1; args[2] = MGA_ARG2; - break; - } else - if ((arg1[1] | alpha[2]) != ARG_DISABLE) { - *reg |= arg1[1] | alpha[2]; - args[0] = MGA_ARG1; args[1] = MGA_ARG1; args[2] = MGA_ALPHA; - break; - } - } - if (arg1[1] == arg1[2]) { - if ((arg1[1] | arg2[0]) != ARG_DISABLE) { - *reg |= arg1[1] | arg2[0]; - args[0] = MGA_ARG2; args[1] = MGA_ARG1; args[2] = MGA_ARG1; - break; - } else - if ((arg1[1] | alpha[0]) != ARG_DISABLE) { - *reg |= arg1[1] | alpha[0]; - args[0] = MGA_ALPHA; args[1] = MGA_ARG1; args[2] = MGA_ARG1; - break; - } - } - /* fallthrough */ - case GL_MODULATE_SUBTRACT_ATI: - /* Arg1 == arg2 */ - if (arg2[1] == arg2[0]) { - if ((arg2[1] | arg1[2]) != ARG_DISABLE) { - *reg |= arg2[1] | arg1[2]; - args[0] = MGA_ARG2; args[1] = MGA_ARG2; args[2] = MGA_ARG1; - break; - } else - if ((arg2[1] | alpha[2]) != ARG_DISABLE) { - *reg |= arg2[1] | alpha[2]; - args[0] = MGA_ARG2; args[1] = MGA_ARG2; args[2] = MGA_ALPHA; - break; - } - } - if (arg2[1] == arg2[2]) { - if ((arg2[1] | arg1[0]) != ARG_DISABLE) { - *reg |= arg2[1] | arg1[0]; - args[0] = MGA_ARG1; args[1] = MGA_ARG2; args[2] = MGA_ARG2; - break; - } else - if ((arg2[1] | alpha[0]) != ARG_DISABLE) { - *reg |= arg2[1] | alpha[0]; - args[0] = MGA_ALPHA; args[1] = MGA_ARG2; args[2] = MGA_ARG2; - break; - } - } - /* fallthrough */ - default: - /* Find working combo of arg1, arg2 and alpha. - * - * Keep the Arg0 != alpha cases first since there's - * no way to get alpha out by itself (GL_REPLACE). - * - * Keep the Arg2 == alpha cases first because only alpha has the - * capabilities to function as Arg2 (GL_INTERPOLATE). Also good for - * GL_ADD, GL_ADD_SIGNED, GL_SUBTRACT since we can't get alpha to the - * adder. - * - * Keep the Arg1 == alpha cases last for GL_MODULATE_ADD_ATI, - * GL_MODULATE_SIGNED_ADD_ATI. Again because we can't get alpha to the - * adder. - * - * GL_MODULATE_SUBTRACT_ATI needs special treatment since it requires - * that Arg1 == arg2. This requirement clashes with those of other modes. - */ - if ((arg1[0] | arg2[1] | alpha[2]) != ARG_DISABLE) { - *reg |= arg1[0] | arg2[1] | alpha[2]; - args[0] = MGA_ARG1; args[1] = MGA_ARG2; args[2] = MGA_ALPHA; - } else - if ((arg1[1] | arg2[0] | alpha[2]) != ARG_DISABLE && - texUnit->Combine.ModeRGB != GL_MODULATE_SUBTRACT_ATI) { - *reg |= arg1[1] | arg2[0] | alpha[2]; - args[0] = MGA_ARG2; args[1] = MGA_ARG1; args[2] = MGA_ALPHA; - } else - if ((arg1[1] | arg2[2] | alpha[0]) != ARG_DISABLE && - texUnit->Combine.ModeRGB != GL_MODULATE_SUBTRACT_ATI) { - *reg |= arg1[1] | arg2[2] | alpha[0]; - args[0] = MGA_ALPHA; args[1] = MGA_ARG1; args[2] = MGA_ARG2; - } else - if ((arg1[2] | arg2[1] | alpha[0]) != ARG_DISABLE) { - *reg |= arg1[2] | arg2[1] | alpha[0]; - args[0] = MGA_ALPHA; args[1] = MGA_ARG2; args[2] = MGA_ARG1; - } else - if ((arg1[0] | arg2[2] | alpha[1]) != ARG_DISABLE) { - *reg |= arg1[0] | arg2[2] | alpha[1]; - args[0] = MGA_ARG1; args[1] = MGA_ALPHA; args[2] = MGA_ARG2; - } else - if ((arg1[2] | arg2[0] | alpha[1]) != ARG_DISABLE) { - *reg |= arg1[2] | arg2[0] | alpha[1]; - args[0] = MGA_ARG2; args[1] = MGA_ALPHA; args[2] = MGA_ARG1; - } else { - /* nothing suitable */ - return GL_FALSE; - } - } - - switch (texUnit->Combine.ModeRGB) { - case GL_REPLACE: - if (texUnit->Combine.ScaleShiftRGB) { - return GL_FALSE; - } - - if (args[0] == MGA_ARG1) { - *reg |= TD0_color_sel_arg1; - } else if (args[0] == MGA_ARG2) { - *reg |= TD0_color_sel_arg2; - } else if (args[0] == MGA_ALPHA) { - /* Can't get alpha out by itself */ - return GL_FALSE; - } - break; - case GL_MODULATE: - if (texUnit->Combine.ScaleShiftRGB == 1) { - *reg |= TD0_color_modbright_2x; - } else if (texUnit->Combine.ScaleShiftRGB == 2) { - *reg |= TD0_color_modbright_4x; - } - - *reg |= TD0_color_sel_mul; - - if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) { - if (args[0] == MGA_ARG1 || args[1] == MGA_ARG1) { - *reg |= TD0_color_arg2mul_alpha2; - } else if (args[0] == MGA_ARG2 || args[1] == MGA_ARG2) { - *reg |= TD0_color_arg1mul_alpha1; - } - } - break; - case GL_ADD_SIGNED: - *reg |= TD0_color_addbias_enable; - /* fallthrough */ - case GL_ADD: - if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) { - /* Can't get alpha to the adder */ - return GL_FALSE; - } - if (texUnit->Combine.ScaleShiftRGB == 1) { - *reg |= TD0_color_add2x_enable; - } else if (texUnit->Combine.ScaleShiftRGB == 2) { - return GL_FALSE; - } - - *reg |= (TD0_color_add_add | - TD0_color_sel_add); - break; - case GL_INTERPOLATE: - if (args[2] != MGA_ALPHA) { - /* Only alpha can function as Arg2 */ - return GL_FALSE; - } - if (texUnit->Combine.ScaleShiftRGB == 1) { - *reg |= TD0_color_add2x_enable; - } else if (texUnit->Combine.ScaleShiftRGB == 2) { - return GL_FALSE; - } - - *reg |= (TD0_color_arg1mul_alpha1 | - TD0_color_blend_enable | - TD0_color_arg1add_mulout | - TD0_color_arg2add_mulout | - TD0_color_add_add | - TD0_color_sel_add); - - /* Have to do this with xor since GL_ONE_MINUS_SRC_ALPHA may have - * already touched this bit. - */ - *reg ^= TD0_color_alpha1inv_enable; - - if (args[0] == MGA_ARG2) { - /* Swap arguments */ - *reg ^= (TD0_color_arg1mul_alpha1 | - TD0_color_arg2mul_alpha2 | - TD0_color_alpha1inv_enable | - TD0_color_alpha2inv_enable); - } - - if (ctx->Texture._EnabledUnits != 0x03) { - /* Linear blending mode needs dualtex enabled */ - *(reg+1) = (TD0_color_arg2_prevstage | - TD0_color_sel_arg2 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2); - mmesa->force_dualtex = GL_TRUE; - } - break; - case GL_SUBTRACT: - if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) { - /* Can't get alpha to the adder */ - return GL_FALSE; - } - if (texUnit->Combine.ScaleShiftRGB == 1) { - *reg |= TD0_color_add2x_enable; - } else if (texUnit->Combine.ScaleShiftRGB == 2) { - return GL_FALSE; - } - - *reg |= (TD0_color_add_sub | - TD0_color_sel_add); - - if (args[0] == MGA_ARG2) { - /* Swap arguments */ - *reg ^= (TD0_color_arg1_inv_enable | - TD0_color_arg2_inv_enable); - } - break; - case GL_MODULATE_SIGNED_ADD_ATI: - *reg |= TD0_color_addbias_enable; - /* fallthrough */ - case GL_MODULATE_ADD_ATI: - if (args[1] == MGA_ALPHA) { - /* Can't get alpha to the adder */ - return GL_FALSE; - } - if (texUnit->Combine.ScaleShiftRGB == 1) { - *reg |= TD0_color_add2x_enable; - } else if (texUnit->Combine.ScaleShiftRGB == 2) { - return GL_FALSE; - } - - *reg |= (TD0_color_add_add | - TD0_color_sel_add); - - if (args[1] == args[0] || args[1] == args[2]) { - *reg |= TD0_color_arg1add_mulout; - if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA) - *reg |= TD0_color_arg1mul_alpha1; - - if (args[1] == MGA_ARG1) { - /* Swap adder arguments */ - *reg ^= (TD0_color_arg1add_mulout | - TD0_color_arg2add_mulout); - if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA) { - /* Swap multiplier arguments */ - *reg ^= (TD0_color_arg1mul_alpha1 | - TD0_color_arg2mul_alpha2); - } - } - } else { - *reg |= (TD0_color_arg2mul_alpha2 | - TD0_color_arg1add_mulout); - - if (args[1] == MGA_ARG1) { - /* Swap arguments */ - *reg ^= (TD0_color_arg1mul_alpha1 | - TD0_color_arg2mul_alpha2 | - TD0_color_arg1add_mulout | - TD0_color_arg2add_mulout); - } - } - break; - case GL_MODULATE_SUBTRACT_ATI: - if (args[1] != MGA_ARG2) { - /* Can't swap arguments */ - return GL_FALSE; - } - if (texUnit->Combine.ScaleShiftRGB == 1) { - *reg |= TD0_color_add2x_enable; - } else if (texUnit->Combine.ScaleShiftRGB == 2) { - return GL_FALSE; - } - - *reg |= (TD0_color_add_sub | - TD0_color_sel_add); - - if (args[1] == args[0] || args[1] == args[2]) { - *reg |= TD0_color_arg1add_mulout; - if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA) - *reg |= TD0_color_arg1mul_alpha1; - } else { - *reg |= (TD0_color_arg2mul_alpha2 | - TD0_color_arg1add_mulout); - } - break; - } - - - /* ALPHA */ - for (i = 0; i < 2; i++) { - arg1[i] = 0; - arg2[i] = 0; - } - - for (i = 0; i < numAlphaArgs; i++) { - switch (texUnit->Combine.SourceA[i]) { - case GL_TEXTURE: - arg1[i] |= 0; - arg2[i] |= ARG_DISABLE; - break; - case GL_TEXTURE0: - if (source == 0) { - arg1[i] |= 0; - arg2[i] |= ARG_DISABLE; - } else { - if (ctx->Texture._EnabledUnits != 0x03) { - /* disable texturing */ - mmesa->setup.dwgctl &= DC_opcod_MASK; - mmesa->setup.dwgctl |= DC_opcod_trap; - mmesa->hw.alpha_sel = AC_alphasel_diffused; - /* return GL_TRUE since we don't need a fallback */ - return GL_TRUE; - } - arg1[i] |= ARG_DISABLE; - arg2[i] |= TD0_alpha_arg2_prevtex; - } - break; - case GL_TEXTURE1: - if (source == 0) { - if (ctx->Texture._EnabledUnits != 0x03) { - /* disable texturing */ - mmesa->setup.dwgctl &= DC_opcod_MASK; - mmesa->setup.dwgctl |= DC_opcod_trap; - mmesa->hw.alpha_sel = AC_alphasel_diffused; - /* return GL_TRUE since we don't need a fallback */ - return GL_TRUE; - } - arg1[i] |= ARG_DISABLE; - /* G400 specs (TDUALSTAGE0) */ - arg2[i] |= TD0_alpha_arg2_prevstage; - } else { - arg1[i] |= 0; - arg2[i] |= ARG_DISABLE; - } - break; - case GL_CONSTANT: - if (mmesa->fcol_used && - mmesa->envcolor[source] != mmesa->envcolor[!source]) - return GL_FALSE; - - arg1[i] |= ARG_DISABLE; - arg2[i] |= TD0_alpha_arg2_fcol; - - mmesa->setup.fcol = mmesa->envcolor[source]; - mmesa->fcol_used = GL_TRUE; - break; - case GL_PRIMARY_COLOR: - arg1[i] |= ARG_DISABLE; - /* G400 specs (TDUALSTAGE1) */ - if (unit == 0 || (mmesa->setup.tdualstage0 & - ((TD0_color_sel_mul & TD0_color_sel_add) | - (TD0_alpha_sel_mul & TD0_alpha_sel_add)))) { - arg2[i] |= TD0_alpha_arg2_diffuse; - } else { - arg2[i] |= ARG_DISABLE; - } - break; - case GL_PREVIOUS: - arg1[i] |= ARG_DISABLE; - if (unit == 0) { - arg2[i] |= TD0_alpha_arg2_diffuse; - } else { - arg2[i] |= TD0_alpha_arg2_prevstage; - } - break; - default: - return GL_FALSE; - } - - switch (texUnit->Combine.OperandA[i]) { - case GL_SRC_ALPHA: - arg1[i] |= 0; - arg2[i] |= 0; - break; - case GL_ONE_MINUS_SRC_ALPHA: - arg1[i] |= TD0_alpha_arg1_inv_enable; - arg2[i] |= TD0_alpha_arg2_inv_enable; - break; - } - } - - /* Find a working combo of arg1 and arg2 */ - if ((arg1[0] | arg2[1]) != ARG_DISABLE) { - *reg |= arg1[0] | arg2[1]; - args[0] = MGA_ARG1; args[1] = MGA_ARG2; - } else - if ((arg1[1] | arg2[0]) != ARG_DISABLE) { - *reg |= arg1[1] | arg2[0]; - args[0] = MGA_ARG2; args[1] = MGA_ARG1; - } else { - /* nothing suitable */ - return GL_FALSE; - } - - switch (texUnit->Combine.ModeA) { - case GL_REPLACE: - if (texUnit->Combine.ScaleShiftA) { - return GL_FALSE; - } - - if (args[0] == MGA_ARG1) { - *reg |= TD0_alpha_sel_arg1; - } else if (args[0] == MGA_ARG2) { - *reg |= TD0_alpha_sel_arg2; - } - break; - case GL_MODULATE: - if (texUnit->Combine.ScaleShiftA == 1) { - *reg |= TD0_alpha_modbright_2x; - } else if (texUnit->Combine.ScaleShiftA == 2) { - *reg |= TD0_alpha_modbright_4x; - } - - *reg |= TD0_alpha_sel_mul; - break; - case GL_ADD_SIGNED: - *reg |= TD0_alpha_addbias_enable; - /* fallthrough */ - case GL_ADD: - if (texUnit->Combine.ScaleShiftA == 1) { - *reg |= TD0_alpha_add2x_enable; - } else if (texUnit->Combine.ScaleShiftA == 2) { - return GL_FALSE; - } - - *reg |= (TD0_alpha_add_enable | - TD0_alpha_sel_add); - break; - case GL_SUBTRACT: - if (texUnit->Combine.ScaleShiftA == 1) { - *reg |= TD0_alpha_add2x_enable; - } else if (texUnit->Combine.ScaleShiftA == 2) { - return GL_FALSE; - } - - *reg |= (TD0_alpha_add_disable | - TD0_alpha_sel_add); - - if (args[0] == MGA_ARG2) { - /* Swap arguments */ - *reg ^= (TD0_alpha_arg1_inv_enable | - TD0_alpha_arg2_inv_enable); - } - break; - } - - return GL_TRUE; -} - - diff --git a/src/mesa/drivers/dri/mga/mga_texstate.c b/src/mesa/drivers/dri/mga/mga_texstate.c deleted file mode 100644 index 33ad8b42560..00000000000 --- a/src/mesa/drivers/dri/mga/mga_texstate.c +++ /dev/null @@ -1,898 +0,0 @@ -/* - * Copyright 2000-2001 VA Linux Systems, Inc. - * (c) Copyright IBM Corporation 2002 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to 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, IBM 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: - * Ian Romanick <[email protected]> - * Keith Whitwell <[email protected]> - */ - -#include "main/context.h" -#include "main/enums.h" -#include "main/macros.h" -#include "main/mm.h" -#include "main/imports.h" -#include "main/simple_list.h" - -#include "mgacontext.h" -#include "mgatex.h" -#include "mgaregs.h" -#include "mgatris.h" -#include "mgaioctl.h" - -#define MGA_USE_TABLE_FOR_FORMAT -#ifdef MGA_USE_TABLE_FOR_FORMAT -#define TMC_nr_tformat (MESA_FORMAT_YCBCR_REV + 1) -static const unsigned TMC_tformat[ TMC_nr_tformat ] = -{ - [MESA_FORMAT_ARGB8888] = TMC_tformat_tw32, - [MESA_FORMAT_RGB565] = TMC_tformat_tw16, - [MESA_FORMAT_ARGB4444] = TMC_tformat_tw12, - [MESA_FORMAT_ARGB1555] = TMC_tformat_tw15, - [MESA_FORMAT_AL88] = TMC_tformat_tw8al, - [MESA_FORMAT_I8] = TMC_tformat_tw8a, - [MESA_FORMAT_CI8] = TMC_tformat_tw8 , - [MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy, - [MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422, -}; -#endif - -static void -mgaSetTexImages( mgaContextPtr mmesa, - const struct gl_texture_object * tObj ) -{ - mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData; - struct gl_texture_image *baseImage = tObj->Image[0][ tObj->BaseLevel ]; - GLint totalSize; - GLint width, height; - GLint i; - GLint numLevels; - GLint log2Width, log2Height; - GLuint txformat = 0; - GLint ofs; - - /* Set the hardware texture format - */ -#ifndef MGA_USE_TABLE_FOR_FORMAT - switch (baseImage->TexFormat->MesaFormat) { - - case MESA_FORMAT_ARGB8888: txformat = TMC_tformat_tw32; break; - case MESA_FORMAT_RGB565: txformat = TMC_tformat_tw16; break; - case MESA_FORMAT_ARGB4444: txformat = TMC_tformat_tw12; break; - case MESA_FORMAT_ARGB1555: txformat = TMC_tformat_tw15; break; - case MESA_FORMAT_AL88: txformat = TMC_tformat_tw8al; break; - case MESA_FORMAT_I8: txformat = TMC_tformat_tw8a; break; - case MESA_FORMAT_CI8: txformat = TMC_tformat_tw8; break; - case MESA_FORMAT_YCBCR: txformat = TMC_tformat_tw422uyvy; break; - case MESA_FORMAT_YCBCR_REV: txformat = TMC_tformat_tw422; break; - - default: - _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__); - return; - } -#else - if ( (baseImage->TexFormat >= TMC_nr_tformat) - || (TMC_tformat[ baseImage->TexFormat ] == 0) ) - { - _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__); - return; - } - - txformat = TMC_tformat[ baseImage->TexFormat ]; - -#endif /* MGA_USE_TABLE_FOR_FORMAT */ - - driCalculateTextureFirstLastLevel( (driTextureObject *) t ); - if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) { - log2Width = 0; - log2Height = 0; - } else { - log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2; - log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2; - } - - width = tObj->Image[0][t->base.firstLevel]->Width; - height = tObj->Image[0][t->base.firstLevel]->Height; - - numLevels = MIN2( t->base.lastLevel - t->base.firstLevel + 1, - MGA_IS_G200(mmesa) ? G200_TEX_MAXLEVELS : G400_TEX_MAXLEVELS); - - - totalSize = 0; - for ( i = 0 ; i < numLevels ; i++ ) { - const struct gl_texture_image * const texImage = - tObj->Image[0][ i + t->base.firstLevel ]; - int size; - - if (texImage == NULL) - break; - - size = texImage->Width * texImage->Height * - _mesa_get_format_bytes(baseImage->TexFormat); - - t->offsets[i] = totalSize; - t->base.dirty_images[0] |= (1<<i); - - /* All mipmaps must be 32-byte aligned */ - totalSize += (size + 31) & ~31; - - /* Since G400 calculates the offsets in hardware - * it can't handle more than one < 32 byte mipmap. - * - * Further testing has indicated that it can't - * handle any < 32 byte mipmaps. - */ - if (MGA_IS_G400( mmesa ) && size <= 32) { - i++; - break; - } - } - - /* save these values */ - numLevels = i; - t->base.lastLevel = t->base.firstLevel + numLevels - 1; - t->base.totalSize = totalSize; - - /* setup hardware register values */ - t->setup.texctl &= (TMC_tformat_MASK & TMC_tpitch_MASK - & TMC_tpitchext_MASK); - t->setup.texctl |= txformat; - - - /* Set the texture width. In order to support non-power of 2 textures and - * textures larger than 1024 texels wide, "linear" pitch must be used. For - * the linear pitch, if the width is 2048, a value of zero is used. - */ - - t->setup.texctl |= TMC_tpitchlin_enable; - t->setup.texctl |= MGA_FIELD( TMC_tpitchext, width & (2048 - 1) ); - - - /* G400 specifies the number of mip levels in a strange way. Since there - * are up to 11 levels, it requires 4 bits. Three of the bits are at the - * high end of TEXFILTER. The other bit is in the middle. Weird. - */ - numLevels--; - t->setup.texfilter &= TF_mapnb_MASK & TF_mapnbhigh_MASK & TF_reserved_MASK; - t->setup.texfilter |= MGA_FIELD( TF_mapnb, numLevels & 0x7 ); - t->setup.texfilter |= MGA_FIELD( TF_mapnbhigh, (numLevels >> 3) & 0x1 ); - - /* warp texture registers */ - ofs = MGA_IS_G200(mmesa) ? 28 : 11; - - t->setup.texwidth = (MGA_FIELD(TW_twmask, width - 1) | - MGA_FIELD(TW_rfw, (10 - log2Width - 8) & 63 ) | - MGA_FIELD(TW_tw, (log2Width + ofs ) | 0x40 )); - - t->setup.texheight = (MGA_FIELD(TH_thmask, height - 1) | - MGA_FIELD(TH_rfh, (10 - log2Height - 8) & 63 ) | - MGA_FIELD(TH_th, (log2Height + ofs ) | 0x40 )); - - mgaUploadTexImages( mmesa, t ); -} - - -/* ================================================================ - * Texture unit state management - */ - -static void mgaUpdateTextureEnvG200( struct gl_context *ctx, GLuint unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current; - mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData; - GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - if (tObj != ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX] && - tObj != ctx->Texture.Unit[0].CurrentTex[TEXTURE_RECT_INDEX]) - return; - - - t->setup.texctl &= ~TMC_tmodulate_enable; - t->setup.texctl2 &= ~(TMC_decalblend_enable | - TMC_idecal_enable | - TMC_decaldis_enable); - - switch (ctx->Texture.Unit[0].EnvMode) { - case GL_REPLACE: - if (format == GL_ALPHA) - t->setup.texctl2 |= TMC_idecal_enable; - - if (format == GL_RGB || format == GL_LUMINANCE) - mmesa->hw.alpha_sel = AC_alphasel_diffused; - else - mmesa->hw.alpha_sel = AC_alphasel_fromtex; - break; - - case GL_MODULATE: - t->setup.texctl |= TMC_tmodulate_enable; - - if (format == GL_ALPHA) - t->setup.texctl2 |= (TMC_idecal_enable | - TMC_decaldis_enable); - - if (format == GL_RGB || format == GL_LUMINANCE) - mmesa->hw.alpha_sel = AC_alphasel_diffused; - else - mmesa->hw.alpha_sel = AC_alphasel_modulated; - break; - - case GL_DECAL: - if (format == GL_RGB || format == GL_RGBA) - t->setup.texctl2 |= TMC_decalblend_enable; - else - t->setup.texctl2 |= TMC_idecal_enable; - - mmesa->hw.alpha_sel = AC_alphasel_diffused; - break; - - case GL_BLEND: - if (format == GL_ALPHA) { - t->setup.texctl2 |= TMC_idecal_enable; - mmesa->hw.alpha_sel = AC_alphasel_modulated; - } else { - t->texenv_fallback = GL_TRUE; - } - break; - - default: - break; - } -} - - -#define MGA_REPLACE 0 -#define MGA_MODULATE 1 -#define MGA_DECAL 2 -#define MGA_ADD 3 -#define MGA_MAX_COMBFUNC 4 - -static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] = -{ - /* Unit 0: - */ - { - /* GL_REPLACE - * Cv = Cs - * Av = Af - */ - (TD0_color_sel_arg1 | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2), - - /* GL_MODULATE - * Cv = Cf Cs - * Av = Af - */ - (TD0_color_arg2_diffuse | - TD0_color_sel_mul | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2), - - /* GL_DECAL - * Cv = Cs - * Av = Af - */ - (TD0_color_sel_arg1 | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2), - - /* GL_ADD - * Cv = Cf + Cs - * Av = Af - */ - (TD0_color_arg2_diffuse | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2), - }, - - /* Unit 1: - */ - { - /* GL_REPLACE - * Cv = Cs - * Av = Ap - */ - (TD0_color_sel_arg1 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2), - - /* GL_MODULATE - * Cv = Cp Cs - * Av = Ap - */ - (TD0_color_arg2_prevstage | - TD0_color_sel_mul | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2), - - /* GL_DECAL - * Cv = Cs - * Av = Ap - */ - (TD0_color_sel_arg1 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2), - - /* GL_ADD - * Cv = Cp + Cs - * Av = Ap - */ - (TD0_color_arg2_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2), - }, -}; - -static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] = -{ - /* Unit 0: - */ - { - /* GL_REPLACE - * Cv = Cs - * Av = As - */ - (TD0_color_sel_arg1 | - TD0_alpha_sel_arg1), - - /* GL_MODULATE - * Cv = Cf Cs - * Av = Af As - */ - (TD0_color_arg2_diffuse | - TD0_color_sel_mul | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul), - - /* GL_DECAL - * tmp = Cf ( 1 - As ) - * Cv = tmp + Cs As - * Av = Af - */ - (TD0_color_arg2_diffuse | - TD0_color_alpha_currtex | - TD0_color_alpha1inv_enable | - TD0_color_arg1mul_alpha1 | - TD0_color_blend_enable | - TD0_color_arg1add_mulout | - TD0_color_arg2add_mulout | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2), - - /* GL_ADD - * Cv = Cf + Cs - * Av = Af As - */ - (TD0_color_arg2_diffuse | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul), - }, - - /* Unit 1: - */ - { - /* GL_REPLACE - * Cv = Cs - * Av = As - */ - (TD0_color_sel_arg1 | - TD0_alpha_sel_arg1), - - /* GL_MODULATE - * Cv = Cp Cs - * Av = Ap As - */ - (TD0_color_arg2_prevstage | - TD0_color_sel_mul | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_mul), - - /* GL_DECAL - * tmp = Cp ( 1 - As ) - * Cv = tmp + Cs As - * Av = Ap - */ - (TD0_color_arg2_prevstage | - TD0_color_alpha_currtex | - TD0_color_alpha1inv_enable | - TD0_color_arg1mul_alpha1 | - TD0_color_blend_enable | - TD0_color_arg1add_mulout | - TD0_color_arg2add_mulout | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2), - - /* GL_ADD - * Cv = Cp + Cs - * Av = Ap As - */ - (TD0_color_arg2_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_mul), - }, -}; - -static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] = -{ - /* Unit 0: - */ - { - /* GL_REPLACE - * Cv = Cf - * Av = As - */ - (TD0_color_arg2_diffuse | - TD0_color_sel_arg2 | - TD0_alpha_sel_arg1), - - /* GL_MODULATE - * Cv = Cf - * Av = Af As - */ - (TD0_color_arg2_diffuse | - TD0_color_sel_arg2 | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul), - - /* GL_DECAL (undefined) - * Cv = Cf - * Av = Af - */ - (TD0_color_arg2_diffuse | - TD0_color_sel_arg2 | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2), - - /* GL_ADD - * Cv = Cf - * Av = Af As - */ - (TD0_color_arg2_diffuse | - TD0_color_sel_arg2 | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul), - }, - - /* Unit 1: - */ - { - /* GL_REPLACE - * Cv = Cp - * Av = As - */ - (TD0_color_arg2_prevstage | - TD0_color_sel_arg2 | - TD0_alpha_sel_arg1), - - /* GL_MODULATE - * Cv = Cp - * Av = Ap As - */ - (TD0_color_arg2_prevstage | - TD0_color_sel_arg2 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_mul), - - /* GL_DECAL (undefined) - * Cv = Cp - * Av = Ap - */ - (TD0_color_arg2_prevstage | - TD0_color_sel_arg2 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2), - - /* GL_ADD - * Cv = Cp - * Av = Ap As - */ - (TD0_color_arg2_prevstage | - TD0_color_sel_arg2 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_mul), - }, -}; - -static GLboolean mgaUpdateTextureEnvBlend( struct gl_context *ctx, int unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - const int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - const struct gl_texture_object *tObj = texUnit->_Current; - GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit); - GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - *reg = 0; - - if (format == GL_ALPHA) { - /* Cv = Cf */ - *reg |= (TD0_color_arg2_diffuse | - TD0_color_sel_arg2); - /* Av = Af As */ - *reg |= (TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul); - return GL_TRUE; - } - - /* C1 = Cf ( 1 - Cs ) */ - *reg |= (TD0_color_arg1_inv_enable | - TD0_color_arg2_diffuse | - TD0_color_sel_mul); - - if (format == GL_RGB || format == GL_LUMINANCE) { - /* A1 = Af */ - *reg |= (TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2); - } else - if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) { - /* A1 = Af As */ - *reg |= (TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul); - } else - if (format == GL_INTENSITY) { - /* A1 = Af ( 1 - As ) */ - *reg |= (TD0_alpha_arg1_inv_enable | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul); - } - - if (RGB_ZERO(mmesa->envcolor[source]) && - (format != GL_INTENSITY || ALPHA_ZERO(mmesa->envcolor[source]))) - return GL_TRUE; /* all done */ - - if (ctx->Texture._EnabledUnits == 0x03) - return GL_FALSE; /* need both units */ - - mmesa->force_dualtex = GL_TRUE; - reg = &mmesa->setup.tdualstage1; - *reg = 0; - - if (RGB_ZERO(mmesa->envcolor[source])) { - /* Cv = C1 */ - *reg |= (TD0_color_arg2_prevstage | - TD0_color_sel_arg2); - } else - if (RGB_ONE(mmesa->envcolor[source])) { - /* Cv = C1 + Cs */ - *reg |= (TD0_color_arg2_prevstage | - TD0_color_add_add | - TD0_color_sel_add); - } else - if (RGBA_EQUAL(mmesa->envcolor[source])) { - /* Cv = C1 + Cc Cs */ - *reg |= (TD0_color_arg2_prevstage | - TD0_color_alpha_fcol | - TD0_color_arg2mul_alpha2 | - TD0_color_arg1add_mulout | - TD0_color_add_add | - TD0_color_sel_add); - - mmesa->setup.fcol = mmesa->envcolor[source]; - } else { - return GL_FALSE; - } - - if (format != GL_INTENSITY || ALPHA_ZERO(mmesa->envcolor[source])) { - /* Av = A1 */ - *reg |= (TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2); - } else - if (ALPHA_ONE(mmesa->envcolor[source])) { - /* Av = A1 + As */ - *reg |= (TD0_alpha_arg2_prevstage | - TD0_alpha_add_enable | - TD0_alpha_sel_add); - } else { - return GL_FALSE; - } - - return GL_TRUE; -} - -static void mgaUpdateTextureEnvG400( struct gl_context *ctx, GLuint unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - const int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - const struct gl_texture_object *tObj = texUnit->_Current; - GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit); - mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData; - GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - if (tObj != ctx->Texture.Unit[source].CurrentTex[TEXTURE_2D_INDEX] && - tObj != ctx->Texture.Unit[source].CurrentTex[TEXTURE_RECT_INDEX]) - return; - - switch (ctx->Texture.Unit[source].EnvMode) { - case GL_REPLACE: - if (format == GL_ALPHA) { - *reg = g400_alpha_combine[unit][MGA_REPLACE]; - } else if (format == GL_RGB || format == GL_LUMINANCE) { - *reg = g400_color_combine[unit][MGA_REPLACE]; - } else { - *reg = g400_color_alpha_combine[unit][MGA_REPLACE]; - } - break; - - case GL_MODULATE: - if (format == GL_ALPHA) { - *reg = g400_alpha_combine[unit][MGA_MODULATE]; - } else if (format == GL_RGB || format == GL_LUMINANCE) { - *reg = g400_color_combine[unit][MGA_MODULATE]; - } else { - *reg = g400_color_alpha_combine[unit][MGA_MODULATE]; - } - break; - - case GL_DECAL: - if (format == GL_RGB) { - *reg = g400_color_combine[unit][MGA_DECAL]; - } else if (format == GL_RGBA) { - *reg = g400_color_alpha_combine[unit][MGA_DECAL]; - if (ctx->Texture._EnabledUnits != 0x03) { - /* Linear blending mode needs dual texturing enabled */ - *(reg+1) = (TD0_color_arg2_prevstage | - TD0_color_sel_arg2 | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2); - mmesa->force_dualtex = GL_TRUE; - } - } else { - /* Undefined */ - *reg = g400_alpha_combine[unit][MGA_DECAL]; - } - break; - - case GL_ADD: - if (format == GL_ALPHA) { - *reg = g400_alpha_combine[unit][MGA_ADD]; - } else if (format == GL_RGB || format == GL_LUMINANCE) { - *reg = g400_color_combine[unit][MGA_ADD]; - } else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) { - *reg = g400_color_alpha_combine[unit][MGA_ADD]; - } else if (format == GL_INTENSITY) { - /* Cv = Cf + Cs - * Av = Af + As - */ - if (unit == 0) { - *reg = (TD0_color_arg2_diffuse | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_add_enable | - TD0_alpha_sel_add); - } else { - *reg = (TD0_color_arg2_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_add_enable | - TD0_alpha_sel_add); - } - } - break; - - case GL_BLEND: - if (!mgaUpdateTextureEnvBlend(ctx, unit)) - t->texenv_fallback = GL_TRUE; - break; - - case GL_COMBINE: - if (!mgaUpdateTextureEnvCombine(ctx, unit)) - t->texenv_fallback = GL_TRUE; - break; - default: - break; - } -} - -static void disable_tex( struct gl_context *ctx, int unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - /* Texture unit disabled */ - - if ( mmesa->CurrentTexObj[unit] != NULL ) { - /* The old texture is no longer bound to this texture unit. - * Mark it as such. - */ - - mmesa->CurrentTexObj[unit]->base.bound &= ~(1UL << unit); - mmesa->CurrentTexObj[unit] = NULL; - } - - if ( unit != 0 && !mmesa->force_dualtex ) { - mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0; - } - - if ( ctx->Texture._EnabledUnits == 0 ) { - mmesa->setup.dwgctl &= DC_opcod_MASK; - mmesa->setup.dwgctl |= DC_opcod_trap; - mmesa->hw.alpha_sel = AC_alphasel_diffused; - } - - mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit); -} - -static GLboolean enable_tex( struct gl_context *ctx, int unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - const int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - const struct gl_texture_object *tObj = texUnit->_Current; - mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData; - - /* Upload teximages (not pipelined) - */ - if (t->base.dirty_images[0]) { - FLUSH_BATCH( mmesa ); - mgaSetTexImages( mmesa, tObj ); - if ( t->base.memBlock == NULL ) { - return GL_FALSE; - } - } - - return GL_TRUE; -} - -static GLboolean update_tex_common( struct gl_context *ctx, int unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - const int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - struct gl_texture_object *tObj = texUnit->_Current; - mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData; - - /* Fallback if there's a texture border */ - if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) { - return GL_FALSE; - } - - - /* Update state if this is a different texture object to last - * time. - */ - if ( mmesa->CurrentTexObj[unit] != t ) { - if ( mmesa->CurrentTexObj[unit] != NULL ) { - /* The old texture is no longer bound to this texture unit. - * Mark it as such. - */ - - mmesa->CurrentTexObj[unit]->base.bound &= ~(1UL << unit); - } - - mmesa->CurrentTexObj[unit] = t; - t->base.bound |= (1UL << unit); - - driUpdateTextureLRU( (driTextureObject *) t ); /* done too often */ - } - - /* register setup */ - if ( unit == 1 ) { - mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0; - } - - t->texenv_fallback = GL_FALSE; - - /* Set this before mgaUpdateTextureEnvG400() since - * GL_ARB_texture_env_crossbar may have to disable texturing. - */ - mmesa->setup.dwgctl &= DC_opcod_MASK; - mmesa->setup.dwgctl |= DC_opcod_texture_trap; - - /* FIXME: The Radeon has some cached state so that it can avoid calling - * FIXME: UpdateTextureEnv in some cases. Is that possible here? - */ - if (MGA_IS_G400(mmesa)) { - /* G400: Regardless of texture env mode, we use the alpha from the - * texture unit (AC_alphasel_fromtex) since it will have already - * been modulated by the incoming fragment color, if needed. - * We don't want (AC_alphasel_modulate) since that'll effectively - * do the modulation twice. - */ - mmesa->hw.alpha_sel = AC_alphasel_fromtex; - - mgaUpdateTextureEnvG400( ctx, unit ); - } else { - mgaUpdateTextureEnvG200( ctx, unit ); - } - - t->setup.texctl2 &= TMC_dualtex_MASK; - if (ctx->Texture._EnabledUnits == 0x03 || mmesa->force_dualtex) { - t->setup.texctl2 |= TMC_dualtex_enable; - } - - mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit); - - FALLBACK( ctx, MGA_FALLBACK_BORDER_MODE, t->border_fallback ); - return !t->border_fallback && !t->texenv_fallback; -} - - -static GLboolean updateTextureUnit( struct gl_context *ctx, int unit ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - const int source = mmesa->tmu_source[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; - - - if ( texUnit->_ReallyEnabled == TEXTURE_2D_BIT || - texUnit->_ReallyEnabled == TEXTURE_RECT_BIT ) { - return(enable_tex( ctx, unit ) && - update_tex_common( ctx, unit )); - } - else if ( texUnit->_ReallyEnabled ) { - return GL_FALSE; - } - else { - disable_tex( ctx, unit ); - return GL_TRUE; - } -} - -/* The G400 is now programmed quite differently wrt texture environment. - */ -void mgaUpdateTextureState( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - GLboolean ok; - unsigned i; - - mmesa->force_dualtex = GL_FALSE; - mmesa->fcol_used = GL_FALSE; - - /* This works around a quirk with the MGA hardware. If only OpenGL - * TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The - * hardware TEXTURE1 can ONLY be used when hardware TEXTURE0 is also used. - */ - - mmesa->tmu_source[0] = 0; - mmesa->tmu_source[1] = 1; - - if ((ctx->Texture._EnabledUnits & 0x03) == 0x02) { - /* only texture 1 enabled */ - mmesa->tmu_source[0] = 1; - mmesa->tmu_source[1] = 0; - } - - for ( i = 0, ok = GL_TRUE - ; (i < ctx->Const.MaxTextureUnits) && ok - ; i++ ) { - ok = updateTextureUnit( ctx, i ); - } - - FALLBACK( ctx, MGA_FALLBACK_TEXTURE, !ok ); -} diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c deleted file mode 100644 index 6ec99dbc3ba..00000000000 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ /dev/null @@ -1,1005 +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. - */ - -/** - * \file mga_xmesa.c - * MGA screen and context initialization / creation code. - * - * \author Keith Whitwell <[email protected]> - */ - -#include <stdlib.h> -#include <stdint.h> -#include "drm.h" -#include "mga_drm.h" -#include "mga_xmesa.h" -#include "main/context.h" -#include "main/simple_list.h" -#include "main/imports.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "vbo/vbo.h" - -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "mgadd.h" -#include "mgastate.h" -#include "mgatex.h" -#include "mgaspan.h" -#include "mgaioctl.h" -#include "mgatris.h" -#include "mgavb.h" -#include "mgapixel.h" -#include "mga_dri.h" - -#include "utils.h" -#include "vblank.h" - -#include "drirenderbuffer.h" - -#include "GL/internal/dri_interface.h" - -#define need_GL_ARB_vertex_array_object -#define need_GL_ARB_vertex_program -#define need_GL_EXT_fog_coord -#define need_GL_EXT_gpu_program_parameters -#define need_GL_EXT_secondary_color -#if 0 -#define need_GL_EXT_paletted_texture -#endif -#define need_GL_APPLE_vertex_array_object -#define need_GL_NV_vertex_program -#include "main/remap_helper.h" - -/* MGA configuration - */ -#include "xmlpool.h" - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_QUALITY - DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_SOFTWARE - DRI_CONF_ARB_VERTEX_PROGRAM(true) - DRI_CONF_NV_VERTEX_PROGRAM(true) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) - DRI_CONF_SECTION_END -DRI_CONF_END; -static const GLuint __driNConfigOptions = 6; - -#ifndef MGA_DEBUG -int MGA_DEBUG = 0; -#endif - -static const __DRIconfig ** -mgaFillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - struct gl_config * m; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - int i; - - /* GLX_SWAP_COPY_OML is only supported because the MGA driver doesn't - * support pageflipping at all. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML - }; - - uint8_t depth_bits_array[3]; - uint8_t stencil_bits_array[3]; - uint8_t msaa_samples_array[1]; - - - depth_bits_array[0] = 0; - depth_bits_array[1] = depth_bits; - depth_bits_array[2] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = 0; - stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGR; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const __DRIconfig **) configs; -} - -const __DRIextension *mgaScreenExtensions[] = { - &driReadDrawableExtension, - &driSwapControlExtension.base, - &driMediaStreamCounterExtension.base, - NULL -}; - -static GLboolean -mgaInitDriver(__DRIscreen *sPriv) -{ - mgaScreenPrivate *mgaScreen; - MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv; - - if (sPriv->devPrivSize != sizeof(MGADRIRec)) { - fprintf(stderr,"\nERROR! sizeof(MGADRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate)); - if (!mgaScreen) { - __driUtilMessage("Couldn't malloc screen struct"); - return GL_FALSE; - } - - mgaScreen->sPriv = sPriv; - sPriv->private = (void *)mgaScreen; - - if (sPriv->drm_version.minor >= 1) { - int ret; - drm_mga_getparam_t gp; - - gp.param = MGA_PARAM_IRQ_NR; - gp.value = &mgaScreen->irq; - mgaScreen->irq = 0; - - ret = drmCommandWriteRead( sPriv->fd, DRM_MGA_GETPARAM, - &gp, sizeof(gp)); - if (ret) { - fprintf(stderr, "drmMgaGetParam (MGA_PARAM_IRQ_NR): %d\n", ret); - FREE(mgaScreen); - sPriv->private = NULL; - return GL_FALSE; - } - } - - sPriv->extensions = mgaScreenExtensions; - - if (serverInfo->chipset != MGA_CARD_TYPE_G200 && - serverInfo->chipset != MGA_CARD_TYPE_G400) { - FREE(mgaScreen); - sPriv->private = NULL; - __driUtilMessage("Unrecognized chipset"); - return GL_FALSE; - } - - - mgaScreen->chipset = serverInfo->chipset; - mgaScreen->cpp = serverInfo->cpp; - - mgaScreen->agpMode = serverInfo->agpMode; - - mgaScreen->frontPitch = serverInfo->frontPitch; - mgaScreen->frontOffset = serverInfo->frontOffset; - mgaScreen->backOffset = serverInfo->backOffset; - mgaScreen->backPitch = serverInfo->backPitch; - mgaScreen->depthOffset = serverInfo->depthOffset; - mgaScreen->depthPitch = serverInfo->depthPitch; - - - /* The only reason that the MMIO region needs to be accessable and the - * primary DMA region base address needs to be known is so that the driver - * can busy wait for certain DMA operations to complete (see - * mgaWaitForFrameCompletion in mgaioctl.c). - * - * Starting with MGA DRM version 3.2, these are completely unneeded as - * there is a new, in-kernel mechanism for handling the wait. - */ - - if (mgaScreen->sPriv->drm_version.minor < 2) { - mgaScreen->mmio.handle = serverInfo->registers.handle; - mgaScreen->mmio.size = serverInfo->registers.size; - if ( drmMap( sPriv->fd, - mgaScreen->mmio.handle, mgaScreen->mmio.size, - &mgaScreen->mmio.map ) < 0 ) { - FREE( mgaScreen ); - sPriv->private = NULL; - __driUtilMessage( "Couldn't map MMIO registers" ); - return GL_FALSE; - } - - mgaScreen->primary.handle = serverInfo->primary.handle; - mgaScreen->primary.size = serverInfo->primary.size; - } - else { - (void) memset( & mgaScreen->primary, 0, sizeof( mgaScreen->primary ) ); - (void) memset( & mgaScreen->mmio, 0, sizeof( mgaScreen->mmio ) ); - } - - mgaScreen->textureOffset[MGA_CARD_HEAP] = serverInfo->textureOffset; - mgaScreen->textureOffset[MGA_AGP_HEAP] = (serverInfo->agpTextureOffset | - PDEA_pagpxfer_enable | 1); - - mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize; - mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize; - - - /* The texVirtual array stores the base addresses in the CPU's address - * space of the texture memory pools. The base address of the on-card - * memory pool is calculated as an offset of the base of video memory. The - * AGP texture pool has to be mapped into the processes address space by - * the DRM. - */ - - mgaScreen->texVirtual[MGA_CARD_HEAP] = (char *)(mgaScreen->sPriv->pFB + - serverInfo->textureOffset); - - if ( serverInfo->agpTextureSize > 0 ) { - if (drmMap(sPriv->fd, serverInfo->agpTextureOffset, - serverInfo->agpTextureSize, - (drmAddress *)&mgaScreen->texVirtual[MGA_AGP_HEAP]) != 0) { - FREE(mgaScreen); - sPriv->private = NULL; - __driUtilMessage("Couldn't map agptexture region"); - return GL_FALSE; - } - } - - - /* For calculating setupdma addresses. - */ - - mgaScreen->bufs = drmMapBufs(sPriv->fd); - if (!mgaScreen->bufs) { - FREE(mgaScreen); - sPriv->private = NULL; - __driUtilMessage("Couldn't map dma buffers"); - return GL_FALSE; - } - mgaScreen->sarea_priv_offset = serverInfo->sarea_priv_offset; - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&mgaScreen->optionCache, - __driConfigOptions, __driNConfigOptions); - - return GL_TRUE; -} - - -static void -mgaDestroyScreen(__DRIscreen *sPriv) -{ - mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private; - - if (MGA_DEBUG&DEBUG_VERBOSE_DRI) - fprintf(stderr, "mgaDestroyScreen\n"); - - drmUnmapBufs(mgaScreen->bufs); - - - /* free all option information */ - driDestroyOptionInfo (&mgaScreen->optionCache); - - FREE(mgaScreen); - sPriv->private = NULL; -} - - -extern const struct tnl_pipeline_stage _mga_render_stage; - -static const struct tnl_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, - &_tnl_vertex_program_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, -}; - - -static const struct dri_extension g400_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_env_combine", NULL }, - { "GL_ARB_texture_env_crossbar", NULL }, - { "GL_EXT_texture_env_combine", NULL }, - { "GL_EXT_texture_edge_clamp", NULL }, - { "GL_ATI_texture_env_combine3", NULL }, - { NULL, NULL } -}; - -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_texture_rectangle", NULL }, - { "GL_ARB_vertex_array_object", GL_ARB_vertex_array_object_functions }, - { "GL_EXT_blend_logic_op", NULL }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - /* paletted_textures currently doesn't work, but we could fix them later */ -#if defined( need_GL_EXT_paletted_texture ) - { "GL_EXT_shared_texture_palette", NULL }, - { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions }, -#endif - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions }, - { "GL_MESA_ycbcr_texture", NULL }, - { NULL, NULL } -}; - -static const struct dri_extension ARB_vp_extensions[] = { - { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, - { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions }, - { NULL, NULL } -}; - -static const struct dri_extension NV_vp_extensions[] = { - { "GL_NV_vertex_program", GL_NV_vertex_program_functions }, - { "GL_NV_vertex_program1_1", NULL }, - { NULL, NULL } -}; - -static const struct dri_debug_control debug_control[] = -{ - { "fall", DEBUG_VERBOSE_FALLBACK }, - { "tex", DEBUG_VERBOSE_TEXTURE }, - { "ioctl", DEBUG_VERBOSE_IOCTL }, - { "verb", DEBUG_VERBOSE_MSG }, - { "dri", DEBUG_VERBOSE_DRI }, - { NULL, 0 } -}; - - -static GLboolean -mgaCreateContext( gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - int i; - unsigned maxlevels; - struct gl_context *ctx, *shareCtx; - mgaContextPtr mmesa; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private; - drm_mga_sarea_t *saPriv = (drm_mga_sarea_t *)(((char*)sPriv->pSAREA)+ - mgaScreen->sarea_priv_offset); - struct dd_function_table functions; - - if (MGA_DEBUG&DEBUG_VERBOSE_DRI) - fprintf(stderr, "mgaCreateContext\n"); - - /* allocate mga context */ - mmesa = (mgaContextPtr) CALLOC(sizeof(mgaContext)); - if (!mmesa) { - return GL_FALSE; - } - - /* Init default driver functions then plug in our Radeon-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions( &functions ); - mgaInitDriverFuncs( &functions ); - mgaInitTextureFuncs( &functions ); - mgaInitIoctlFuncs( &functions ); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((mgaContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - mmesa->glCtx = _mesa_create_context(API_OPENGL, mesaVis, shareCtx, - &functions, (void *) mmesa); - if (!mmesa->glCtx) { - FREE(mmesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = mmesa; - - /* Init mga state */ - mmesa->hHWContext = driContextPriv->hHWContext; - mmesa->driFd = sPriv->fd; - mmesa->driHwLock = &sPriv->pSAREA->lock; - - mmesa->mgaScreen = mgaScreen; - mmesa->driScreen = sPriv; - mmesa->sarea = (void *)saPriv; - - /* Parse configuration files */ - driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache, - sPriv->myNum, "mga"); - - (void) memset( mmesa->texture_heaps, 0, sizeof( mmesa->texture_heaps ) ); - make_empty_list( & mmesa->swapped ); - - mmesa->nr_heaps = mgaScreen->texVirtual[MGA_AGP_HEAP] ? 2 : 1; - for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) { - mmesa->texture_heaps[i] = driCreateTextureHeap( i, mmesa, - mgaScreen->textureSize[i], - 6, - MGA_NR_TEX_REGIONS, - (drmTextureRegionPtr)mmesa->sarea->texList[i], - &mmesa->sarea->texAge[i], - &mmesa->swapped, - sizeof( mgaTextureObject_t ), - (destroy_texture_object_t *) mgaDestroyTexObj ); - } - - /* Set the maximum texture size small enough that we can guarentee - * that both texture units can bind a maximal texture and have them - * on the card at once. - */ - ctx = mmesa->glCtx; - if ( mgaScreen->chipset == MGA_CARD_TYPE_G200 ) { - ctx->Const.MaxTextureUnits = 1; - ctx->Const.MaxTextureImageUnits = 1; - ctx->Const.MaxTextureCoordUnits = 1; - maxlevels = G200_TEX_MAXLEVELS; - - } - else { - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureImageUnits = 2; - ctx->Const.MaxTextureCoordUnits = 2; - maxlevels = G400_TEX_MAXLEVELS; - } - - driCalculateMaxTextureLevels( mmesa->texture_heaps, - mmesa->nr_heaps, - & ctx->Const, - 4, - 11, /* max 2D texture size is 2048x2048 */ - 0, /* 3D textures unsupported. */ - 0, /* cube textures unsupported. */ - 11, /* max texture rect size is 2048x2048 */ - maxlevels, - GL_FALSE, - 0 ); - - 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; - - ctx->Const.MaxDrawBuffers = 1; - - mmesa->texture_depth = driQueryOptioni (&mmesa->optionCache, - "texture_depth"); - if (mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB) - mmesa->texture_depth = ( mesaVis->rgbBits >= 24 ) ? - DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16; - mmesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24; - - switch (mesaVis->depthBits) { - case 16: - mmesa->depth_scale = 1.0/(GLdouble)0xffff; - mmesa->depth_clear_mask = ~0; - mmesa->ClearDepth = 0xffff; - break; - case 24: - mmesa->depth_scale = 1.0/(GLdouble)0xffffff; - if (mmesa->hw_stencil) { - mmesa->depth_clear_mask = 0xffffff00; - mmesa->stencil_clear_mask = 0x000000ff; - } else - mmesa->depth_clear_mask = ~0; - mmesa->ClearDepth = 0xffffff00; - break; - case 32: - mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; - mmesa->depth_clear_mask = ~0; - mmesa->ClearDepth = 0xffffffff; - break; - }; - - mmesa->haveHwStipple = GL_FALSE; - mmesa->RenderIndex = -1; /* impossible value */ - mmesa->dirty = ~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 ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, mga_pipeline ); - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - _tnl_allow_pixel_fog( ctx, GL_FALSE ); - _tnl_allow_vertex_fog( ctx, GL_TRUE ); - - mmesa->primary_offset = mmesa->mgaScreen->primary.handle; - - ctx->DriverCtx = (void *) mmesa; - mmesa->glCtx = ctx; - - driInitExtensions( ctx, card_extensions, GL_FALSE ); - - if (MGA_IS_G400(MGA_CONTEXT(ctx))) { - driInitExtensions( ctx, g400_extensions, GL_FALSE ); - } - - if ( driQueryOptionb( &mmesa->optionCache, "arb_vertex_program" ) ) { - driInitExtensions(ctx, ARB_vp_extensions, GL_FALSE); - } - - if ( driQueryOptionb( &mmesa->optionCache, "nv_vertex_program" ) ) { - driInitExtensions( ctx, NV_vp_extensions, GL_FALSE ); - } - - - /* XXX these should really go right after _mesa_init_driver_functions() */ - mgaDDInitStateFuncs( ctx ); - mgaDDInitSpanFuncs( ctx ); - mgaDDInitPixelFuncs( ctx ); - mgaDDInitTriFuncs( ctx ); - - mgaInitVB( ctx ); - mgaInitState( mmesa ); - - driContextPriv->driverPrivate = (void *) mmesa; - -#if DO_DEBUG - MGA_DEBUG = driParseDebugString( getenv( "MGA_DEBUG" ), - debug_control ); -#endif - - (*sPriv->systemTime->getUST)( & mmesa->swap_ust ); - - if (driQueryOptionb(&mmesa->optionCache, "no_rast")) { - fprintf(stderr, "disabling 3D acceleration\n"); - FALLBACK(mmesa->glCtx, MGA_FALLBACK_DISABLE, 1); - } - - return GL_TRUE; -} - -static void -mgaDestroyContext(__DRIcontext *driContextPriv) -{ - mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; - - if (MGA_DEBUG&DEBUG_VERBOSE_DRI) - fprintf( stderr, "[%s:%d] mgaDestroyContext start\n", - __FILE__, __LINE__ ); - - assert(mmesa); /* should never be null */ - if (mmesa) { - GLboolean release_texture_heaps; - - - release_texture_heaps = (mmesa->glCtx->Shared->RefCount == 1); - _swsetup_DestroyContext( mmesa->glCtx ); - _tnl_DestroyContext( mmesa->glCtx ); - _vbo_DestroyContext( mmesa->glCtx ); - _swrast_DestroyContext( mmesa->glCtx ); - - mgaFreeVB( mmesa->glCtx ); - - /* free the Mesa context */ - mmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(mmesa->glCtx); - - if ( release_texture_heaps ) { - /* This share group is about to go away, free our private - * texture object data. - */ - int i; - - for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) { - driDestroyTextureHeap( mmesa->texture_heaps[ i ] ); - mmesa->texture_heaps[ i ] = NULL; - } - - assert( is_empty_list( & mmesa->swapped ) ); - } - - /* free the option cache */ - driDestroyOptionCache (&mmesa->optionCache); - - FREE(mmesa); - } - - if (MGA_DEBUG&DEBUG_VERBOSE_DRI) - fprintf( stderr, "[%s:%d] mgaDestroyContext done\n", - __FILE__, __LINE__ ); -} - - -static GLboolean -mgaCreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap ) -{ - mgaScreenPrivate *screen = (mgaScreenPrivate *) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - GLboolean swStencil = (mesaVis->stencilBits > 0 && - mesaVis->depthBits != 24); - -#if 0 - driDrawPriv->driverPrivate = (void *) - _mesa_create_framebuffer(mesaVis, - GL_FALSE, /* software depth buffer? */ - swStencil, - mesaVis->accumRedBits > 0, - mesaVis->alphaBits > 0 ); -#else - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - NULL, - screen->cpp, - screen->frontOffset, screen->frontPitch, - driDrawPriv); - mgaSetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - NULL, - screen->cpp, - screen->backOffset, screen->backPitch, - driDrawPriv); - mgaSetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mgaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - /* XXX is this right? */ - if (mesaVis->stencilBits) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z24_S8, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mgaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z32, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mgaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - } - else if (mesaVis->depthBits == 32) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z32, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mgaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0 && !swStencil) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(MESA_FORMAT_S8, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - mgaSetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - swStencil, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; -#endif - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -mgaDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -static void -mgaSwapBuffers(__DRIdrawable *dPriv) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - mgaContextPtr mmesa; - struct gl_context *ctx; - mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = mmesa->glCtx; - - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( ctx ); - mgaCopyBuffer( dPriv ); - } - } else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "%s: drawable has no context!\n", __FUNCTION__); - } -} - -static GLboolean -mgaUnbindContext(__DRIcontext *driContextPriv) -{ - mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; - if (mmesa) - mmesa->dirty = ~0; - - return GL_TRUE; -} - -/* This looks buggy to me - the 'b' variable isn't used anywhere... - * Hmm - It seems that the drawable is already hooked in to - * driDrawablePriv. - * - * But why are we doing context initialization here??? - */ -static GLboolean -mgaMakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv) -{ - if (driContextPriv) { - mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; - - if (mmesa->driDrawable != driDrawPriv) { - if (driDrawPriv->swap_interval == (unsigned)-1) { - driDrawPriv->vblFlags = (mmesa->mgaScreen->irq == 0) - ? VBLANK_FLAG_NO_IRQ - : driGetDefaultVBlankFlags(&mmesa->optionCache); - - driDrawableInitVBlank( driDrawPriv ); - } - - mmesa->driDrawable = driDrawPriv; - mmesa->dirty = ~0; - mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); - } - - mmesa->driReadable = driReadPriv; - - _mesa_make_current(mmesa->glCtx, - (struct gl_framebuffer *) driDrawPriv->driverPrivate, - (struct gl_framebuffer *) driReadPriv->driverPrivate); - } - else { - _mesa_make_current(NULL, NULL, NULL); - } - - return GL_TRUE; -} - - -void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) -{ - __DRIdrawable *dPriv = mmesa->driDrawable; - drm_mga_sarea_t *sarea = mmesa->sarea; - int me = mmesa->hHWContext; - int i; - - drmGetLock(mmesa->driFd, mmesa->hHWContext, flags); - - DRI_VALIDATE_DRAWABLE_INFO( mmesa->driScreen, dPriv ); - if (*(dPriv->pStamp) != mmesa->lastStamp) { - mmesa->lastStamp = *(dPriv->pStamp); - mmesa->SetupNewInputs |= VERT_BIT_POS; - mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); - mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) ); - driUpdateFramebufferSize(mmesa->glCtx, dPriv); - } - - mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS; - - mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT; - - if (sarea->ctxOwner != me) { - mmesa->dirty |= (MGA_UPLOAD_CONTEXT | MGA_UPLOAD_TEX0 | - MGA_UPLOAD_TEX1 | MGA_UPLOAD_PIPE); - sarea->ctxOwner=me; - } - - for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) { - DRI_AGE_TEXTURES( mmesa->texture_heaps[ i ] ); - } -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig **mgaInitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { 1, 2, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 3, 0, 0 }; - MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions2( "MGA", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) - return NULL; - - - if (!mgaInitDriver(psp)) - return NULL; - - return mgaFillInModes( psp, - dri_priv->cpp * 8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); -} - - -/** - * Get information about previous buffer swaps. - */ -static int -getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo ) -{ - mgaContextPtr mmesa; - - if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL) - || (dPriv->driContextPriv->driverPrivate == NULL) - || (sInfo == NULL) ) { - return -1; - } - - mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate; - sInfo->swap_count = mmesa->swap_count; - sInfo->swap_ust = mmesa->swap_ust; - sInfo->swap_missed_count = mmesa->swap_missed_count; - - sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0) - ? driCalculateSwapUsage( dPriv, 0, mmesa->swap_missed_ust ) - : 0.0; - - return 0; -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = mgaInitScreen, - .DestroyScreen = mgaDestroyScreen, - .CreateContext = mgaCreateContext, - .DestroyContext = mgaDestroyContext, - .CreateBuffer = mgaCreateBuffer, - .DestroyBuffer = mgaDestroyBuffer, - .SwapBuffers = mgaSwapBuffers, - .MakeCurrent = mgaMakeCurrent, - .UnbindContext = mgaUnbindContext, - .GetSwapInfo = getSwapInfo, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.h b/src/mesa/drivers/dri/mga/mga_xmesa.h deleted file mode 100644 index aee146090c0..00000000000 --- a/src/mesa/drivers/dri/mga/mga_xmesa.h +++ /dev/null @@ -1,154 +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 <[email protected]> - */ - -#ifndef _MGA_INIT_H_ -#define _MGA_INIT_H_ - -#include <sys/time.h> -#include "dri_util.h" -#include "mga_drm.h" -#include "main/mtypes.h" -#include "mgaregs.h" -#include "xmlconfig.h" - -typedef struct mga_screen_private_s { - /** - * Chipset "family" of this card. Currently only \c MGA_CARD_TYPE_G200 and - * \c MGA_CARD_TYPE_G400 are possible. - */ - int chipset; - - - /** - * Characters (bytes) per-pixel for both the front and back buffers. - * - * \note - * This is also implicitly the bytes per-pixel for the depth-buffer. - */ - int cpp; - - GLint agpMode; - unsigned int irq; /**< IRQ number (0 means none) */ - - unsigned int frontOffset; - unsigned int frontPitch; - unsigned int backOffset; - unsigned int backPitch; - - unsigned int depthOffset; - unsigned int depthPitch; - - unsigned int textureOffset[MGA_NR_TEX_HEAPS]; - unsigned int textureSize[MGA_NR_TEX_HEAPS]; - char *texVirtual[MGA_NR_TEX_HEAPS]; - - - __DRIscreen *sPriv; - drmBufMapPtr bufs; - - drmRegion mmio; - drmRegion primary; - unsigned int sarea_priv_offset; - - /** Configuration cache with default values for all contexts */ - driOptionCache optionCache; -} mgaScreenPrivate; - - -/** - * mgaRenderbuffer, derived from Mesa's gl_renderbuffer - */ -typedef struct { - struct gl_renderbuffer Base; - /* XXX per-window info should go here */ - int foo, bar; -} mgaRenderbuffer; - - - -#include "mgacontext.h" - -extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags ); -extern void mgaEmitHwStateLocked( mgaContextPtr mmesa ); -extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit ); - -#define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch - - - -/* Lock the hardware and validate our state. - */ -#define LOCK_HARDWARE( mmesa ) \ - do { \ - char __ret=0; \ - DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \ - (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \ - if (__ret) \ - mgaGetLock( mmesa, 0 ); \ - } while (0) - - -/* - */ -#define LOCK_HARDWARE_QUIESCENT( mmesa ) do { \ - LOCK_HARDWARE( mmesa ); \ - UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); \ -} while (0) - - -/* Unlock the hardware using the global current context - */ -#define UNLOCK_HARDWARE(mmesa) \ - DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext); - - -/* Freshen our snapshot of the drawables - */ -#define REFRESH_DRAWABLE_INFO( mmesa ) \ -do { \ - LOCK_HARDWARE( mmesa ); \ - mmesa->lastX = mmesa->drawX; \ - mmesa->lastY = mmesa->drawY; \ - UNLOCK_HARDWARE( mmesa ); \ -} while (0) - - -#define GET_DRAWABLE_LOCK( mmesa ) while(0) -#define RELEASE_DRAWABLE_LOCK( mmesa ) while(0) - - -/* The 2D driver macros are busted -- we can't use them here as they - * rely on the 2D driver data structures rather than taking an explicit - * base address. - */ -#define MGA_BASE( reg ) ((unsigned long)(mmesa->mgaScreen->mmio.map)) -#define MGA_ADDR( reg ) (MGA_BASE(reg) + reg) - -#define MGA_DEREF( reg ) *(volatile uint32_t *)MGA_ADDR( reg ) -#define MGA_READ( reg ) MGA_DEREF( reg ) - -#endif diff --git a/src/mesa/drivers/dri/mga/mgacontext.h b/src/mesa/drivers/dri/mga/mgacontext.h deleted file mode 100644 index b1fbb3c45d6..00000000000 --- a/src/mesa/drivers/dri/mga/mgacontext.h +++ /dev/null @@ -1,359 +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 <[email protected]> - */ - -#ifndef MGALIB_INC -#define MGALIB_INC - -#include <stdint.h> -#include "drm.h" -#include "mga_drm.h" -#include "dri_util.h" -#include "xf86drm.h" -#include "main/mtypes.h" -#include "main/mm.h" -#include "main/colormac.h" -#include "main/macros.h" -#include "texmem.h" -#include "xmlconfig.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)) - -#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G200) -#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400) - - -/* SoftwareFallback - * - texture env GL_BLEND -- can be fixed - * - 1D and 3D textures - * - incomplete textures - * - GL_DEPTH_FUNC == GL_NEVER not in h/w - */ -#define MGA_FALLBACK_TEXTURE 0x1 -#define MGA_FALLBACK_DRAW_BUFFER 0x2 -#define MGA_FALLBACK_READ_BUFFER 0x4 -#define MGA_FALLBACK_BLEND 0x8 -#define MGA_FALLBACK_RENDERMODE 0x10 -#define MGA_FALLBACK_STENCIL 0x20 -#define MGA_FALLBACK_DEPTH 0x40 -#define MGA_FALLBACK_BORDER_MODE 0x80 -#define MGA_FALLBACK_DISABLE 0x100 - - -/* Use the templated vertex formats: - */ -#define TAG(x) mga##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -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 * ); - - - -/* Texture environment color - */ -#define RGB_ZERO(c) (((c) & 0xffffff) == 0x000000) -#define RGB_ONE(c) (((c) & 0xffffff) == 0xffffff) -#define ALPHA_ZERO(c) (((c) >> 24) == 0x00) -#define ALPHA_ONE(c) (((c) >> 24) == 0xff) -#define RGBA_EQUAL(c) ((c) == PACK_COLOR_8888( (c) & 0xff, (c) & 0xff, \ - (c) & 0xff, (c) & 0xff )) - -struct mga_texture_object_s; -struct mga_screen_private_s; - -#define G200_TEX_MAXLEVELS 5 -#define G400_TEX_MAXLEVELS 11 - -typedef struct mga_texture_object_s -{ - driTextureObject base; - - /* The G200 only has the ability to use 5 mipmap levels (including the - * base level). The G400 does not have this restriction, but it still - * only has 5 offset pointers in the hardware. The trick on the G400 is - * upto the first 4 offset pointers point to mipmap levels. The last - * offset pointer tells how large the preceeding mipmap is. This value is - * then used to determine where the remaining mipmaps are. - * - * For example, if the first offsets[0] through offsets[2] are used as - * pointers, then offset[3] will be the size of the mipmap pointed to by - * offsets[2]. So mipmap level 3 will be at (offsets[2]+offsets[3]). For - * each successive mipmap level, offsets[3] is divided by 4 and added to - * the previous address. So mipmap level 4 will be at - * (offsets[2]+offsets[3]+(offsets[3] / 4)). - * - * The last pointer is selected by setting TO_texorgoffsetsel in its - * pointer. In the previous example, offset[2] would have - * TO_texorgoffsetsel or'ed in before writing it to the hardware. - * - * In the current driver all of the mipmaps are packed together linearly - * with mipmap level 0. Therefore offsets[0] points to the base of the - * texture (and has TO_texorgoffsetsel or'ed in), and offsets[1] is the - * size of the base texture. - * - * There is a possible optimization available here. At times the driver - * may not be able to allocate a single block of memory for the complete - * texture without ejecting some other textures from memory. It may be - * possible to put some of the lower mipmap levels (i.e., the larger - * mipmaps) in memory separate from the higher levels. - * - * The implementation should be fairly obvious, but getting "right" would - * likely be non-trivial. A first allocation for the entire texture would - * be attempted with a flag that says "don't eject other textures." If - * that failed, an additional allocation would be attmpted for just the - * base map. The process would repeat with the block of lower maps. The - * tricky parts would be in detecting when some of the levels had been - * ejected from texture memory by other textures and preventing the - * 4th allocation (for all the smallest mipmap levels) from kicking out - * any of the first three. - * - * This array holds G400_TEX_MAXLEVELS pointers to remove an if-statement - * in a loop in mgaSetTexImages. Values past G200_TEX_MAXLEVELS are not - * used. - */ - GLuint offsets[G400_TEX_MAXLEVELS]; - - int texelBytes; - GLuint age; - - drm_mga_texture_regs_t setup; - - /* If one texture dimension wraps with GL_CLAMP and the other with - * GL_CLAMP_TO_EDGE, we have to fallback to software. We would also have - * to fallback for GL_CLAMP_TO_BORDER. - */ - GLboolean border_fallback; - /* Depending on multitxturing and environment color - * GL_BLEND may have to be a software fallback. - */ - GLboolean texenv_fallback; -} mgaTextureObject_t; - -struct mga_hw_state { - GLuint specen; - GLuint cull; - GLuint cull_dualtex; - GLuint stencil; - GLuint stencilctl; - GLuint stencil_enable; - GLuint zmode; - GLuint rop; - GLuint alpha_func; - GLuint alpha_func_enable; - GLuint blend_func; - GLuint blend_func_enable; - GLuint alpha_sel; -}; - -struct mga_context_t { - - struct gl_context *glCtx; - unsigned int lastStamp; /* fullscreen breaks dpriv->laststamp, - * need to shadow it here. */ - - /* Hardware state management - */ - struct mga_hw_state hw; - - /* Bookkeeping for texturing - */ - unsigned nr_heaps; - driTexHeap * texture_heaps[ MGA_NR_TEX_HEAPS ]; - driTextureObject swapped; - - struct mga_texture_object_s *CurrentTexObj[2]; - - - /* Map GL texture units onto hardware. - */ - GLuint tmu_source[2]; - - int texture_depth; - - /* Manage fallbacks - */ - GLuint Fallback; - - /* Texture environment color. - */ - unsigned int envcolor[2]; - GLboolean fcol_used; - GLboolean force_dualtex; - - /* Rasterization state - */ - GLuint SetupNewInputs; - GLuint SetupIndex; - GLuint RenderIndex; - - GLuint hw_primitive; - GLenum raster_primitive; - GLenum render_primitive; - - GLubyte *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 NewGLState; - GLuint dirty; - - drm_mga_context_regs_t setup; - - GLuint ClearColor; - GLuint ClearDepth; - GLuint poly_stipple; - GLfloat depth_scale; - - GLuint depth_clear_mask; - GLuint stencil_clear_mask; - GLuint hw_stencil; - GLuint haveHwStipple; - GLfloat hw_viewport[16]; - - /* Dma buffers - */ - drmBufPtr vertex_dma_buffer; - drmBufPtr iload_buffer; - - int64_t swap_ust; - int64_t swap_missed_ust; - - GLuint swap_count; - GLuint swap_missed_count; - - uint32_t last_frame_fence; - - /* Drawable, cliprect and scissor information - */ - int dirty_cliprects; /* which sets of cliprects are uptodate? */ - int draw_buffer; /* which buffer are we rendering to */ - unsigned int drawOffset; /* draw buffer address in space */ - int readOffset; - int drawX, drawY; /* origin of drawable in draw buffer */ - int lastX, lastY; /* detect DSTORG bug */ - GLuint numClipRects; /* cliprects for the draw buffer */ - drm_clip_rect_t *pClipRects; - drm_clip_rect_t draw_rect; - drm_clip_rect_t scissor_rect; - int scissor; - - drm_clip_rect_t tmp_boxes[2][MGA_NR_SAREA_CLIPRECTS]; - - - /* Texture aging and DMA based aging. - */ - unsigned int texAge[MGA_NR_TEX_HEAPS];/* texture LRU age */ - unsigned int dirtyAge; /* buffer age for synchronization */ - - GLuint primary_offset; - - /* Mirrors of some DRI state. - */ - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - __DRIdrawable *driDrawable; - __DRIdrawable *driReadable; - - __DRIscreen *driScreen; - struct mga_screen_private_s *mgaScreen; - drm_mga_sarea_t *sarea; - - /* Configuration cache - */ - driOptionCache optionCache; -}; - -#define MGA_CONTEXT(ctx) ((mgaContextPtr)(ctx->DriverCtx)) - - - - -/* ================================================================ - * Debugging: - */ -#define DO_DEBUG 1 - -#if DO_DEBUG -extern int MGA_DEBUG; -#else -#define MGA_DEBUG 0 -#endif - -#define DEBUG_VERBOSE_MSG 0x01 -#define DEBUG_VERBOSE_DRI 0x02 -#define DEBUG_VERBOSE_IOCTL 0x04 -#define DEBUG_VERBOSE_TEXTURE 0x08 -#define DEBUG_VERBOSE_FALLBACK 0x10 - -static INLINE GLuint mgaPackColor(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; - } -} - - -/* - * Subpixel offsets for window coordinates: - */ -#define SUBPIXEL_X (-0.5F) -#define SUBPIXEL_Y (-0.5F + 0.125) - - -#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/src/mesa/drivers/dri/mga/mgadd.c b/src/mesa/drivers/dri/mga/mgadd.c deleted file mode 100644 index 2e3e9f2c43c..00000000000 --- a/src/mesa/drivers/dri/mga/mgadd.c +++ /dev/null @@ -1,70 +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 <[email protected]> - */ - - -#include "main/mtypes.h" -#include "main/framebuffer.h" -#include "main/mm.h" - -#include "mgacontext.h" -#include "mgadd.h" -#include "mga_xmesa.h" -#include "utils.h" - -/*************************************** - * Mesa's Driver Functions - ***************************************/ - - -static const GLubyte *mgaGetString( struct gl_context *ctx, GLenum name ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - static char buffer[128]; - unsigned offset; - - switch ( name ) { - case GL_VENDOR: - return (GLubyte *) "VA Linux Systems Inc."; - - case GL_RENDERER: - offset = driGetRendererString( buffer, - MGA_IS_G400(mmesa) ? "G400" : - MGA_IS_G200(mmesa) ? "G200" : "MGA", - mmesa->mgaScreen->agpMode ); - - return (GLubyte *)buffer; - - default: - return NULL; - } -} - - -void mgaInitDriverFuncs( struct dd_function_table *functions ) -{ - functions->GetString = mgaGetString; -} diff --git a/src/mesa/drivers/dri/mga/mgadd.h b/src/mesa/drivers/dri/mga/mgadd.h deleted file mode 100644 index f92591df459..00000000000 --- a/src/mesa/drivers/dri/mga/mgadd.h +++ /dev/null @@ -1,35 +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 <[email protected]> - */ - -#ifndef MGADD_INC -#define MGADD_INC - -#include "main/context.h" - -extern void mgaInitDriverFuncs( struct dd_function_table *functions ); - -#endif diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c deleted file mode 100644 index a54d86a178d..00000000000 --- a/src/mesa/drivers/dri/mga/mgaioctl.c +++ /dev/null @@ -1,747 +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. - */ - -/** - * \file mgaioctl.c - * MGA IOCTL related wrapper functions. - * - * \author Keith Whitwell <[email protected]> - * \author Gareth Hughes <[email protected]> - */ - -#include <errno.h> -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/dd.h" -#include "swrast/swrast.h" - -#include "main/mm.h" -#include "drm.h" -#include "mga_drm.h" -#include "mgacontext.h" -#include "mgadd.h" -#include "mgastate.h" -#include "mgaioctl.h" - -#include "vblank.h" - - -static int -mgaSetFence( mgaContextPtr mmesa, uint32_t * fence ) -{ - int ret = ENOSYS; - - if ( mmesa->driScreen->drm_version.minor >= 2 ) { - ret = drmCommandWriteRead( mmesa->driScreen->fd, DRM_MGA_SET_FENCE, - fence, sizeof( uint32_t )); - if (ret) { - fprintf(stderr, "drmMgaSetFence: %d\n", ret); - exit(1); - } - } - - return ret; -} - - -static int -mgaWaitFence( mgaContextPtr mmesa, uint32_t fence, uint32_t * curr_fence ) -{ - int ret = ENOSYS; - - if ( mmesa->driScreen->drm_version.minor >= 2 ) { - uint32_t temp = fence; - - ret = drmCommandWriteRead( mmesa->driScreen->fd, - DRM_MGA_WAIT_FENCE, - & temp, sizeof( uint32_t )); - if (ret) { - fprintf(stderr, "drmMgaSetFence: %d\n", ret); - exit(1); - } - - if ( curr_fence ) { - *curr_fence = temp; - } - } - - return ret; -} - - -static void mga_iload_dma_ioctl(mgaContextPtr mmesa, - unsigned long dest, - int length) -{ - drmBufPtr buf = mmesa->iload_buffer; - drm_mga_iload_t iload; - int ret, i; - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "DRM_IOCTL_MGA_ILOAD idx %d dst %x length %d\n", - buf->idx, (int) dest, length); - - if ( (length & MGA_ILOAD_MASK) != 0 ) { - UNLOCK_HARDWARE( mmesa ); - fprintf( stderr, "%s: Invalid ILOAD datasize (%d), must be " - "multiple of %u.\n", __FUNCTION__, length, MGA_ILOAD_ALIGN ); - exit( 1 ); - } - - iload.idx = buf->idx; - iload.dstorg = dest; - iload.length = length; - - i = 0; - do { - ret = drmCommandWrite( mmesa->driFd, DRM_MGA_ILOAD, - &iload, sizeof(iload) ); - } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); - - if ( ret < 0 ) { - printf("send iload retcode = %d\n", ret); - exit(1); - } - - mmesa->iload_buffer = 0; - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "finished iload dma put\n"); - -} - -drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ) -{ - int idx = 0; - int size = 0; - drmDMAReq dma; - int retcode; - drmBufPtr buf; - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "Getting dma buffer\n"); - - dma.context = mmesa->hHWContext; - dma.send_count = 0; - dma.send_list = NULL; - dma.send_sizes = NULL; - dma.flags = 0; - dma.request_count = 1; - dma.request_size = MGA_BUFFER_SIZE; - dma.request_list = &idx; - dma.request_sizes = &size; - dma.granted_count = 0; - - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n", - dma.context, dma.request_count, - dma.request_size); - - while (1) { - retcode = drmDMA(mmesa->driFd, &dma); - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "retcode %d sz %d idx %d count %d\n", - retcode, - dma.request_sizes[0], - dma.request_list[0], - dma.granted_count); - - if (retcode == 0 && - dma.request_sizes[0] && - dma.granted_count) - break; - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "\n\nflush"); - - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); - } - - buf = &(mmesa->mgaScreen->bufs->list[idx]); - buf->used = 0; - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, - "drmDMA (get) returns size[0] 0x%x idx[0] %d\n" - "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n", - dma.request_sizes[0], dma.request_list[0], - buf->idx, buf->total, - buf->used, buf->address); - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "finished getbuffer\n"); - - return buf; -} - - - - -static void -mgaClear( struct gl_context *ctx, GLbitfield mask ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - __DRIdrawable *dPriv = mmesa->driDrawable; - GLuint flags = 0; - GLuint clear_color = mmesa->ClearColor; - GLuint clear_depth = 0; - GLuint color_mask = 0; - GLuint depth_mask = 0; - int ret; - int i; - static int nrclears; - drm_mga_clear_t clear; - GLint cx, cy, cw, ch; - - FLUSH_BATCH( mmesa ); - - if ( mask & BUFFER_BIT_FRONT_LEFT ) { - flags |= MGA_FRONT; - color_mask = mmesa->setup.plnwt; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if ( mask & BUFFER_BIT_BACK_LEFT ) { - flags |= MGA_BACK; - color_mask = mmesa->setup.plnwt; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if ( (mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask ) { - flags |= MGA_DEPTH; - clear_depth = (mmesa->ClearDepth & mmesa->depth_clear_mask); - depth_mask |= mmesa->depth_clear_mask; - mask &= ~BUFFER_BIT_DEPTH; - } - - if ( (mask & BUFFER_BIT_STENCIL) && mmesa->hw_stencil ) { - flags |= MGA_DEPTH; - clear_depth |= (ctx->Stencil.Clear & mmesa->stencil_clear_mask); - depth_mask |= mmesa->stencil_clear_mask; - mask &= ~BUFFER_BIT_STENCIL; - } - - if ( flags ) { - LOCK_HARDWARE( mmesa ); - - /* compute region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - - 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; - - 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); - drm_clip_rect_t *box = mmesa->pClipRects; - drm_clip_rect_t *b = mmesa->sarea->boxes; - int n = 0; - - if (cw != dPriv->w || ch != dPriv->h) { - /* clear subregion */ - 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 { - /* clear whole window */ - for ( ; i < nr ; i++) { - *b++ = 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 ); - - mmesa->sarea->nbox = n; - - clear.flags = flags; - clear.clear_color = clear_color; - clear.clear_depth = clear_depth; - clear.color_mask = color_mask; - clear.depth_mask = depth_mask; - ret = drmCommandWrite( mmesa->driFd, DRM_MGA_CLEAR, - &clear, sizeof(clear)); - 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 ); - } - - UNLOCK_HARDWARE( mmesa ); - mmesa->dirty |= MGA_UPLOAD_CLIPRECTS|MGA_UPLOAD_CONTEXT; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - - -/** - * Wait for the previous frame of rendering has completed. - * - * \param mmesa Hardware context pointer. - * - * \bug - * The loop in this function should have some sort of a timeout mechanism. - * - * \warning - * This routine used to assume that the hardware lock was held on entry. It - * now assumes that the lock is \b not held on entry. - */ - -static void mgaWaitForFrameCompletion( mgaContextPtr mmesa ) -{ - if ( mgaWaitFence( mmesa, mmesa->last_frame_fence, NULL ) == ENOSYS ) { - unsigned wait = 0; - GLuint last_frame; - GLuint last_wrap; - - - LOCK_HARDWARE( mmesa ); - last_frame = mmesa->sarea->last_frame.head; - last_wrap = mmesa->sarea->last_frame.wrap; - - /* The DMA routines in the kernel track a couple values in the SAREA - * that we use here. The number of times that the primary DMA buffer - * has "wrapped" around is tracked in last_wrap. In addition, the - * wrap count and the buffer position at the end of the last frame are - * stored in last_frame.wrap and last_frame.head. - * - * By comparing the wrap counts and the current DMA pointer value - * (read directly from the hardware) to last_frame.head, we can - * determine when the graphics processor has processed all of the - * commands for the last frame. - * - * In this case "last frame" means the frame of the *previous* swap- - * buffers call. This is done to prevent queuing a second buffer swap - * before the previous swap is executed. - */ - while ( 1 ) { - if ( last_wrap < mmesa->sarea->last_wrap || - ( last_wrap == mmesa->sarea->last_wrap && - last_frame <= (MGA_READ( MGAREG_PRIMADDRESS ) - - mmesa->primary_offset) ) ) { - break; - } - if ( 0 ) { - wait++; - fprintf( stderr, " last: head=0x%06x wrap=%d\n", - last_frame, last_wrap ); - fprintf( stderr, " head: head=0x%06lx wrap=%d\n", - (long)(MGA_READ( MGAREG_PRIMADDRESS ) - mmesa->primary_offset), - mmesa->sarea->last_wrap ); - } - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH ); - - UNLOCK_HARDWARE( mmesa ); - DO_USLEEP( 1 ); - LOCK_HARDWARE( mmesa ); - } - if ( wait ) - fprintf( stderr, "\n" ); - - UNLOCK_HARDWARE( mmesa ); - } -} - - -/* - * Copy the back buffer to the front buffer. - */ -void mgaCopyBuffer( __DRIdrawable *dPriv ) -{ - mgaContextPtr mmesa; - drm_clip_rect_t *pbox; - GLint nbox; - GLint ret; - GLint i; - GLboolean missed_target; - __DRIscreen *psp = dPriv->driScreenPriv; - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate; - - FLUSH_BATCH( mmesa ); - - mgaWaitForFrameCompletion( mmesa ); - driWaitForVBlank( dPriv, & missed_target ); - if ( missed_target ) { - mmesa->swap_missed_count++; - (void) (*psp->systemTime->getUST)( & mmesa->swap_missed_ust ); - } - LOCK_HARDWARE( mmesa ); - - /* Use the frontbuffer cliprects - */ - if (mmesa->dirty_cliprects & MGA_FRONT) - mgaUpdateRects( mmesa, MGA_FRONT ); - - - pbox = dPriv->pClipRects; - nbox = dPriv->numClipRects; - - for (i = 0 ; i < nbox ; ) - { - int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects); - drm_clip_rect_t *b = mmesa->sarea->boxes; - - mmesa->sarea->nbox = nr - i; - - for ( ; i < nr ; i++) - *b++ = pbox[i]; - - if (0) - fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n"); - - ret = drmCommandNone( mmesa->driFd, DRM_MGA_SWAP ); - if ( ret ) { - printf("send swap retcode = %d\n", ret); - exit(1); - } - } - - (void) mgaSetFence( mmesa, & mmesa->last_frame_fence ); - UNLOCK_HARDWARE( mmesa ); - - mmesa->dirty |= MGA_UPLOAD_CLIPRECTS; - mmesa->swap_count++; - (void) (*psp->systemTime->getUST)( & mmesa->swap_ust ); -} - - -/** - * Implement the hardware-specific portion of \c glFinish. - * - * Flushes all pending commands to the hardware and wait for them to finish. - * - * \param ctx Context where the \c glFinish command was issued. - * - * \sa glFinish, mgaFlush, mgaFlushDMA - */ -static void mgaFinish( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - uint32_t fence; - - - LOCK_HARDWARE( mmesa ); - if ( mmesa->vertex_dma_buffer != NULL ) { - mgaFlushVerticesLocked( mmesa ); - } - - if ( mgaSetFence( mmesa, & fence ) == 0 ) { - UNLOCK_HARDWARE( mmesa ); - (void) mgaWaitFence( mmesa, fence, NULL ); - } - else { - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) { - fprintf(stderr, "mgaRegetLockQuiescent\n"); - } - - UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); - UNLOCK_HARDWARE( mmesa ); - } -} - - -/** - * Flush all commands upto at least a certain point to the hardware. - * - * \note - * The term "wait" in the name of this function is misleading. It doesn't - * actually wait for anything. It just makes sure that the commands have - * been flushed to the hardware. - * - * \warning - * As the name implies, this function assumes that the hardware lock is - * held on entry. - */ -void mgaWaitAgeLocked( mgaContextPtr mmesa, int age ) -{ - if (GET_DISPATCH_AGE(mmesa) < age) { - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH ); - } -} - - -static GLboolean intersect_rect( drm_clip_rect_t *out, - const drm_clip_rect_t *a, - const drm_clip_rect_t *b ) -{ - *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; - - return ((out->x1 < out->x2) && (out->y1 < out->y2)); -} - - - - -static void age_mmesa( mgaContextPtr mmesa, int age ) -{ - if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->age = age; - if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->age = age; -} - - -void mgaFlushVerticesLocked( mgaContextPtr mmesa ) -{ - drm_clip_rect_t *pbox = mmesa->pClipRects; - int nbox = mmesa->numClipRects; - drmBufPtr buffer = mmesa->vertex_dma_buffer; - drm_mga_vertex_t vertex; - int i; - - mmesa->vertex_dma_buffer = 0; - - 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) - buffer->used = 0; - - if (nbox >= MGA_NR_SAREA_CLIPRECTS) - mmesa->dirty |= MGA_UPLOAD_CLIPRECTS; - -#if 0 - if (!buffer->used || !(mmesa->dirty & MGA_UPLOAD_CLIPRECTS)) - { - if (nbox == 1) - mmesa->sarea->nbox = 0; - else - mmesa->sarea->nbox = nbox; - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox); - - vertex.idx = buffer->idx; - vertex.used = buffer->used; - vertex.discard = 1; - drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX, - &vertex, sizeof(drmMGAVertex) ); - - age_mmesa(mmesa, mmesa->sarea->last_enqueue); - } - else -#endif - { - for (i = 0 ; i < nbox ; ) - { - int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox); - drm_clip_rect_t *b = mmesa->sarea->boxes; - int discard = 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; - buffer->used = 0; - } - } else { - mmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++) - *b++ = pbox[i]; - } - - /* Finished with the buffer? - */ - if (nr == nbox) - discard = 1; - - mmesa->sarea->dirty |= MGA_UPLOAD_CLIPRECTS; - - vertex.idx = buffer->idx; - vertex.used = buffer->used; - vertex.discard = discard; - drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX, - &vertex, sizeof(vertex) ); - - age_mmesa(mmesa, mmesa->sarea->last_enqueue); - } - } - - mmesa->dirty &= ~MGA_UPLOAD_CLIPRECTS; -} - -void mgaFlushVertices( mgaContextPtr mmesa ) -{ - LOCK_HARDWARE( mmesa ); - mgaFlushVerticesLocked( mmesa ); - UNLOCK_HARDWARE( mmesa ); -} - - -void mgaFireILoadLocked( mgaContextPtr mmesa, - GLuint offset, GLuint length ) -{ - if (!mmesa->iload_buffer) { - fprintf(stderr, "mgaFireILoad: no buffer\n"); - return; - } - - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "mgaFireILoad idx %d ofs 0x%x length %d\n", - mmesa->iload_buffer->idx, (int)offset, (int)length ); - - mga_iload_dma_ioctl( mmesa, offset, length ); -} - -void mgaGetILoadBufferLocked( mgaContextPtr mmesa ) -{ - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "mgaGetIloadBuffer (buffer now %p)\n", - (void *) mmesa->iload_buffer); - - mmesa->iload_buffer = mga_get_buffer_ioctl( mmesa ); -} - - -/** - * Implement the hardware-specific portion of \c glFlush. - * - * \param ctx Context to be flushed. - * - * \sa glFlush, mgaFinish, mgaFlushDMA - */ -static void mgaFlush( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - - LOCK_HARDWARE( mmesa ); - if ( mmesa->vertex_dma_buffer != NULL ) { - mgaFlushVerticesLocked( mmesa ); - } - - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH ); - UNLOCK_HARDWARE( mmesa ); -} - - -int mgaFlushDMA( int fd, drmLockFlags flags ) -{ - drm_lock_t lock; - int ret, i = 0; - - memset( &lock, 0, sizeof(lock) ); - - lock.flags = flags & (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH - | DRM_LOCK_FLUSH_ALL); - - do { - ret = drmCommandWrite( fd, DRM_MGA_FLUSH, &lock, sizeof(lock) ); - } while ( ret && errno == EBUSY && i++ < DRM_MGA_IDLE_RETRY ); - - if ( ret == 0 ) - return 0; - if ( errno != EBUSY ) - return -errno; - - if ( lock.flags & DRM_LOCK_QUIESCENT ) { - /* Only keep trying if we need quiescence. - */ - lock.flags &= ~(DRM_LOCK_FLUSH | DRM_LOCK_FLUSH_ALL); - - do { - ret = drmCommandWrite( fd, DRM_MGA_FLUSH, &lock, sizeof(lock) ); - } while ( ret && errno == EBUSY && i++ < DRM_MGA_IDLE_RETRY ); - } - - if ( ret == 0 ) { - return 0; - } else { - return -errno; - } -} - -void mgaInitIoctlFuncs( struct dd_function_table *functions ) -{ - functions->Clear = mgaClear; - functions->Flush = mgaFlush; - functions->Finish = mgaFinish; -} diff --git a/src/mesa/drivers/dri/mga/mgaioctl.h b/src/mesa/drivers/dri/mga/mgaioctl.h deleted file mode 100644 index 7a8660d2035..00000000000 --- a/src/mesa/drivers/dri/mga/mgaioctl.h +++ /dev/null @@ -1,110 +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 <[email protected]> - * Gareth Hughes <[email protected]> - */ - -#ifndef MGA_IOCTL_H -#define MGA_IOCTL_H - -#include "mgacontext.h" -#include "mga_xmesa.h" - -void mgaCopyBuffer( __DRIdrawable *dPriv ); -void mgaWaitForVBlank( mgaContextPtr mmesa ); - -void mgaGetILoadBufferLocked( mgaContextPtr mmesa ); -void mgaFireILoadLocked( mgaContextPtr mmesa, - GLuint offset, GLuint length ); - -void mgaWaitAgeLocked( mgaContextPtr mmesa, int age ); - -void mgaFlushVertices( mgaContextPtr mmesa ); -void mgaFlushVerticesLocked( mgaContextPtr mmesa ); -int mgaFlushDMA( int fd, drmLockFlags flags ); - -void mgaInitIoctlFuncs( struct dd_function_table *functions ); - -#define FLUSH_BATCH(mmesa) do { \ - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \ - fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \ - if (mmesa->vertex_dma_buffer) mgaFlushVertices(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 *mgaAllocDmaLow( mgaContextPtr mmesa, int bytes ) -{ - GLuint *head; - - /* If there is no DMA buffer currently allocated or the currently - * allocated DMA buffer doesn't have enough room left for this request, - * a new buffer will need to be allocated. - */ - if ( (mmesa->vertex_dma_buffer == NULL) - || ((mmesa->vertex_dma_buffer->used + bytes) - > mmesa->vertex_dma_buffer->total) ) { - LOCK_HARDWARE( mmesa ); - - /* In the case where the existing buffer does not have enough room, - * we need to flush it out to the hardware. - */ - if ( mmesa->vertex_dma_buffer != NULL ) { - 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; -} - - -#define UPDATE_LOCK( mmesa, flags ) \ -do { \ - GLint ret = mgaFlushDMA( mmesa->driFd, flags ); \ - if ( ret < 0 ) { \ - drmCommandNone( mmesa->driFd, DRM_MGA_RESET ); \ - UNLOCK_HARDWARE( mmesa ); \ - fprintf( stderr, "%s: flush return = %s (%d), flags = 0x%08x\n", \ - __FUNCTION__, strerror( -ret ), -ret, \ - (unsigned)(flags) ); \ - exit( 1 ); \ - } \ -} while (0) - -#endif diff --git a/src/mesa/drivers/dri/mga/mgapixel.c b/src/mesa/drivers/dri/mga/mgapixel.c deleted file mode 100644 index b8e365c714c..00000000000 --- a/src/mesa/drivers/dri/mga/mgapixel.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Copyright 2000 Compaq Computer Inc. and 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. - */ - -/** - * \file mgapixel.c - * Implement framebuffer pixel operations for MGA. - * - * \todo - * Someday the accelerated \c glReadPixels and \c glDrawPixels paths need to - * be resurrected. They are currently ifdef'ed out because they don't seem - * to work and they only get activated some very rare circumstances. - * - * \author Keith Whitwell <[email protected]> - * \author Gareth Hughes <[email protected]> - */ - -#include "main/mtypes.h" -#include "main/macros.h" -#include "mgadd.h" -#include "mgacontext.h" -#include "mgaioctl.h" -#include "mgapixel.h" -#include "mgastate.h" - -#include "swrast/swrast.h" -#include "main/imports.h" - -#if 0 -#define IS_AGP_MEM( mmesa, p ) \ - ((unsigned long)mmesa->mgaScreen->buffers.map <= ((unsigned long)p) && \ - (unsigned long)mmesa->mgaScreen->buffers.map + \ - (unsigned long)mmesa->mgaScreen->buffers.size > ((unsigned long)p)) -#define AGP_OFFSET( mmesa, p ) \ - (((unsigned long)p) - (unsigned long)mmesa->mgaScreen->buffers.map) - - -static GLboolean -check_depth_stencil_24_8( const struct gl_context *ctx, GLenum type, - const struct gl_pixelstore_attrib *packing, - const void *pixels, GLint sz, - GLint pitch ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - return ( type == GL_UNSIGNED_INT_24_8 && - ctx->Visual->DepthBits == 24 && - ctx->Visual->StencilBits == 8 && - mmesa->mgaScreen->cpp == 4 && - mmesa->hw_stencil && - !ctx->Pixel.IndexShift && - !ctx->Pixel.IndexOffset && - !ctx->Pixel.MapStencilFlag && - ctx->Pixel.DepthBias == 0.0 && - ctx->Pixel.DepthScale == 1.0 && - !packing->SwapBytes && - pitch % 32 == 0 && - pitch < 4096 ); -} - - -static GLboolean -check_depth( const struct gl_context *ctx, GLenum type, - const struct gl_pixelstore_attrib *packing, - const void *pixels, GLint sz, GLint pitch ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - if ( IS_AGP_MEM( mmesa, pixels ) && - !( ( type == GL_UNSIGNED_INT && mmesa->mgaScreen->cpp == 4 ) || - ( type == GL_UNSIGNED_SHORT && mmesa->mgaScreen->cpp == 2 ) ) ) - return GL_FALSE; - - return ( ctx->Pixel.DepthBias == 0.0 && - ctx->Pixel.DepthScale == 1.0 && - !packing->SwapBytes && - pitch % 32 == 0 && - pitch < 4096 ); -} - - -static GLboolean -check_color( const struct gl_context *ctx, GLenum type, GLenum format, - const struct gl_pixelstore_attrib *packing, - const void *pixels, GLint sz, GLint pitch ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint cpp = mmesa->mgaScreen->cpp; - - /* Can't do conversions on agp reads/draws. - */ - if ( IS_AGP_MEM( mmesa, pixels ) && - !( pitch % 32 == 0 && pitch < 4096 && - ( ( type == GL_UNSIGNED_BYTE && - cpp == 4 && format == GL_BGRA ) || - ( type == GL_UNSIGNED_INT_8_8_8_8 && - cpp == 4 && format == GL_BGRA ) || - ( type == GL_UNSIGNED_SHORT_5_6_5_REV && - cpp == 2 && format == GL_RGB ) ) ) ) - return GL_FALSE; - - return (!ctx->_ImageTransferState && - !packing->SwapBytes && - !packing->LsbFirst); -} - -static GLboolean -check_color_per_fragment_ops( const struct gl_context *ctx ) -{ - return (!( ctx->Color.AlphaEnabled || - ctx->Depth.Test || - ctx->Fog.Enabled || - ctx->Scissor.Enabled || - ctx->Stencil._Enabled || - !ctx->Color.ColorMask[0][0] || - !ctx->Color.ColorMask[0][1] || - !ctx->Color.ColorMask[0][2] || - !ctx->Color.ColorMask[0][3] || - ctx->Color.ColorLogicOpEnabled || - ctx->Texture._EnabledUnits - ) && - ctx->Current.RasterPosValid && - ctx->Pixel.ZoomX == 1.0F && - (ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F)); -} - -static GLboolean -check_depth_per_fragment_ops( const struct gl_context *ctx ) -{ - return ( ctx->Current.RasterPosValid && - ctx->Color.ColorMask[0][RCOMP] == 0 && - ctx->Color.ColorMask[0][BCOMP] == 0 && - ctx->Color.ColorMask[0][GCOMP] == 0 && - ctx->Color.ColorMask[0][ACOMP] == 0 && - ctx->Pixel.ZoomX == 1.0F && - ( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) ); -} - -/* In addition to the requirements for depth: - */ -#if defined(MESA_packed_depth_stencil) -static GLboolean -check_stencil_per_fragment_ops( const struct gl_context *ctx ) -{ - return ( !ctx->Pixel.IndexShift && - !ctx->Pixel.IndexOffset ); -} -#endif - - -static GLboolean -clip_pixelrect( const struct gl_context *ctx, - const struct gl_framebuffer *buffer, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height, - GLint *skipPixels, GLint *skipRows, - GLint *size ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - *width = MIN2(*width, MAX_WIDTH); /* redundant? */ - - /* left clipping */ - 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 (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - 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 (*height <= 0) - return GL_FALSE; - - *size = ((*y + *height - 1) * mmesa->mgaScreen->frontPitch + - (*x + *width - 1) * mmesa->mgaScreen->cpp); - - return GL_TRUE; -} - -static GLboolean -mgaTryReadPixels( struct gl_context *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); - GLint size, skipPixels, skipRows; - GLint pitch = pack->RowLength ? pack->RowLength : width; - GLboolean ok; - - GLuint planemask; - GLuint source; -#if 0 - drmMGABlit blit; - GLuint dest; - GLint source_pitch, dest_pitch; - GLint delta_sx, delta_sy; - GLint delta_dx, delta_dy; - GLint blit_height, ydir; -#endif - - if (!clip_pixelrect(ctx, ctx->ReadBuffer, - &x, &y, &width, &height, - &skipPixels, &skipRows, &size)) { - return GL_TRUE; - } - - /* Only accelerate reading to agp buffers. - */ - if ( !IS_AGP_MEM(mmesa, (char *)pixels) || - !IS_AGP_MEM(mmesa, (char *)pixels + size) ) - return GL_FALSE; - - switch (format) { - case GL_DEPTH_STENCIL: - ok = check_depth_stencil_24_8(ctx, type, pack, pixels, size, pitch); - planemask = ~0; - source = mmesa->mgaScreen->depthOffset; - break; - - case GL_DEPTH_COMPONENT: - ok = check_depth(ctx, type, pack, pixels, size, pitch); - - /* Can't accelerate at this depth -- planemask does the wrong - * thing; it doesn't clear the low order bits in the - * destination, instead it leaves them untouched. - * - * Could get the acclerator to solid fill the destination with - * zeros first... Or get the cpu to do it... - */ - if (ctx->Visual.depthBits == 24) - return GL_FALSE; - - planemask = ~0; - source = mmesa->mgaScreen->depthOffset; - break; - - case GL_RGB: - case GL_BGRA: - ok = check_color(ctx, type, format, pack, pixels, size, pitch); - planemask = ~0; - source = (mmesa->draw_buffer == MGA_FRONT ? - mmesa->mgaScreen->frontOffset : - mmesa->mgaScreen->backOffset); - break; - - default: - return GL_FALSE; - } - - if (!ok) { - return GL_FALSE; - } - - - LOCK_HARDWARE( mmesa ); - -#if 0 - { - __DRIdrawable *dPriv = mmesa->driDrawable; - int nbox, retcode, i; - - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); - - if (mmesa->dirty_cliprects & MGA_FRONT) - mgaUpdateRects( mmesa, MGA_FRONT ); - - nbox = dPriv->numClipRects; - - y = dPriv->h - y - height; - x += mmesa->drawX; - y += mmesa->drawY; - - dest = ((mmesa->mgaScreen->agp.handle + AGP_OFFSET(mmesa, pixels)) | - DO_dstmap_sys | DO_dstacc_agp); - source_pitch = mmesa->mgaScreen->frontPitch / mmesa->mgaScreen->cpp; - dest_pitch = pitch; - delta_sx = 0; - delta_sy = 0; - delta_dx = -x; - delta_dy = -y; - blit_height = 2*y + height; - ydir = -1; - - if (0) fprintf(stderr, "XX doing readpixel blit src_pitch %d dst_pitch %d\n", - source_pitch, dest_pitch); - - - - for (i = 0 ; i < nbox ; ) - { - int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects); - drm_clip_rect_t *box = dPriv->pClipRects; - drm_clip_rect_t *b = mmesa->sarea->boxes; - int n = 0; - - for ( ; i < nr ; i++) { - GLint bx = box[i].x1; - GLint by = box[i].y1; - GLint bw = box[i].x2 - bx; - GLint bh = box[i].y2 - by; - - if (bx < x) bw -= x - bx, bx = x; - if (by < y) bh -= y - by, by = y; - if (bx + bw > x + width) bw = x + width - bx; - if (by + bh > y + height) bh = y + height - by; - if (bw <= 0) continue; - if (bh <= 0) continue; - - b->x1 = bx; - b->y1 = by; - b->x2 = bx + bw; - b->y2 = by + bh; - b++; - n++; - } - - mmesa->sarea->nbox = n; - - if (n && (retcode = drmCommandWrite( mmesa->driFd, DRM_MGA_BLIT, - &blit, sizeof(drmMGABlit)))) { - fprintf(stderr, "blit ioctl failed, retcode = %d\n", retcode); - UNLOCK_HARDWARE( mmesa ); - exit(1); - } - } - - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); - } -#endif - - UNLOCK_HARDWARE( mmesa ); - - return GL_TRUE; -} - -static void -mgaDDReadPixels( struct gl_context *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( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint pitch, - const void *pixels, - GLuint dest, GLuint planemask) -{ -#if 0 - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - drmMGABlit blit; - __DRIdrawable *dPriv = mmesa->driDrawable; - drm_clip_rect_t pbox = dPriv->pClipRects; - int nbox = dPriv->numClipRects; - int retcode, i; - - y = dPriv->h - y - height; - x += mmesa->drawX; - y += mmesa->drawY; - - blit.dest = dest; - blit.planemask = planemask; - blit.source = ((mmesa->mgaScreen->agp.handle + AGP_OFFSET(mmesa, pixels)) - | SO_srcmap_sys | SO_srcacc_agp); - blit.dest_pitch = mmesa->mgaScreen->frontPitch / mmesa->mgaScreen->cpp; - blit.source_pitch = pitch; - blit.delta_sx = -x; - blit.delta_sy = -y; - blit.delta_dx = 0; - blit.delta_dy = 0; - if (ctx->Pixel.ZoomY == -1) { - blit.height = height; - blit.ydir = 1; - } else { - blit.height = height; - blit.ydir = -1; - } - - if (0) fprintf(stderr, - "doing drawpixel blit src_pitch %d dst_pitch %d\n", - blit.source_pitch, blit.dest_pitch); - - for (i = 0 ; i < nbox ; ) - { - int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects); - drm_clip_rect_t *box = mmesa->pClipRects; - drm_clip_rect_t *b = mmesa->sarea->boxes; - int n = 0; - - for ( ; i < nr ; i++) { - GLint bx = box[i].x1; - GLint by = box[i].y1; - GLint bw = box[i].x2 - bx; - GLint bh = box[i].y2 - by; - - if (bx < x) bw -= x - bx, bx = x; - if (by < y) bh -= y - by, by = y; - if (bx + bw > x + width) bw = x + width - bx; - if (by + bh > y + height) bh = y + height - by; - if (bw <= 0) continue; - if (bh <= 0) continue; - - b->x1 = bx; - b->y1 = by; - b->x2 = bx + bw; - b->y2 = by + bh; - b++; - n++; - } - - mmesa->sarea->nbox = n; - - if (n && (retcode = drmCommandWrite( mmesa->driFd, DRM_MGA_BLIT, - &blit, sizeof(drmMGABlit)))) { - fprintf(stderr, "blit ioctl failed, retcode = %d\n", retcode); - UNLOCK_HARDWARE( mmesa ); - exit(1); - } - } -#endif -} - - - - -static GLboolean -mgaTryDrawPixels( struct gl_context *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; - GLint pitch = unpack->RowLength ? unpack->RowLength : width; - GLuint dest, planemask; - GLuint cpp = mmesa->mgaScreen->cpp; - - if (!clip_pixelrect(ctx, ctx->DrawBuffer, - &x, &y, &width, &height, - &skipPixels, &skipRows, &size)) { - return GL_TRUE; - } - - - switch (format) { - case GL_DEPTH_STENCIL: - dest = mmesa->mgaScreen->depthOffset; - planemask = ~0; - if (!check_depth_stencil_24_8(ctx, type, unpack, pixels, size, pitch) || - !check_depth_per_fragment_ops(ctx) || - !check_stencil_per_fragment_ops(ctx)) - return GL_FALSE; - break; - - case GL_DEPTH_COMPONENT: - dest = mmesa->mgaScreen->depthOffset; - - if (ctx->Visual.depthBits == 24) - planemask = ~0xff; - else - planemask = ~0; - - if (!check_depth(ctx, type, unpack, pixels, size, pitch) || - !check_depth_per_fragment_ops(ctx)) - return GL_FALSE; - break; - - case GL_RGB: - case GL_BGRA: - dest = (mmesa->draw_buffer == MGA_FRONT ? - mmesa->mgaScreen->frontOffset : - mmesa->mgaScreen->backOffset); - - planemask = mgaPackColor(cpp, - ctx->Color.ColorMask[0][RCOMP], - ctx->Color.ColorMask[0][GCOMP], - ctx->Color.ColorMask[0][BCOMP], - ctx->Color.ColorMask[0][ACOMP]); - - if (cpp == 2) - planemask |= planemask << 16; - - if (!check_color(ctx, type, format, unpack, pixels, size, pitch)) { - return GL_FALSE; - } - if (!check_color_per_fragment_ops(ctx)) { - return GL_FALSE; - } - break; - - default: - return GL_FALSE; - } - - LOCK_HARDWARE_QUIESCENT( mmesa ); - - if (mmesa->dirty_cliprects & MGA_FRONT) - mgaUpdateRects( mmesa, MGA_FRONT ); - - if ( IS_AGP_MEM(mmesa, (char *)pixels) && - IS_AGP_MEM(mmesa, (char *)pixels + size) ) - { - do_draw_pix( ctx, x, y, width, height, pitch, pixels, - dest, planemask ); - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); - } - else - { - /* Pixels is in regular memory -- get dma buffers and perform - * upload through them. - */ -/* drmBufPtr buf = mgaGetBufferLocked(mmesa); */ - GLuint bufferpitch = (width*cpp+31)&~31; - - char *address = 0; /* mmesa->mgaScreen->agp.map; */ - - do { -/* GLuint rows = MIN2( height, MGA_DMA_BUF_SZ / bufferpitch ); */ - GLuint rows = height; - - - if (0) fprintf(stderr, "trying to upload %d rows (pitch %d)\n", - rows, bufferpitch); - - /* The texture conversion code is so slow that there is only - * negligble speedup when the buffers/images don't exactly - * match: - */ -#if 0 - if (cpp == 2) { - 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_texsubimage2d( MESA_FORMAT_ARGB8888, - 0, 0, width, rows, - bufferpitch, format, type, - unpack, pixels, address )) { -/* mgaReleaseBufLocked( mmesa, buf ); */ - UNLOCK_HARDWARE(mmesa); - return GL_FALSE; - } - } -#else - memcpy( address, pixels, rows*bufferpitch ); -#endif - - do_draw_pix( ctx, x, y, width, rows, - bufferpitch/cpp, address, dest, planemask ); - - /* Fix me -- use multiple buffers to avoid flush. - */ - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); - - pixels = (void *)((char *) pixels + rows * pitch); - height -= rows; - y += rows; - } while (height); - -/* mgaReleaseBufLocked( mmesa, buf ); */ - } - - UNLOCK_HARDWARE( mmesa ); - mmesa->dirty |= MGA_UPLOAD_CLIPRECTS; - - return GL_TRUE; -} - -static void -mgaDDDrawPixels( struct gl_context *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 ); -} -#endif - - -/* Stub functions - not a real allocator, always returns pointer to - * the same block of agp space which isn't used for anything else at - * present. - */ -void mgaDDInitPixelFuncs( struct gl_context *ctx ) -{ -#if 0 - /* evidently, these functions don't always work */ - if (getenv("MGA_BLIT_PIXELS")) { - ctx->Driver.ReadPixels = mgaDDReadPixels; /* requires agp dest */ - ctx->Driver.DrawPixels = mgaDDDrawPixels; /* works with agp/normal mem */ - } -#endif -} diff --git a/src/mesa/drivers/dri/mga/mgapixel.h b/src/mesa/drivers/dri/mga/mgapixel.h deleted file mode 100644 index 6241b4b5ef4..00000000000 --- a/src/mesa/drivers/dri/mga/mgapixel.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2001 Compaq Computer Inc. 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 <[email protected]> - */ - -#ifndef MGA_PIXELS_H -#define MGA_PIXELS_H - -#include "main/mtypes.h" - -extern void mgaDDInitPixelFuncs( struct gl_context *ctx ); - -#endif diff --git a/src/mesa/drivers/dri/mga/mgaregs.h b/src/mesa/drivers/dri/mga/mgaregs.h deleted file mode 100644 index 1ef1e6d24c6..00000000000 --- a/src/mesa/drivers/dri/mga/mgaregs.h +++ /dev/null @@ -1,1394 +0,0 @@ -/* author: stephen crowley, [email protected] */ - -/* - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and 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 - * 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. - */ - -#ifndef _MGAREGS_H_ -#define _MGAREGS_H_ - -/*************** (START) AUTOMATICLY GENERATED REGISTER FILE *****************/ -/* - * Generated on Wed Jan 26 13:44:46 MST 2000 - */ - - - -/* - * 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_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_tformat_tw422uyvy 0xb /* val 11, 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_uvoffset_SHIFT 17 -# define TF_uvoffset_OGL (0U << TF_uvoffset_SHIFT) -# define TF_uvoffset_D3D (1U << TF_uvoffset_SHIFT) -# define TF_uvoffset_MASK (~(1U << TF_uvoffset_SHIFT)) -# define TF_reserved_MASK (~0x1ff00) /* bits 8-16 */ -# define TF_mapnbhigh_SHIFT 18 -# define TF_mapnbhigh_MASK (~(1U << TF_mapnbhigh_SHIFT)) -# 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 ******************/ - -/* Copied from mga_drv.h kernel file. - */ - -#define MGA_ILOAD_ALIGN 64 -#define MGA_ILOAD_MASK (MGA_ILOAD_ALIGN - 1) - -#endif /* _MGAREGS_H_ */ - diff --git a/src/mesa/drivers/dri/mga/mgarender.c b/src/mesa/drivers/dri/mga/mgarender.c deleted file mode 100644 index f10a91adcec..00000000000 --- a/src/mesa/drivers/dri/mga/mgarender.c +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * - */ - - -/* - * 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 "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "math/m_xform.h" - -#include "tnl/t_context.h" - -#include "mgacontext.h" -#include "mgatris.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( struct gl_context *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 ); -} - - -#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 FLUSH() 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 ALLOC_VERTS( nr ) \ - mgaAllocDmaLow( mmesa, (nr) * mmesa->vertex_size * 4) -#define EMIT_VERTS( ctx, j, nr, buf ) \ - mga_emit_contiguous_verts(ctx, j, (j)+(nr), buf) - - -#define TAG(x) mga_##x -#include "tnl_dd/t_dd_dmatmp.h" - - - -/**********************************************************************/ -/* Render pipeline stage */ -/**********************************************************************/ - - -static GLboolean mga_run_render( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - /* Don't handle clipping or indexed vertices or vertex manipulations. - */ - if (mmesa->RenderIndex != 0 || - !mga_validate_render( ctx, VB )) { - return GL_TRUE; - } - - tnl->Driver.Render.Start( ctx ); - mmesa->SetupNewInputs = ~0; - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { - GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - - if (!length) - continue; - - mga_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length, - prim); - } - - tnl->Driver.Render.Finish( ctx ); - - return GL_FALSE; /* finished the pipe */ -} - - -const struct tnl_pipeline_stage _mga_render_stage = -{ - "mga render", - NULL, - NULL, - NULL, - NULL, - mga_run_render /* run */ -}; diff --git a/src/mesa/drivers/dri/mga/mgaspan.c b/src/mesa/drivers/dri/mga/mgaspan.c deleted file mode 100644 index dd9a8d74edd..00000000000 --- a/src/mesa/drivers/dri/mga/mgaspan.c +++ /dev/null @@ -1,227 +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 <[email protected]> - */ - -#include "main/mtypes.h" -#include "mgadd.h" -#include "mgacontext.h" -#include "mgaspan.h" -#include "mgaioctl.h" -#include "swrast/swrast.h" - -#define DBG 0 - -#define LOCAL_VARS \ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); \ - __DRIscreen *sPriv = mmesa->driScreen; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - const __DRIdrawable *dPriv = drb->dPriv; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(sPriv->pFB + \ - drb->offset + \ - dPriv->x * drb->cpp + \ - dPriv->y * pitch); \ - GLuint p; \ - (void) buf; (void) p - - - -#define LOCAL_DEPTH_VARS \ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); \ - __DRIscreen *sPriv = mmesa->driScreen; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - const __DRIdrawable *dPriv = drb->dPriv; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(sPriv->pFB + \ - drb->offset + \ - dPriv->x * drb->cpp + \ - dPriv->y * pitch) - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define HW_LOCK() - -/* FIXME could/should we use dPriv->numClipRects like the other drivers? */ -#define HW_CLIPLOOP() \ - do { \ - int _nc = mmesa->numClipRects; \ - while (_nc--) { \ - int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \ - int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \ - int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \ - int maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY; - -#define HW_ENDCLIPLOOP() \ - } \ - } while (0) - -#define HW_UNLOCK() - - - -#define Y_FLIP(_y) (height - _y - 1) - -/* 16 bit, RGB565 color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_RGB -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 - -#define TAG(x) mga##x##_565 -#define TAG2(x,y) mga##x##_565##y -#include "spantmp2.h" - -/* 32 bit, ARGB8888 color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_BGRA -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV - -#define TAG(x) mga##x##_8888 -#define TAG2(x,y) mga##x##_8888##y -#include "spantmp2.h" - - -/* 16 bit depthbuffer functions. - */ -#define VALUE_TYPE GLushort - -#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) mga##x##_z16 -#include "depthtmp.h" - - - - -/* 32 bit depthbuffer functions. - */ -#define VALUE_TYPE GLuint - -#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) mga##x##_z32 -#include "depthtmp.h" - - - -/* 24/8 bit interleaved depth/stencil functions - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \ - tmp &= 0xff; \ - tmp |= (d) << 8; \ - *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \ -} - -#define READ_DEPTH( d, _x, _y ) { \ - d = (*(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff) >> 8; \ -} - -#define TAG(x) mga##x##_z24_s8 -#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) mga##x##_z24_s8 -#include "stenciltmp.h" - - -static void -mgaSpanRenderStart( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - FLUSH_BATCH( mmesa ); - LOCK_HARDWARE_QUIESCENT( mmesa ); -} - -static void -mgaSpanRenderFinish( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - _swrast_flush( ctx ); - UNLOCK_HARDWARE( mmesa ); -} - -/** - * Initialize the driver callbacks for the read / write span functions. - * - * \bug - * To really support RGB888 and RGBA8888 visuals, we need separate read and - * write routines for 888 and 8888. We also need to determine whether or not - * the visual has destination alpha. - */ -void mgaDDInitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = mgaSpanRenderStart; - swdd->SpanRenderFinish = mgaSpanRenderFinish; -} - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -mgaSetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis) -{ - if (drb->Base.Format == MESA_FORMAT_RGB565) { - mgaInitPointers_565(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_ARGB8888) { - mgaInitPointers_8888(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_Z16) { - mgaInitDepthPointers_z16(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_Z24_S8) { - mgaInitDepthPointers_z24_s8(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_Z32) { - mgaInitDepthPointers_z32(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_S8) { - mgaInitStencilPointers_z24_s8(&drb->Base); - } -} diff --git a/src/mesa/drivers/dri/mga/mgaspan.h b/src/mesa/drivers/dri/mga/mgaspan.h deleted file mode 100644 index 48186b46e9a..00000000000 --- a/src/mesa/drivers/dri/mga/mgaspan.h +++ /dev/null @@ -1,39 +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 <[email protected]> - */ - -#ifndef _MGA_SPAN_H -#define _MGA_SPAN_H - -#include "drirenderbuffer.h" - -extern void mgaDDInitSpanFuncs( struct gl_context *ctx ); - -extern void -mgaSetSpanFunctions(driRenderbuffer *rb, const struct gl_config *vis); - - -#endif diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c deleted file mode 100644 index bfc55f4fc6d..00000000000 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ /dev/null @@ -1,1198 +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 <[email protected]> - */ - - -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/dd.h" -#include "main/mm.h" -#include "main/state.h" - -#include "mgacontext.h" -#include "mgadd.h" -#include "mgastate.h" -#include "mgatex.h" -#include "mgavb.h" -#include "mgatris.h" -#include "mgaioctl.h" -#include "mgaregs.h" - -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "swrast_setup/swrast_setup.h" - -#include "xmlpool.h" -#include "drirenderbuffer.h" - - -static void updateSpecularLighting( struct gl_context *ctx ); - -static const GLuint mgarop_NoBLK[16] = { - DC_atype_rpl | 0x00000000, DC_atype_rstr | 0x00080000, - DC_atype_rstr | 0x00040000, DC_atype_rpl | 0x000c0000, - DC_atype_rstr | 0x00020000, DC_atype_rstr | 0x000a0000, - DC_atype_rstr | 0x00060000, DC_atype_rstr | 0x000e0000, - DC_atype_rstr | 0x00010000, DC_atype_rstr | 0x00090000, - DC_atype_rstr | 0x00050000, DC_atype_rstr | 0x000d0000, - DC_atype_rpl | 0x00030000, DC_atype_rstr | 0x000b0000, - DC_atype_rstr | 0x00070000, DC_atype_rpl | 0x000f0000 -}; - -/* ============================================================= - * Alpha blending - */ - -static void mgaDDAlphaFunc(struct gl_context *ctx, GLenum func, GLfloat ref) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLubyte refByte; - GLuint a; - - CLAMPED_FLOAT_TO_UBYTE(refByte, ref); - - switch ( func ) { - case GL_NEVER: - a = AC_atmode_alt; - refByte = 0; - break; - case GL_LESS: - a = AC_atmode_alt; - break; - case GL_GEQUAL: - a = AC_atmode_agte; - break; - case GL_LEQUAL: - a = AC_atmode_alte; - break; - case GL_GREATER: - a = AC_atmode_agt; - break; - case GL_NOTEQUAL: - a = AC_atmode_ane; - break; - case GL_EQUAL: - a = AC_atmode_ae; - break; - case GL_ALWAYS: - a = AC_atmode_noacmp; - break; - default: - a = 0; - break; - } - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.alpha_func = a | MGA_FIELD( AC_atref, refByte ); -} - -static void updateBlendLogicOp(struct gl_context *ctx) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLboolean logicOp = _mesa_rgba_logicop_enabled(ctx); - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - - mmesa->hw.blend_func_enable = - (ctx->Color.BlendEnabled && !logicOp) ? ~0 : 0; - - FALLBACK( ctx, MGA_FALLBACK_BLEND, - ctx->Color.BlendEnabled && !logicOp && - mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) ); -} - -static void mgaDDBlendEquationSeparate(struct gl_context *ctx, - GLenum modeRGB, GLenum modeA) -{ - assert( modeRGB == modeA ); - updateBlendLogicOp( ctx ); -} - -static void mgaDDBlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint src; - GLuint dst; - - switch (ctx->Color.Blend[0].SrcRGB) { - case GL_ZERO: - src = AC_src_zero; break; - case GL_SRC_ALPHA: - src = AC_src_src_alpha; break; - case GL_ONE: - default: /* never happens */ - src = AC_src_one; break; - case GL_DST_COLOR: - src = AC_src_dst_color; break; - case GL_ONE_MINUS_DST_COLOR: - src = AC_src_om_dst_color; break; - case GL_ONE_MINUS_SRC_ALPHA: - src = AC_src_om_src_alpha; break; - case GL_DST_ALPHA: - src = (ctx->Visual.alphaBits > 0) - ? AC_src_dst_alpha : AC_src_one; - break; - case GL_ONE_MINUS_DST_ALPHA: - src = (ctx->Visual.alphaBits > 0) - ? AC_src_om_dst_alpha : AC_src_zero; - break; - case GL_SRC_ALPHA_SATURATE: - src = (ctx->Visual.alphaBits > 0) - ? AC_src_src_alpha_sat : AC_src_zero; - break; - } - - switch (ctx->Color.Blend[0].DstRGB) { - case GL_SRC_ALPHA: - dst = AC_dst_src_alpha; break; - case GL_ONE_MINUS_SRC_ALPHA: - dst = AC_dst_om_src_alpha; break; - default: /* never happens */ - case GL_ZERO: - dst = AC_dst_zero; break; - case GL_ONE: - dst = AC_dst_one; break; - case GL_SRC_COLOR: - dst = AC_dst_src_color; break; - case GL_ONE_MINUS_SRC_COLOR: - dst = AC_dst_om_src_color; break; - case GL_DST_ALPHA: - dst = (ctx->Visual.alphaBits > 0) - ? AC_dst_dst_alpha : AC_dst_one; - break; - case GL_ONE_MINUS_DST_ALPHA: - dst = (ctx->Visual.alphaBits > 0) - ? AC_dst_om_dst_alpha : AC_dst_zero; - break; - } - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.blend_func = (src | dst); - - FALLBACK( ctx, MGA_FALLBACK_BLEND, - ctx->Color.BlendEnabled && !_mesa_rgba_logicop_enabled(ctx) && - mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) ); -} - -/* ============================================================= - * Depth testing - */ - -static void mgaDDDepthFunc(struct gl_context *ctx, GLenum func) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - int zmode; - - switch (func) { - case GL_NEVER: - /* can't do this in h/w, we'll use a s/w fallback */ - FALLBACK (ctx, MGA_FALLBACK_DEPTH, ctx->Depth.Test); - - /* FALLTHROUGH */ - case GL_ALWAYS: - zmode = DC_zmode_nozcmp; break; - case GL_LESS: - zmode = DC_zmode_zlt; break; - case GL_LEQUAL: - zmode = DC_zmode_zlte; break; - case GL_EQUAL: - zmode = DC_zmode_ze; break; - case GL_GREATER: - zmode = DC_zmode_zgt; break; - case GL_GEQUAL: - zmode = DC_zmode_zgte; break; - case GL_NOTEQUAL: - zmode = DC_zmode_zne; break; - default: - zmode = 0; break; - } - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.zmode &= DC_zmode_MASK; - mmesa->hw.zmode |= zmode; -} - -static void mgaDDDepthMask(struct gl_context *ctx, GLboolean flag) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.zmode &= DC_atype_MASK; - mmesa->hw.zmode |= (flag) ? DC_atype_zi : DC_atype_i; -} - - -static void mgaDDClearDepth(struct gl_context *ctx, GLclampd d) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - /* Select the Z depth. The ~ is used because the _MASK values in the - * MGA driver are used to mask OFF the selected bits. In this case, - * we want to mask off everything except the MA_zwidth bits. - */ - 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; - case MA_zwidth_32: mmesa->ClearDepth = d * 0xffffffff; break; - default: return; - } -} - - -/* ============================================================= - * Fog - */ - - -static void mgaDDFogfv(struct gl_context *ctx, GLenum pname, const GLfloat *param) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - if (pname == GL_FOG_COLOR) { - GLuint color = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F), - (GLubyte)(ctx->Fog.Color[1]*255.0F), - (GLubyte)(ctx->Fog.Color[2]*255.0F)); - - MGA_STATECHANGE(mmesa, MGA_UPLOAD_CONTEXT); - mmesa->setup.fogcolor = color; - } -} - - -/* ============================================================= - * Scissoring - */ - - -void mgaUpdateClipping(const struct gl_context *ctx) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - if (mmesa->driDrawable) - { - int x1 = mmesa->driDrawable->x + ctx->Scissor.X; - int y1 = mmesa->driDrawable->y + mmesa->driDrawable->h - - (ctx->Scissor.Y + ctx->Scissor.Height); - int x2 = x1 + ctx->Scissor.Width; - int y2 = y1 + ctx->Scissor.Height; - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 < 0) x2 = 0; - if (y2 < 0) y2 = 0; - - mmesa->scissor_rect.x1 = x1; - mmesa->scissor_rect.y1 = y1; - mmesa->scissor_rect.x2 = x2; - mmesa->scissor_rect.y2 = y2; - - mmesa->dirty |= MGA_UPLOAD_CLIPRECTS; - } -} - - -static void mgaDDScissor( struct gl_context *ctx, GLint x, GLint y, - GLsizei w, GLsizei h ) -{ - if ( ctx->Scissor.Enabled ) { - FLUSH_BATCH( MGA_CONTEXT(ctx) ); /* don't pipeline cliprect changes */ - mgaUpdateClipping( ctx ); - } -} - - -/* ============================================================= - * Culling - */ - - -#define _CULL_DISABLE 0 -#define _CULL_NEGATIVE ((1<<11)|(1<<5)|(1<<16)) -#define _CULL_POSITIVE (1<<11) - -static void mgaDDCullFaceFrontFace(struct gl_context *ctx, GLenum unused) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - if (ctx->Polygon.CullFlag && - ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) - { - mmesa->hw.cull = _CULL_NEGATIVE; - - if (ctx->Polygon.CullFaceMode == GL_FRONT) - mmesa->hw.cull ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); - - if (ctx->Polygon.FrontFace != GL_CCW) - mmesa->hw.cull ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); - - mmesa->hw.cull_dualtex = mmesa->hw.cull ^ - (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* warp bug? */ - } - else { - mmesa->hw.cull = _CULL_DISABLE; - mmesa->hw.cull_dualtex = _CULL_DISABLE; - } -} - - -/* ============================================================= - * Masks - */ - -static void mgaDDColorMask(struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; - GLuint mask = mgaPackColor(mgaScreen->cpp, - ctx->Color.ColorMask[0][RCOMP], - ctx->Color.ColorMask[0][GCOMP], - ctx->Color.ColorMask[0][BCOMP], - ctx->Color.ColorMask[0][ACOMP]); - - if (mgaScreen->cpp == 2) - mask = mask | (mask << 16); - - if (mmesa->setup.plnwt != mask) { - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->setup.plnwt = mask; - } -} - - -/* ============================================================= - * Polygon state - */ - -static int mgaStipples[16] = { - 0xffff, - 0xa5a5, - 0x5a5a, - 0xa0a0, - 0x5050, - 0x0a0a, - 0x0505, - 0x8020, - 0x0401, - 0x1040, - 0x0208, - 0x0802, - 0x4010, - 0x0104, - 0x2080, - 0x0000 -}; - -/** - * The MGA supports a subset of possible 4x4 stipples natively, GL - * wants 32x32. Fortunately stipple is usually a repeating pattern. - * - * \param ctx GL rendering context to be affected - * \param mask Pointer to the 32x32 stipple mask - */ - -static void mgaDDPolygonStipple( struct gl_context *ctx, const GLubyte *mask ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - const GLubyte *m = mask; - GLubyte p[4]; - int i,j,k; - int active = (ctx->Polygon.StippleFlag && - mmesa->raster_primitive == GL_TRIANGLES); - GLuint stipple; - - FLUSH_BATCH(mmesa); - mmesa->haveHwStipple = 0; - - if (active) { - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - mmesa->setup.dwgctl &= ~(0xf<<20); - } - - p[0] = mask[0] & 0xf; p[0] |= p[0] << 4; - p[1] = mask[4] & 0xf; p[1] |= p[1] << 4; - p[2] = mask[8] & 0xf; p[2] |= p[2] << 4; - p[3] = mask[12] & 0xf; p[3] |= p[3] << 4; - - for (k = 0 ; k < 8 ; k++) - for (j = 0 ; j < 4; j++) - for (i = 0 ; i < 4 ; i++) - if (*m++ != p[j]) { - return; - } - - stipple = ( ((p[0] & 0xf) << 0) | - ((p[1] & 0xf) << 4) | - ((p[2] & 0xf) << 8) | - ((p[3] & 0xf) << 12) ); - - for (i = 0 ; i < 16 ; i++) - if (mgaStipples[i] == stipple) { - mmesa->poly_stipple = i<<20; - mmesa->haveHwStipple = 1; - break; - } - - if (active) { - mmesa->setup.dwgctl &= ~(0xf<<20); - mmesa->setup.dwgctl |= mmesa->poly_stipple; - } -} - - -/* ============================================================= - * 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 updateSpecularLighting( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - unsigned int specen; - - specen = _mesa_need_secondary_color(ctx) ? TMC_specen_enable : 0; - - if ( specen != mmesa->hw.specen ) { - mmesa->hw.specen = specen; - mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1; - } -} - - -/* ============================================================= - * Materials - */ - - -static void mgaDDLightModelfv(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { - FLUSH_BATCH( MGA_CONTEXT(ctx) ); - updateSpecularLighting( ctx ); - } -} - - -/* ============================================================= - * Stencil - */ - - -static void -mgaDDStencilFuncSeparate(struct gl_context *ctx, GLenum face, GLenum func, GLint ref, - GLuint mask) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint stencil; - GLuint stencilctl; - - stencil = MGA_FIELD( S_sref, ref ) | MGA_FIELD( S_smsk, mask ); - switch (func) - { - case GL_NEVER: - stencilctl = SC_smode_snever; - break; - case GL_LESS: - stencilctl = SC_smode_slt; - break; - case GL_LEQUAL: - stencilctl = SC_smode_slte; - break; - case GL_GREATER: - stencilctl = SC_smode_sgt; - break; - case GL_GEQUAL: - stencilctl = SC_smode_sgte; - break; - case GL_NOTEQUAL: - stencilctl = SC_smode_sne; - break; - case GL_EQUAL: - stencilctl = SC_smode_se; - break; - case GL_ALWAYS: - default: - stencilctl = SC_smode_salways; - break; - } - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.stencil &= (S_sref_MASK & S_smsk_MASK); - mmesa->hw.stencil |= stencil; - mmesa->hw.stencilctl &= SC_smode_MASK; - mmesa->hw.stencilctl |= stencilctl; -} - -static void -mgaDDStencilMaskSeparate(struct gl_context *ctx, GLenum face, GLuint mask) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.stencil &= S_swtmsk_MASK; - mmesa->hw.stencil |= MGA_FIELD( S_swtmsk, mask ); -} - -static void -mgaDDStencilOpSeparate(struct gl_context *ctx, GLenum face, GLenum fail, GLenum zfail, - GLenum zpass) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint stencilctl; - - stencilctl = 0; - switch (ctx->Stencil.FailFunc[0]) - { - case GL_KEEP: - stencilctl |= SC_sfailop_keep; - break; - case GL_ZERO: - stencilctl |= SC_sfailop_zero; - break; - case GL_REPLACE: - stencilctl |= SC_sfailop_replace; - break; - case GL_INCR: - stencilctl |= SC_sfailop_incrsat; - break; - case GL_DECR: - stencilctl |= SC_sfailop_decrsat; - break; - case GL_INCR_WRAP: - stencilctl |= SC_sfailop_incr; - break; - case GL_DECR_WRAP: - stencilctl |= SC_sfailop_decr; - break; - case GL_INVERT: - stencilctl |= SC_sfailop_invert; - break; - default: - break; - } - - switch (ctx->Stencil.ZFailFunc[0]) - { - case GL_KEEP: - stencilctl |= SC_szfailop_keep; - break; - case GL_ZERO: - stencilctl |= SC_szfailop_zero; - break; - case GL_REPLACE: - stencilctl |= SC_szfailop_replace; - break; - case GL_INCR: - stencilctl |= SC_szfailop_incrsat; - break; - case GL_DECR: - stencilctl |= SC_szfailop_decrsat; - break; - case GL_INCR_WRAP: - stencilctl |= SC_szfailop_incr; - break; - case GL_DECR_WRAP: - stencilctl |= SC_szfailop_decr; - break; - case GL_INVERT: - stencilctl |= SC_szfailop_invert; - break; - default: - break; - } - - switch (ctx->Stencil.ZPassFunc[0]) - { - case GL_KEEP: - stencilctl |= SC_szpassop_keep; - break; - case GL_ZERO: - stencilctl |= SC_szpassop_zero; - break; - case GL_REPLACE: - stencilctl |= SC_szpassop_replace; - break; - case GL_INCR: - stencilctl |= SC_szpassop_incrsat; - break; - case GL_DECR: - stencilctl |= SC_szpassop_decrsat; - break; - case GL_INCR_WRAP: - stencilctl |= SC_szpassop_incr; - break; - case GL_DECR_WRAP: - stencilctl |= SC_szpassop_decr; - break; - case GL_INVERT: - stencilctl |= SC_szpassop_invert; - break; - default: - break; - } - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.stencilctl &= (SC_sfailop_MASK & SC_szfailop_MASK - & SC_szpassop_MASK); - mmesa->hw.stencilctl |= stencilctl; -} - - -/* ============================================================= - * Window position and viewport transformation - */ - -void mgaCalcViewport( struct gl_context *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( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - mgaCalcViewport( ctx ); -} - -static void mgaDepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - mgaCalcViewport( ctx ); -} - - -/* ============================================================= - * Miscellaneous - */ - -static void mgaDDClearColor(struct gl_context *ctx, - const GLfloat color[4] ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->cpp, - c[0], c[1], c[2], c[3]); -} - - -/* Fallback to swrast for select and feedback. - */ -static void mgaRenderMode( struct gl_context *ctx, GLenum mode ) -{ - FALLBACK( ctx, MGA_FALLBACK_RENDERMODE, (mode != GL_RENDER) ); -} - - -static void mgaDDLogicOp( struct gl_context *ctx, GLenum opcode ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.rop = mgarop_NoBLK[ opcode & 0x0f ]; -} - - -static void mga_set_cliprects(mgaContextPtr mmesa) -{ - __DRIdrawable *driDrawable = mmesa->driDrawable; - - if ((mmesa->draw_buffer != MGA_FRONT) - || (driDrawable->numBackClipRects == 0)) { - if (driDrawable->numClipRects == 0) { - static drm_clip_rect_t zeroareacliprect = {0,0,0,0}; - mmesa->numClipRects = 1; - mmesa->pClipRects = &zeroareacliprect; - } else { - mmesa->numClipRects = driDrawable->numClipRects; - mmesa->pClipRects = driDrawable->pClipRects; - } - mmesa->drawX = driDrawable->x; - mmesa->drawY = driDrawable->y; - } else { - mmesa->numClipRects = driDrawable->numBackClipRects; - mmesa->pClipRects = driDrawable->pBackClipRects; - mmesa->drawX = driDrawable->backX; - mmesa->drawY = driDrawable->backY; - } - - mmesa->setup.dstorg = mmesa->drawOffset; - mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS; -} - - -void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) -{ - __DRIdrawable *const driDrawable = mmesa->driDrawable; - __DRIdrawable *const driReadable = mmesa->driReadable; - - mmesa->dirty_cliprects = 0; - - driUpdateFramebufferSize(mmesa->glCtx, driDrawable); - if (driDrawable != driReadable) { - driUpdateFramebufferSize(mmesa->glCtx, driReadable); - } - - mga_set_cliprects(mmesa); - - mgaUpdateClipping( mmesa->glCtx ); - mgaCalcViewport( mmesa->glCtx ); -} - - -static void mgaDDDrawBuffer(struct gl_context *ctx, GLenum mode ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - FLUSH_BATCH( mmesa ); - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ - FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; - mmesa->draw_buffer = MGA_FRONT; - break; - case BUFFER_BACK_LEFT: - mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; - mmesa->draw_buffer = MGA_BACK; - break; - default: - FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - mga_set_cliprects(mmesa); - FALLBACK(ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE); -} - - -static void mgaDDReadBuffer(struct gl_context *ctx, GLenum mode ) -{ - /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */ -} - - -/* ============================================================= - * State enable/disable - */ - - -static void mgaDDEnable(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - switch(cap) { - case GL_DITHER: - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - if (!ctx->Color.DitherFlag) - mmesa->setup.maccess |= MA_nodither_enable; - else - mmesa->setup.maccess &= ~MA_nodither_enable; - break; - case GL_LIGHTING: - case GL_COLOR_SUM_EXT: - FLUSH_BATCH( mmesa ); - updateSpecularLighting( ctx ); - break; - case GL_ALPHA_TEST: - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->hw.alpha_func_enable = (state) ? ~0 : 0; - break; - case GL_DEPTH_TEST: - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - FALLBACK (ctx, MGA_FALLBACK_DEPTH, - ctx->Depth.Func == GL_NEVER && ctx->Depth.Test); - break; - - case GL_SCISSOR_TEST: - FLUSH_BATCH( mmesa ); - mmesa->scissor = state; - mgaUpdateClipping( ctx ); - break; - - case GL_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: - mgaDDCullFaceFrontFace( ctx, 0 ); - break; - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - break; - case GL_POLYGON_STIPPLE: - if (mmesa->haveHwStipple && mmesa->raster_primitive == GL_TRIANGLES) { - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - mmesa->setup.dwgctl &= ~(0xf<<20); - if (state) - mmesa->setup.dwgctl |= mmesa->poly_stipple; - } - break; - - case GL_BLEND: - case GL_COLOR_LOGIC_OP: - updateBlendLogicOp( ctx ); - break; - - case GL_STENCIL_TEST: - MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); - if (mmesa->hw_stencil) { - mmesa->hw.stencil_enable = ( state ) ? ~0 : 0; - } - else { - FALLBACK( ctx, MGA_FALLBACK_STENCIL, state ); - } - default: - break; - } -} - - -/* ============================================================= - */ - -static void mgaDDPrintDirty( const char *msg, GLuint state ) -{ - fprintf(stderr, "%s (0x%03x): %s%s%s%s%s%s%s\n", - msg, - (unsigned int) state, - (state & MGA_WAIT_AGE) ? "wait-age " : "", - (state & MGA_UPLOAD_TEX0IMAGE) ? "upload-tex0-img " : "", - (state & MGA_UPLOAD_TEX1IMAGE) ? "upload-tex1-img " : "", - (state & MGA_UPLOAD_CONTEXT) ? "upload-ctx " : "", - (state & MGA_UPLOAD_TEX0) ? "upload-tex0 " : "", - (state & MGA_UPLOAD_TEX1) ? "upload-tex1 " : "", - (state & MGA_UPLOAD_PIPE) ? "upload-pipe " : "" - ); -} - -/* Push the state into the sarea and/or texture memory. - */ -void mgaEmitHwStateLocked( mgaContextPtr mmesa ) -{ - drm_mga_sarea_t *sarea = mmesa->sarea; - struct gl_context * ctx = mmesa->glCtx; - - if (MGA_DEBUG & DEBUG_VERBOSE_MSG) - mgaDDPrintDirty( __FUNCTION__, mmesa->dirty ); - - if (mmesa->dirty & MGA_UPLOAD_CONTEXT) { - mmesa->setup.wflag = _CULL_DISABLE; - if (mmesa->raster_primitive == GL_TRIANGLES) { - if ((ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT && - ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT)) { - mmesa->setup.wflag = mmesa->hw.cull_dualtex; - } - else { - mmesa->setup.wflag = mmesa->hw.cull; - } - } - - mmesa->setup.stencil = mmesa->hw.stencil - & mmesa->hw.stencil_enable; - mmesa->setup.stencilctl = mmesa->hw.stencilctl - & mmesa->hw.stencil_enable; - - /* If depth testing is not enabled, then use the no Z-compare / no - * Z-write mode. Otherwise, use whatever is set in hw.zmode. - */ - mmesa->setup.dwgctl &= (DC_zmode_MASK & DC_atype_MASK); - mmesa->setup.dwgctl |= (ctx->Depth.Test) - ? mmesa->hw.zmode : (DC_zmode_nozcmp | DC_atype_i); - - mmesa->setup.dwgctl &= DC_bop_MASK; - mmesa->setup.dwgctl |= _mesa_rgba_logicop_enabled(ctx) - ? mmesa->hw.rop : mgarop_NoBLK[ GL_COPY & 0x0f ]; - - mmesa->setup.alphactrl &= AC_src_MASK & AC_dst_MASK & AC_atmode_MASK - & AC_atref_MASK & AC_alphasel_MASK; - mmesa->setup.alphactrl |= - (mmesa->hw.alpha_func & mmesa->hw.alpha_func_enable) | - (mmesa->hw.blend_func & mmesa->hw.blend_func_enable) | - ((AC_src_one | AC_dst_zero) & ~mmesa->hw.blend_func_enable) | - mmesa->hw.alpha_sel; - - memcpy( &sarea->context_state, &mmesa->setup, sizeof(mmesa->setup)); - } - - if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) { - memcpy(&sarea->tex_state[0], - &mmesa->CurrentTexObj[0]->setup, - sizeof(sarea->tex_state[0])); - } - - if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) { - memcpy(&sarea->tex_state[1], - &mmesa->CurrentTexObj[1]->setup, - sizeof(sarea->tex_state[1])); - } - - if (mmesa->dirty & (MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1)) { - sarea->tex_state[0].texctl2 &= ~TMC_specen_enable; - sarea->tex_state[1].texctl2 &= ~TMC_specen_enable; - sarea->tex_state[0].texctl2 |= mmesa->hw.specen; - sarea->tex_state[1].texctl2 |= mmesa->hw.specen; - } - - if (mmesa->dirty & MGA_UPLOAD_PIPE) { -/* mmesa->sarea->wacceptseq = mmesa->hw_primitive; */ - mmesa->sarea->warp_pipe = mmesa->vertex_format; - mmesa->sarea->vertsize = mmesa->vertex_size; - } - - mmesa->sarea->dirty |= mmesa->dirty; - mmesa->dirty &= MGA_UPLOAD_CLIPRECTS; -} - -/* ============================================================= - */ - - -static void mgaDDValidateState( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - FLUSH_BATCH( mmesa ); - - if (mmesa->NewGLState & _NEW_TEXTURE) { - mgaUpdateTextureState(ctx); - } - - if (!mmesa->Fallback) { - if (mmesa->NewGLState & _MGA_NEW_RASTERSETUP) { - mgaChooseVertexState( ctx ); - } - - if (mmesa->NewGLState & _MGA_NEW_RENDERSTATE) { - mgaChooseRenderState( ctx ); - } - } - - mmesa->NewGLState = 0; -} - - -static void mgaDDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - MGA_CONTEXT(ctx)->NewGLState |= new_state; -} - - -static void mgaRunPipeline( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - if (mmesa->NewGLState) { - mgaDDValidateState( ctx ); - } - - if (mmesa->dirty) { - mgaEmitHwStateLocked( mmesa ); - } - - _tnl_run_pipeline( ctx ); -} - - -void mgaInitState( mgaContextPtr mmesa ) -{ - mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; - struct gl_context *ctx = mmesa->glCtx; - - if (ctx->Visual.doubleBufferMode) { - /* use back buffer by default */ - mmesa->draw_buffer = MGA_BACK; - mmesa->drawOffset = mmesa->mgaScreen->backOffset; - mmesa->readOffset = mmesa->mgaScreen->backOffset; - mmesa->setup.dstorg = mgaScreen->backOffset; - } else { - /* use front buffer by default */ - mmesa->draw_buffer = MGA_FRONT; - mmesa->drawOffset = mmesa->mgaScreen->frontOffset; - mmesa->readOffset = mmesa->mgaScreen->frontOffset; - mmesa->setup.dstorg = mgaScreen->frontOffset; - } - - mmesa->setup.maccess = (MA_memreset_disable | - MA_fogen_disable | - MA_tlutload_disable | - MA_nodither_disable | - MA_dit555_disable); - if (driQueryOptioni (&mmesa->optionCache, "color_reduction") != - DRI_CONF_COLOR_REDUCTION_DITHER) - mmesa->setup.maccess |= MA_nodither_enable; - - switch (mmesa->mgaScreen->cpp) { - case 2: - mmesa->setup.maccess |= MA_pwidth_16; - break; - case 4: - mmesa->setup.maccess |= MA_pwidth_32; - break; - default: - fprintf( stderr, "Error: unknown cpp %d, exiting...\n", - mmesa->mgaScreen->cpp ); - exit( 1 ); - } - - switch (mmesa->glCtx->Visual.depthBits) { - case 16: - mmesa->setup.maccess |= MA_zwidth_16; - break; - case 24: - mmesa->setup.maccess |= MA_zwidth_24; - break; - case 32: - mmesa->setup.maccess |= MA_zwidth_32; - break; - } - - mmesa->hw.blend_func = AC_src_one | AC_dst_zero; - mmesa->hw.blend_func_enable = 0; - mmesa->hw.alpha_func = AC_atmode_noacmp | MGA_FIELD( AC_atref, 0x00 ); - mmesa->hw.alpha_func_enable = 0; - mmesa->hw.rop = mgarop_NoBLK[ GL_COPY & 0x0f ]; - mmesa->hw.zmode = DC_zmode_zlt | DC_atype_zi; - mmesa->hw.stencil = MGA_FIELD( S_sref, 0x00) | MGA_FIELD( S_smsk, 0xff ) | - MGA_FIELD( S_swtmsk, 0xff ); - mmesa->hw.stencilctl = SC_smode_salways | SC_sfailop_keep - | SC_szfailop_keep | SC_szpassop_keep; - mmesa->hw.stencil_enable = 0; - mmesa->hw.cull = _CULL_DISABLE; - mmesa->hw.cull_dualtex = _CULL_DISABLE; - mmesa->hw.specen = 0; - mmesa->hw.alpha_sel = AC_alphasel_diffused; - - mmesa->setup.dwgctl = (DC_opcod_trap | - DC_linear_xy | - DC_solid_disable | - DC_arzero_disable | - DC_sgnzero_disable | - DC_shftzero_enable | - MGA_FIELD( DC_bop, 0xC ) | - MGA_FIELD( DC_trans, 0x0 ) | - DC_bltmod_bmonolef | - DC_pattern_disable | - DC_transc_disable | - DC_clipdis_disable); - - mmesa->setup.plnwt = ~0; - mmesa->setup.alphactrl = (AC_amode_alpha_channel | - AC_astipple_disable | - AC_aten_disable); - - mmesa->setup.fogcolor = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F), - (GLubyte)(ctx->Fog.Color[1]*255.0F), - (GLubyte)(ctx->Fog.Color[2]*255.0F)); - - mmesa->setup.wflag = 0; - mmesa->setup.tdualstage0 = 0; - mmesa->setup.tdualstage1 = 0; - mmesa->setup.fcol = 0; - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - - mmesa->envcolor[0] = 0; - mmesa->envcolor[1] = 0; -} - - -void mgaDDInitStateFuncs( struct gl_context *ctx ) -{ - ctx->Driver.UpdateState = mgaDDInvalidateState; - ctx->Driver.Enable = mgaDDEnable; - ctx->Driver.LightModelfv = mgaDDLightModelfv; - ctx->Driver.AlphaFunc = mgaDDAlphaFunc; - ctx->Driver.BlendEquationSeparate = mgaDDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = mgaDDBlendFuncSeparate; - ctx->Driver.DepthFunc = mgaDDDepthFunc; - ctx->Driver.DepthMask = mgaDDDepthMask; - ctx->Driver.Fogfv = mgaDDFogfv; - ctx->Driver.Scissor = mgaDDScissor; - ctx->Driver.CullFace = mgaDDCullFaceFrontFace; - ctx->Driver.FrontFace = mgaDDCullFaceFrontFace; - ctx->Driver.ColorMask = mgaDDColorMask; - - ctx->Driver.DrawBuffer = mgaDDDrawBuffer; - ctx->Driver.ReadBuffer = mgaDDReadBuffer; - ctx->Driver.ClearColor = mgaDDClearColor; - ctx->Driver.ClearDepth = mgaDDClearDepth; - ctx->Driver.LogicOpcode = mgaDDLogicOp; - - ctx->Driver.PolygonStipple = mgaDDPolygonStipple; - - ctx->Driver.StencilFuncSeparate = mgaDDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = mgaDDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = mgaDDStencilOpSeparate; - - ctx->Driver.DepthRange = mgaDepthRange; - ctx->Driver.Viewport = mgaViewport; - ctx->Driver.RenderMode = mgaRenderMode; - - TNL_CONTEXT(ctx)->Driver.RunPipeline = mgaRunPipeline; -} diff --git a/src/mesa/drivers/dri/mga/mgastate.h b/src/mesa/drivers/dri/mga/mgastate.h deleted file mode 100644 index 6e8a869cf79..00000000000 --- a/src/mesa/drivers/dri/mga/mgastate.h +++ /dev/null @@ -1,38 +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 <[email protected]> - */ - -#ifndef _MGA_STATE_H -#define _MGA_STATE_H - -extern void mgaInitState( mgaContextPtr mmesa ); -extern void mgaDDInitStateFuncs(struct gl_context *ctx); -extern void mgaUpdateClipping(const struct gl_context *ctx); -extern void mgaUpdateCull( struct gl_context *ctx ); -extern void mgaCalcViewport( struct gl_context *ctx ); -extern void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ); - -#endif diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c deleted file mode 100644 index ebbfec36556..00000000000 --- a/src/mesa/drivers/dri/mga/mgatex.c +++ /dev/null @@ -1,540 +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 <[email protected]> - */ - -#include "main/glheader.h" -#include "main/mm.h" -#include "main/colormac.h" -#include "main/context.h" -#include "main/enums.h" -#include "main/simple_list.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/texstore.h" -#include "main/teximage.h" -#include "main/texobj.h" - -#include "mgacontext.h" -#include "mgatex.h" -#include "mgaregs.h" -#include "mgaioctl.h" - -#include "xmlpool.h" - -/** - * Set the texture wrap modes. - * Currently \c GL_REPEAT, \c GL_CLAMP and \c GL_CLAMP_TO_EDGE are supported. - * - * \param t Texture object whose wrap modes are to be set - * \param swrap Wrap mode for the \a s texture coordinate - * \param twrap Wrap mode for the \a t texture coordinate - */ - -static void -mgaSetTexWrapping( mgaTextureObjectPtr t, GLenum swrap, GLenum twrap ) -{ - GLboolean is_clamp = GL_FALSE; - GLboolean is_clamp_to_edge = GL_FALSE; - - t->setup.texctl &= (TMC_clampu_MASK & TMC_clampv_MASK); - t->setup.texctl2 &= (TMC_borderen_MASK); - - switch( swrap ) { - case GL_REPEAT: - break; - case GL_CLAMP: - t->setup.texctl |= TMC_clampu_enable; - is_clamp = GL_TRUE; - break; - case GL_CLAMP_TO_EDGE: - t->setup.texctl |= TMC_clampu_enable; - is_clamp_to_edge = GL_TRUE; - break; - default: - _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__); - } - - switch( twrap ) { - case GL_REPEAT: - break; - case GL_CLAMP: - t->setup.texctl |= TMC_clampv_enable; - is_clamp = GL_TRUE; - break; - case GL_CLAMP_TO_EDGE: - t->setup.texctl |= TMC_clampv_enable; - is_clamp_to_edge = GL_TRUE; - break; - default: - _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__); - } - - if ( is_clamp ) { - t->setup.texctl2 |= TMC_borderen_enable; - } - - t->border_fallback = (is_clamp && is_clamp_to_edge); -} - - -/** - * Set the texture magnification and minification modes. - * - * \param t Texture whose filter modes are to be set - * \param minf Texture minification mode - * \param magf Texture magnification mode - */ - -static void -mgaSetTexFilter( mgaTextureObjectPtr t, GLenum minf, GLenum magf ) -{ - GLuint val = 0; - - switch (minf) { - case GL_NEAREST: val = TF_minfilter_nrst; break; - case GL_LINEAR: val = TF_minfilter_bilin; break; - case GL_NEAREST_MIPMAP_NEAREST: val = TF_minfilter_mm1s; break; - case GL_LINEAR_MIPMAP_NEAREST: val = TF_minfilter_mm4s; break; - case GL_NEAREST_MIPMAP_LINEAR: val = TF_minfilter_mm2s; break; - case GL_LINEAR_MIPMAP_LINEAR: val = TF_minfilter_mm8s; break; - default: val = TF_minfilter_nrst; break; - } - - switch (magf) { - case GL_NEAREST: val |= TF_magfilter_nrst; break; - case GL_LINEAR: val |= TF_magfilter_bilin; break; - default: val |= TF_magfilter_nrst; break; - } - - /* See OpenGL 1.2 specification */ - if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || - minf == GL_NEAREST_MIPMAP_LINEAR)) { - val |= MGA_FIELD( TF_fthres, 0x20 ); /* c = 0.5 */ - } else { - val |= MGA_FIELD( TF_fthres, 0x10 ); /* c = 0 */ - } - - - /* Mask off the bits for the fields we are setting. Remember, the MGA mask - * defines have 0s for the bits in the named fields. This is the opposite - * of most of the other drivers. - */ - - t->setup.texfilter &= (TF_minfilter_MASK & - TF_magfilter_MASK & - TF_fthres_MASK); - t->setup.texfilter |= val; -} - -static void mgaSetTexBorderColor(mgaTextureObjectPtr t, const GLfloat color[4]) -{ - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - t->setup.texbordercol = PACK_COLOR_8888(c[3], c[0], c[1], c[2] ); -} - - -static gl_format -mgaChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - const GLboolean do32bpt = - ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 ); - const GLboolean force16bpt = - ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 ); - (void) format; - - switch ( internalFormat ) { - case 4: - case GL_RGBA: - case GL_COMPRESSED_RGBA: - switch ( type ) { - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555; - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return MESA_FORMAT_ARGB4444; - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return MESA_FORMAT_ARGB1555; - default: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - } - - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - switch ( type ) { - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return MESA_FORMAT_ARGB4444; - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return MESA_FORMAT_ARGB1555; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - return MESA_FORMAT_RGB565; - default: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - } - - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return !force16bpt ? - MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - - case GL_RGBA4: - case GL_RGBA2: - return MESA_FORMAT_ARGB4444; - - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - - case GL_RGB5: - case GL_RGB4: - case GL_R3_G3_B2: - return MESA_FORMAT_RGB565; - - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - /* FIXME: This will report incorrect component sizes... */ - return MGA_IS_G400(mmesa) ? MESA_FORMAT_AL88 : MESA_FORMAT_ARGB4444; - - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - /* FIXME: This will report incorrect component sizes... */ - return MGA_IS_G400(mmesa) ? MESA_FORMAT_AL88 : MESA_FORMAT_RGB565; - - case 2: - case GL_LUMINANCE_ALPHA: - 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 GL_COMPRESSED_LUMINANCE_ALPHA: - /* FIXME: This will report incorrect component sizes... */ - return MGA_IS_G400(mmesa) ? MESA_FORMAT_AL88 : MESA_FORMAT_ARGB4444; - - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - /* FIXME: This will report incorrect component sizes... */ - return MGA_IS_G400(mmesa) ? MESA_FORMAT_I8 : MESA_FORMAT_ARGB4444; - - case GL_YCBCR_MESA: - if (MGA_IS_G400(mmesa) && - (type == GL_UNSIGNED_SHORT_8_8_APPLE || - type == GL_UNSIGNED_BYTE)) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - - 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_FORMAT_CI8; - - default: - _mesa_problem( ctx, "unexpected texture format in %s", __FUNCTION__ ); - return MESA_FORMAT_NONE; - } - - return MESA_FORMAT_NONE; /* never get here */ -} - - - - -/** - * Allocate space for and load the mesa images into the texture memory block. - * This will happen before drawing with a new texture, or drawing with a - * texture after it was swapped out or teximaged again. - */ - -static mgaTextureObjectPtr -mgaAllocTexObj( struct gl_texture_object *tObj ) -{ - mgaTextureObjectPtr t; - - - t = CALLOC( sizeof( *t ) ); - tObj->DriverData = t; - if ( t != NULL ) { - /* Initialize non-image-dependent parts of the state: - */ - t->base.tObj = tObj; - - t->setup.texctl = TMC_takey_1 | TMC_tamask_0; - t->setup.texctl2 = TMC_ckstransdis_enable; - t->setup.texfilter = TF_filteralpha_enable | TF_uvoffset_OGL; - - t->border_fallback = GL_FALSE; - t->texenv_fallback = GL_FALSE; - - make_empty_list( & t->base ); - - mgaSetTexWrapping( t, tObj->Sampler.WrapS, tObj->Sampler.WrapT ); - mgaSetTexFilter( t, tObj->Sampler.MinFilter, tObj->Sampler.MagFilter ); - mgaSetTexBorderColor( t, tObj->Sampler.BorderColor.f ); - } - - return( t ); -} - - -static void mgaTexEnv( struct gl_context *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - GLuint unit = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - - switch( pname ) { - case GL_TEXTURE_ENV_COLOR: { - GLubyte c[4]; - - UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor ); - mmesa->envcolor[unit] = PACK_COLOR_8888( c[3], c[0], c[1], c[2] ); - break; - } - } -} - - -static void mgaTexImage2D( struct gl_context *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 ) -{ - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - if ( t != NULL ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) mgaAllocTexObj( texObj ); - if ( t == NULL ) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" ); - return; - } - } - - _mesa_store_teximage2d( ctx, target, level, internalFormat, - width, height, border, format, type, - pixels, packing, texObj, texImage ); - level -= t->firstLevel; - if (level >= 0) - t->dirty_images[0] |= (1UL << level); -} - -static void mgaTexSubImage2D( struct gl_context *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 ) -{ - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - assert( t ); /* this _should_ be true */ - if ( t != NULL ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) mgaAllocTexObj( texObj ); - if ( t == NULL ) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" ); - return; - } - } - - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); - level -= t->firstLevel; - if (level >= 0) - t->dirty_images[0] |= (1UL << level); -} - - -/** - * Changes variables and flags for a state update, which will happen at the - * next UpdateTextureState - */ - -static void -mgaTexParameter( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData; - - /* 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 == NULL) || - (target != GL_TEXTURE_2D && - target != GL_TEXTURE_RECTANGLE_NV) ) { - return; - } - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - driSwapOutTextureObject( (driTextureObject *) t ); - /* FALLTHROUGH */ - case GL_TEXTURE_MAG_FILTER: - FLUSH_BATCH(mmesa); - mgaSetTexFilter( t, tObj->Sampler.MinFilter, tObj->Sampler.MagFilter ); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - FLUSH_BATCH(mmesa); - mgaSetTexWrapping(t,tObj->Sampler.WrapS,tObj->Sampler.WrapT); - break; - - case GL_TEXTURE_BORDER_COLOR: - FLUSH_BATCH(mmesa); - mgaSetTexBorderColor(t, tObj->Sampler.BorderColor.f); - 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. Since there's no LOD clamping, - * we just have to rely on loading the right subset of mipmap levels - * to simulate a clamped LOD. - */ - driSwapOutTextureObject( (driTextureObject *) t ); - break; - - default: - return; - } -} - - -static void -mgaBindTexture( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) || - (tObj->DriverData != NULL) ); -} - - -static void -mgaDeleteTexture( struct gl_context *ctx, struct gl_texture_object *tObj ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - driTextureObject * t = (driTextureObject *) tObj->DriverData; - - if ( t ) { - if ( mmesa ) { - FLUSH_BATCH( mmesa ); - } - - driDestroyTextureObject( t ); - } - - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); -} - - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -mgaNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - mgaAllocTexObj( obj ); - return obj; -} - - -void -mgaInitTextureFuncs( struct dd_function_table *functions ) -{ - functions->ChooseTextureFormat = mgaChooseTextureFormat; - functions->TexImage2D = mgaTexImage2D; - functions->TexSubImage2D = mgaTexSubImage2D; - functions->BindTexture = mgaBindTexture; - functions->NewTextureObject = mgaNewTextureObject; - functions->DeleteTexture = mgaDeleteTexture; - functions->IsTextureResident = driIsTextureResident; - functions->TexEnv = mgaTexEnv; - functions->TexParameter = mgaTexParameter; -} diff --git a/src/mesa/drivers/dri/mga/mgatex.h b/src/mesa/drivers/dri/mga/mgatex.h deleted file mode 100644 index 3827fb06686..00000000000 --- a/src/mesa/drivers/dri/mga/mgatex.h +++ /dev/null @@ -1,50 +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 <[email protected]> - */ - -#ifndef MGATEX_INC -#define MGATEX_INC - -#include "mgacontext.h" - -typedef struct mga_texture_object_s *mgaTextureObjectPtr; - - -/* Called before a primitive is rendered to make sure the texture - * state is properly setup. Texture residence is checked later - * when we grab the lock. - */ -void mgaUpdateTextureState( struct gl_context *ctx ); - -int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t ); - -void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ); - -void mgaInitTextureFuncs( struct dd_function_table *functions ); - -GLboolean mgaUpdateTextureEnvCombine( struct gl_context *ctx, int unit ); - -#endif diff --git a/src/mesa/drivers/dri/mga/mgatexmem.c b/src/mesa/drivers/dri/mga/mgatexmem.c deleted file mode 100644 index 58afbbb279e..00000000000 --- a/src/mesa/drivers/dri/mga/mgatexmem.c +++ /dev/null @@ -1,278 +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 <[email protected]> - */ - -#include "main/glheader.h" - -#include "main/mm.h" -#include "mgacontext.h" -#include "mgatex.h" -#include "mgaregs.h" -#include "mgaioctl.h" -#include "mga_xmesa.h" - -#include "main/imports.h" -#include "main/simple_list.h" - -/** - * Destroy any device-dependent state associated with the texture. This may - * include NULLing out hardware state that points to the texture. - */ -void -mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - unsigned i; - - - /* See if it was the driver's current object. - */ - - if ( mmesa != NULL ) - { - if ( t->age > mmesa->dirtyAge ) - mmesa->dirtyAge = t->age; - - for ( i = 0 ; i < mmesa->glCtx->Const.MaxTextureUnits ; i++ ) - { - if ( t == mmesa->CurrentTexObj[ i ] ) { - mmesa->CurrentTexObj[ i ] = NULL; - } - } - } -} - - -/** - * Upload a texture image from system memory to either on-card or AGP - * memory. Uploads to on-card memory are performed using an ILOAD operation. - * This is used for both initial loading of the entire image, and texSubImage - * updates. - * - * Performed with the hardware lock held. - * - * Even though this function is named "upload subimage," the entire image - * is uploaded. - * - * \param mmesa Driver context. - * \param t Texture to be uploaded. - * \param hwlevel Mipmap level of the texture to be uploaded. - * - * \bug As mentioned above, this fuction actually copies the entier mipmap - * level. There should be a version of this function that performs - * sub-rectangle uploads. This will perform quite a bit better if only - * a small portion of a larger texture has been updated. Care would - * need to be take with such an implementation once glCopyTexImage has - * been hardware accelerated. - */ -static void mgaUploadSubImage( mgaContextPtr mmesa, - mgaTextureObjectPtr t, GLint hwlevel ) -{ - struct gl_texture_image * texImage; - unsigned offset; - unsigned texelBytes; - unsigned length; - const int level = hwlevel + t->base.firstLevel; - - - if ( (hwlevel < 0) - || (hwlevel >= (MGA_IS_G200(mmesa) - ? G200_TEX_MAXLEVELS : G400_TEX_MAXLEVELS)) ) { - fprintf( stderr, "[%s:%d] level = %d\n", __FILE__, __LINE__, level ); - return; - } - - texImage = t->base.tObj->Image[0][level]; - if ( texImage == NULL ) { - fprintf( stderr, "[%s:%d] Image[%d] = NULL\n", __FILE__, __LINE__, - level ); - return; - } - - - if (texImage->Data == NULL) { - fprintf(stderr, "null texture image data tObj %p level %d\n", - (void *) t->base.tObj, level); - return; - } - - - /* find the proper destination offset for this level */ - if ( MGA_IS_G200(mmesa) ) { - offset = (t->base.memBlock->ofs + t->offsets[hwlevel]); - } - else { - unsigned i; - - offset = t->base.memBlock->ofs; - for ( i = 0 ; i < hwlevel ; i++ ) { - offset += (t->offsets[1] >> (i * 2)); - } - } - - - /* Copy the texture from system memory to a memory space that can be - * directly used by the hardware for texturing. - */ - - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - length = texImage->Width * texImage->Height * texelBytes; - if ( t->base.heap->heapId == MGA_CARD_HEAP ) { - unsigned tex_offset = 0; - unsigned to_copy; - - - /* We may not be able to upload the entire texture in one batch due to - * register limits or dma buffer limits. Split the copy up into maximum - * sized chunks. - */ - - offset += mmesa->mgaScreen->textureOffset[ t->base.heap->heapId ]; - while ( length != 0 ) { - mgaGetILoadBufferLocked( mmesa ); - - /* The kernel ILOAD ioctl requires that the lenght be an even multiple - * of MGA_ILOAD_ALIGN. - */ - length = ((length) + MGA_ILOAD_MASK) & ~MGA_ILOAD_MASK; - - to_copy = MIN2( length, MGA_BUFFER_SIZE ); - (void) memcpy( mmesa->iload_buffer->address, - (GLubyte *) texImage->Data + tex_offset, to_copy ); - - if ( MGA_DEBUG & DEBUG_VERBOSE_TEXTURE ) - fprintf(stderr, "[%s:%d] address/size = 0x%08lx/%d\n", - __FILE__, __LINE__, - (long) (offset + tex_offset), - to_copy ); - - mgaFireILoadLocked( mmesa, offset + tex_offset, to_copy ); - tex_offset += to_copy; - length -= to_copy; - } - } else { - /* FIXME: the sync for direct copy reduces speed.. */ - /* This works, is slower for uploads to card space and needs - * additional synchronization with the dma stream. - */ - - UPDATE_LOCK(mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT); - - memcpy( mmesa->mgaScreen->texVirtual[t->base.heap->heapId] + offset, - texImage->Data, length ); - - if ( MGA_DEBUG & DEBUG_VERBOSE_TEXTURE ) - fprintf(stderr, "[%s:%d] address/size = 0x%08lx/%d\n", - __FILE__, __LINE__, - (long) (mmesa->mgaScreen->texVirtual[t->base.heap->heapId] - + offset), - length); - } -} - - -/** - * Upload the texture images associated with texture \a t. This might - * require the allocation of texture memory. - * - * \param mmesa Context pointer - * \param t Texture to be uploaded - */ - -int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - int i; - int ofs; - - - if ( (t == NULL) || (t->base.totalSize == 0) ) - return 0; - - LOCK_HARDWARE( mmesa ); - - if (t->base.memBlock == NULL ) { - int heap; - - heap = driAllocateTexture( mmesa->texture_heaps, mmesa->nr_heaps, - (driTextureObject *) t ); - if ( heap == -1 ) { - UNLOCK_HARDWARE( mmesa ); - return -1; - } - - assert(t->base.memBlock); - ofs = mmesa->mgaScreen->textureOffset[ heap ] - + t->base.memBlock->ofs; - - if ( MGA_IS_G200(mmesa) ) { - t->setup.texorg = ofs; - t->setup.texorg1 = ofs + t->offsets[1]; - t->setup.texorg2 = ofs + t->offsets[2]; - t->setup.texorg3 = ofs + t->offsets[3]; - t->setup.texorg4 = ofs + t->offsets[4]; - } - else { - t->setup.texorg = ofs | TO_texorgoffsetsel; - t->setup.texorg1 = t->offsets[1]; - t->setup.texorg2 = 0; - t->setup.texorg3 = 0; - t->setup.texorg4 = 0; - } - - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - } - - /* Let the world know we've used this memory recently. - */ - driUpdateTextureLRU( (driTextureObject *) t ); - - if (MGA_DEBUG&DEBUG_VERBOSE_TEXTURE) - fprintf(stderr, "[%s:%d] dispatch age: %d age freed memory: %d\n", - __FILE__, __LINE__, - GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge); - - if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa)) - mgaWaitAgeLocked( mmesa, mmesa->dirtyAge ); - - if (t->base.dirty_images[0]) { - const int numLevels = t->base.lastLevel - t->base.firstLevel + 1; - - if (MGA_DEBUG&DEBUG_VERBOSE_TEXTURE) - fprintf(stderr, "[%s:%d] dirty_images[0] = 0x%04x\n", - __FILE__, __LINE__, t->base.dirty_images[0] ); - - for (i = 0 ; i < numLevels ; i++) { - if ( (t->base.dirty_images[0] & (1U << i)) != 0 ) { - mgaUploadSubImage( mmesa, t, i ); - } - } - t->base.dirty_images[0] = 0; - } - - - UNLOCK_HARDWARE( mmesa ); - - return 0; -} diff --git a/src/mesa/drivers/dri/mga/mgatris.c b/src/mesa/drivers/dri/mga/mgatris.c deleted file mode 100644 index 7b06774adb4..00000000000 --- a/src/mesa/drivers/dri/mga/mgatris.c +++ /dev/null @@ -1,914 +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 <[email protected]> - */ - -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" -#include "main/mm.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "mgacontext.h" -#include "mgaioctl.h" -#include "mgatris.h" -#include "mgavb.h" - - -static void mgaRenderPrimitive( struct gl_context *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 ); -} - - -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 ) -{ - const GLfloat sz = 0.5 * CLAMP(mmesa->glCtx->Point.Size, - mmesa->glCtx->Const.MinPointSize, - mmesa->glCtx->Const.MaxPointSize); - const 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 - - /* 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; - - *(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; - const GLfloat width = CLAMP(mmesa->glCtx->Line.Width, - mmesa->glCtx->Const.MinLineWidth, - mmesa->glCtx->Const.MaxLineWidth); - 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 ) -{ - struct gl_context *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 ) -{ - struct gl_context *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 ) -{ - struct gl_context *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 { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_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_BACK_COLORS 0 -#define HAVE_SPEC 1 -#define HAVE_HW_FLATSHADE 0 -#define VERTEX mgaVertex -#define TAB rast_tab - - -#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_size * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - mga_color_t *color = (mga_color_t *)&((v)->ui[4]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4] - -#define VERT_SET_SPEC( v0, c ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \ -} while (0) - -#define VERT_COPY_SPEC( v0, v1 ) \ -do { \ - v0->v.specular.red = v1->v.specular.red; \ - v0->v.specular.green = v1->v.specular.green; \ - v0->v.specular.blue = v1->v.specular.blue; \ -} while (0) - -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx] -#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] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - (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 "tnl_dd/t_dd_unfilled.h" -#undef IND - -/*********************************************************************** - * 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 "tnl_dd/t_dd_tritmp.h" - -#define IND (MGA_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#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 "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" - -#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_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(); -} - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - - -#define VERT(x) (mgaVertex *)(vertptr + ((x)*vertex_size*sizeof(int))) -#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 vertex_size = mmesa->vertex_size; \ - 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( struct gl_context *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( struct gl_context *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -static void mgaFastRenderClippedPoly( struct gl_context *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 *start = (const GLuint *)VERT(elts[0]); - int i,j; - - for (i = 2 ; i < n ; i++) { - EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) VERT(elts[i-1]) ); - EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) VERT(elts[i]) ); - EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) start ); - } -} - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - -#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) -#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \ - DD_TRI_UNFILLED) - -void mgaChooseRenderState(struct gl_context *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|DD_TRI_STIPPLE)) { - 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; - - index |= MGA_FALLBACK_BIT; - } - - 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 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( struct gl_context *ctx, GLenum prim, GLuint hwprim ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - - FLUSH_BATCH( mmesa ); - - /* Update culling */ - if (mmesa->raster_primitive != prim) - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - - mmesa->raster_primitive = prim; -/* mmesa->hw_primitive = hwprim; */ - mmesa->hw_primitive = MGA_WA_TRIANGLES; /* disable mgarender.c for now */ - - if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple) - { - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - mmesa->setup.dwgctl &= ~(0xf<<20); - if (mmesa->raster_primitive == GL_TRIANGLES) - mmesa->setup.dwgctl |= mmesa->poly_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 mgarender.c. - */ -static void mgaRenderPrimitive( struct gl_context *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( struct gl_context *ctx ) -{ - if (MGA_CONTEXT(ctx)->RenderIndex & MGA_FALLBACK_BIT) - _swrast_flush( ctx ); -} - - - -/**********************************************************************/ -/* Manage total rasterization fallbacks */ -/**********************************************************************/ - -static const char * const fallbackStrings[] = { - "Texture mode", - "glDrawBuffer(GL_FRONT_AND_BACK)", - "read buffer", - "glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ZERO)", - "glRenderMode(selection or feedback)", - "No hardware stencil", - "glDepthFunc( GL_NEVER )", - "Mixing GL_CLAMP_TO_EDGE and GL_CLAMP", - "rasterization fallback option" -}; - -static const char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - - -void mgaFallback( struct gl_context *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; - if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) { - fprintf(stderr, "MGA begin rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } - 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->NewGLState |= (_MGA_NEW_RENDERSTATE | - _MGA_NEW_RASTERSETUP); - if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) { - fprintf(stderr, "MGA end rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } -} - - -void mgaDDInitTriFuncs( struct gl_context *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.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/src/mesa/drivers/dri/mga/mgatris.h b/src/mesa/drivers/dri/mga/mgatris.h deleted file mode 100644 index 2f574feb936..00000000000 --- a/src/mesa/drivers/dri/mga/mgatris.h +++ /dev/null @@ -1,51 +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 <[email protected]> - */ - -#ifndef MGATRIS_INC -#define MGATRIS_INC - -#include "main/mtypes.h" - -extern void mgaDDInitTriFuncs( struct gl_context *ctx ); -extern void mgaChooseRenderState( struct gl_context *ctx ); -extern void mgaRasterPrimitive( struct gl_context *ctx, GLenum prim, GLuint hwprim ); - -extern void mgaFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( ctx, bit, mode ) mgaFallback( ctx, bit, mode ) - -#define _MGA_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_LINE_STIPPLE | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_FLATSHADE | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_STIPPLE | \ - _NEW_POLYGONSTIPPLE) - -#endif diff --git a/src/mesa/drivers/dri/mga/mgavb.c b/src/mesa/drivers/dri/mga/mgavb.c deleted file mode 100644 index f098aa5cbc0..00000000000 --- a/src/mesa/drivers/dri/mga/mgavb.c +++ /dev/null @@ -1,478 +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 <[email protected]> - */ - -#include <stdlib.h> -#include "mgacontext.h" -#include "mgavb.h" -#include "mgatris.h" -#include "mgaioctl.h" -#include "mga_xmesa.h" - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "tnl/t_context.h" -#include "swrast/swrast.h" - - -#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)( struct gl_context *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( struct gl_context *ctx ); - GLuint vertex_size; - 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 VERTEX_COLOR mga_color_t -#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_SIZE() mmesa->vertex_size * sizeof(GLuint) - -#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 INTERP_VERTEX setup_tab[mmesa->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[mmesa->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 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 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 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" - -#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" - -#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" - -#define IND (MGA_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (MGA_TEX0_BIT|MGA_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#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" - -#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" - -#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#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" - -#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" - -#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#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" - -#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" - -#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" - - -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 mgaPrintSetupFlags(char *msg, GLuint flags ) -{ - 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," : ""); -} - - -void mgaCheckTexSizes( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /*fprintf(stderr, "%s\n", __FUNCTION__);*/ - - if (!setup_tab[mmesa->SetupIndex].check_tex_sizes(ctx)) { - mmesa->SetupIndex |= MGA_PTEX_BIT; - mmesa->SetupNewInputs = ~0; - - 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; - } - if (mmesa->Fallback) { - tnl->Driver.Render.Start(ctx); - } - } -} - - -void mgaBuildVertices( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - GLuint stride = mmesa->vertex_size * sizeof(int); - GLubyte *v = ((GLubyte *)mmesa->verts + (start * stride)); - - newinputs |= mmesa->SetupNewInputs; - mmesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[mmesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= MGA_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= MGA_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= MGA_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= MGA_TEX0_BIT|MGA_TEX1_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= MGA_FOG_BIT; - - if (mmesa->SetupIndex & MGA_PTEX_BIT) - ind = ~0; - - ind &= mmesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - - -void mgaChooseVertexState( struct gl_context *ctx ) -{ - 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; - - if (ctx->Fog.Enabled) - ind |= MGA_FOG_BIT; - - if (ctx->Texture._EnabledUnits & 0x2) { - /* unit 1 enabled */ - if (ctx->Texture._EnabledUnits & 0x1) { - /* unit 0 enabled */ - ind |= MGA_TEX1_BIT|MGA_TEX0_BIT; - } - else { - ind |= MGA_TEX0_BIT; - } - } - else if (ctx->Texture._EnabledUnits & 0x1) { - /* unit 0 enabled */ - 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->dirty |= MGA_UPLOAD_PIPE; - mmesa->vertex_format = setup_tab[ind].vertex_format; - mmesa->vertex_size = setup_tab[ind].vertex_size; - } -} - - - -void *mga_emit_contiguous_verts( struct gl_context *ctx, - GLuint start, - GLuint count, - void *dest) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint stride = mmesa->vertex_size * 4; - setup_tab[mmesa->SetupIndex].emit( ctx, start, count, dest, stride ); - return (void *)((char *)dest + stride * (count - start)); -} - - - -void mgaInitVB( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - mmesa->verts = (GLubyte *)_mesa_align_malloc(size * sizeof(mgaVertex), 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - } - - mmesa->dirty |= MGA_UPLOAD_PIPE; - mmesa->vertex_format = setup_tab[0].vertex_format; - mmesa->vertex_size = setup_tab[0].vertex_size; -} - - -void mgaFreeVB( struct gl_context *ctx ) -{ - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - if (mmesa->verts) { - _mesa_align_free(mmesa->verts); - mmesa->verts = 0; - } -} - diff --git a/src/mesa/drivers/dri/mga/mgavb.h b/src/mesa/drivers/dri/mga/mgavb.h deleted file mode 100644 index 20e5d8ba700..00000000000 --- a/src/mesa/drivers/dri/mga/mgavb.h +++ /dev/null @@ -1,65 +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 <[email protected]> - */ - -#ifndef MGAVB_INC -#define MGAVB_INC - -#include "main/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) - - -extern void mgaChooseVertexState( struct gl_context *ctx ); -extern void mgaCheckTexSizes( struct gl_context *ctx ); -extern void mgaBuildVertices( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint newinputs ); - -extern void mgaPrintSetupFlags(char *msg, GLuint flags ); - -extern void mgaInitVB( struct gl_context *ctx ); -extern void mgaFreeVB( struct gl_context *ctx ); - -extern void *mga_emit_contiguous_verts( struct gl_context *ctx, - GLuint start, - GLuint count, - void *dest ); - -extern void mga_translate_vertex(struct gl_context *ctx, - const mgaVertex *src, - SWvertex *dst); - -extern void mga_print_vertex( struct gl_context *ctx, const mgaVertex *v ); - -#endif diff --git a/src/mesa/drivers/dri/mga/server/mga.h b/src/mesa/drivers/dri/mga/server/mga.h deleted file mode 100644 index d7790e47794..00000000000 --- a/src/mesa/drivers/dri/mga/server/mga.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * MGA Millennium (MGA2064W) functions - * - * Copyright 1996 The XFree86 Project, Inc. - * - * Authors - * Dirk Hohndel - * David Dawes - */ - -#ifndef MGA_H -#define MGA_H - - -#include "xf86drm.h" -#include "linux/types.h" - - -#define PCI_CHIP_MGA2085 0x0518 -#define PCI_CHIP_MGA2064 0x0519 -#define PCI_CHIP_MGA1064 0x051A -#define PCI_CHIP_MGA2164 0x051B -#define PCI_CHIP_MGA2164_AGP 0x051F -#define PCI_CHIP_MGAG200_PCI 0x0520 -#define PCI_CHIP_MGAG200 0x0521 -#define PCI_CHIP_MGAG400 0x0525 -#define PCI_CHIP_MGAG550 0x2527 -#define PCI_CHIP_MGAG100_PCI 0x1000 -#define PCI_CHIP_MGAG100 0x1001 - - -# define MMIO_IN8(base, offset) \ - *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) -# define MMIO_IN16(base, offset) \ - *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset)) -# define MMIO_IN32(base, offset) \ - *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) -# define MMIO_OUT8(base, offset, val) \ - *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val) -# define MMIO_OUT16(base, offset, val) \ - *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset)) = (val) -# define MMIO_OUT32(base, offset, val) \ - *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = (val) - -#define INREG8(addr) MMIO_IN8(pMga->IOBase, addr) -#define INREG16(addr) MMIO_IN16(pMga->IOBase, addr) -#define INREG(addr) MMIO_IN32(pMga->IOBase, addr) -#define OUTREG8(addr, val) MMIO_OUT8(pMga->IOBase, addr, val) -#define OUTREG16(addr, val) MMIO_OUT16(pMga->IOBase, addr, val) -#define OUTREG(addr, val) MMIO_OUT32(pMga->IOBase, addr, val) - -#define MGAIOMAPSIZE 0x00004000 - - -typedef struct { - int Chipset; /**< \brief Chipset number */ - - int irq; /**< \brief IRQ number */ - - - int frontOffset; /**< \brief Front color buffer offset */ - int frontPitch; /**< \brief Front color buffer pitch */ - int backOffset; /**< \brief Back color buffer offset */ - int backPitch; /**< \brief Back color buffer pitch */ - int depthOffset; /**< \brief Depth buffer offset */ - int depthPitch; /**< \brief Depth buffer pitch */ - int textureOffset; /**< \brief Texture area offset */ - int textureSize; /**< \brief Texture area size */ - int logTextureGranularity; - - /** - * \name AGP - */ - /*@{*/ - drmSize agpSize; /**< \brief AGP map size */ - int agpMode; /**< \brief AGP mode */ - /*@}*/ - - drmRegion agp; - - /* PCI mappings */ - drmRegion registers; - drmRegion status; - - /* AGP mappings */ - drmRegion warp; - drmRegion primary; - drmRegion buffers; - drmRegion agpTextures; - - drmBufMapPtr drmBuffers; - - unsigned long IOAddress; - unsigned char *IOBase; - int HasSDRAM; - - __u32 reg_ien; -} MGARec, *MGAPtr; - - - -#define MGA_FRONT 0x1 -#define MGA_BACK 0x2 -#define MGA_DEPTH 0x4 - -#define MGA_AGP_1X_MODE 0x01 -#define MGA_AGP_2X_MODE 0x02 -#define MGA_AGP_4X_MODE 0x04 -#define MGA_AGP_MODE_MASK 0x07 - - -#endif diff --git a/src/mesa/drivers/dri/mga/server/mga_bios.h b/src/mesa/drivers/dri/mga/server/mga_bios.h deleted file mode 100644 index 5dcfc1614d4..00000000000 --- a/src/mesa/drivers/dri/mga/server/mga_bios.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef MGA_BIOS_H -#define MGA_BIOS_H - - -/* - * MGABiosInfo - This struct describes the video BIOS info block. - * - * DESCRIPTION - * Do not mess with this, unless you know what you are doing. - * The data lengths and types are critical. - * - * HISTORY - * October 7, 1996 - [aem] Andrew E. Mileski - * This struct was shamelessly stolen from the MGA DDK. - * It has been reformatted, and the data types changed. - */ -typedef struct { - /* Length of this structure in bytes */ - __u16 StructLen; - - /* - * Unique number identifying the product type - * 0 : MGA-S1P20 (2MB base with 175MHz Ramdac) - * 1 : MGA-S1P21 (2MB base with 220MHz Ramdac) - * 2 : Reserved - * 3 : Reserved - * 4 : MGA-S1P40 (4MB base with 175MHz Ramdac) - * 5 : MGA-S1P41 (4MB base with 220MHz Ramdac) - */ - __u16 ProductID; - - /* Serial number of the board */ - __u8 SerNo[ 10 ]; - - /* - * Manufacturing date of the board (at product test) - * Format: yyyy yyym mmmd dddd - */ - __u16 ManufDate; - - /* Identification of manufacturing site */ - __u16 ManufId; - - /* - * Number and revision level of the PCB - * Format: nnnn nnnn nnnr rrrr - * n = PCB number ex:576 (from 0->2047) - * r = PCB revision (from 0->31) - */ - __u16 PCBInfo; - - /* Identification of any PMBs */ - __u16 PMBInfo; - - /* - * Bit 0-7 : Ramdac speed (0=175MHz, 1=220MHz) - * Bit 8-15 : Ramdac type (0=TVP3026, 1=TVP3027) - */ - __u16 RamdacType; - - /* Maximum PCLK of the ramdac */ - __u16 PclkMax; - - /* Maximum LDCLK supported by the WRAM memory */ - __u16 LclkMax; - - /* Maximum MCLK of base board */ - __u16 ClkBase; - - /* Maximum MCLK of 4Mb board */ - __u16 Clk4MB; - - /* Maximum MCLK of 8Mb board */ - __u16 Clk8MB; - - /* Maximum MCLK of board with multimedia module */ - __u16 ClkMod; - - /* Diagnostic test pass frequency */ - __u16 TestClk; - - /* Default VGA mode1 pixel frequency */ - __u16 VGAFreq1; - - /* Default VGA mode2 pixel frequency */ - __u16 VGAFreq2; - - /* Date of last BIOS programming/update */ - __u16 ProgramDate; - - /* Number of times BIOS has been programmed */ - __u16 ProgramCnt; - - /* Support for up to 32 hardware/software options */ - __u32 Options; - - /* Support for up to 32 hardware/software features */ - __u32 FeatFlag; - - /* Definition of VGA mode MCLK */ - __u16 VGAClk; - - /* Indicate the revision level of this header struct */ - __u16 StructRev; - - __u16 Reserved[ 3 ]; -} MGABiosInfo; - -/* from the PINS structure, refer pins info from MGA */ -typedef struct tagParamMGA { - __u16 PinID; /* 0 */ - __u8 StructLen; /* 2 */ - __u8 Rsvd1; /* 3 */ - __u16 StructRev; /* 4 */ - __u16 ProgramDate; /* 6 */ - __u16 ProgramCnt; /* 8 */ - __u16 ProductID; /* 10 */ - __u8 SerNo[16]; /* 12 */ - __u8 PLInfo[6]; /* 28 */ - __u16 PCBInfo; /* 34 */ - __u32 FeatFlag; /* 36 */ - __u8 RamdacType; /* 40 */ - __u8 RamdacSpeed; /* 41 */ - __u8 PclkMax; /* 42 */ - __u8 ClkGE; /* 43 */ - __u8 ClkMem; /* 44 */ - __u8 Clk4MB; /* 45 */ - __u8 Clk8MB; /* 46 */ - __u8 ClkMod; /* 47 */ - __u8 TestClk; /* 48 */ - __u8 VGAFreq1; /* 49 */ - __u8 VGAFreq2; /* 50 */ - __u8 MCTLWTST; /* 51 */ - __u8 VidCtrl; /* 52 */ - __u8 Clk12MB; /* 53 */ - __u8 Clk16MB; /* 54 */ - __u8 Reserved[8]; /* 55-62 */ - __u8 PinCheck; /* 63 */ -} MGABios2Info; - -#endif diff --git a/src/mesa/drivers/dri/mga/server/mga_dri.h b/src/mesa/drivers/dri/mga/server/mga_dri.h deleted file mode 100644 index 1ce07028f17..00000000000 --- a/src/mesa/drivers/dri/mga/server/mga_dri.h +++ /dev/null @@ -1,112 +0,0 @@ - -/* - * 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 AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION 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 <[email protected]> - * Gareth Hughes <[email protected]> - */ - -#ifndef __MGA_DRI_H__ -#define __MGA_DRI_H__ - -#include "xf86drm.h" -#include "drm.h" -#include "mga_drm.h" - -#define MGA_DEFAULT_AGP_SIZE 64 -#define MGA_DEFAULT_AGP_MODE 4 -#define MGA_MAX_AGP_MODE 4 - -/* Buffer are aligned on 4096 byte boundaries. - */ -#define MGA_BUFFER_ALIGN 0x00000fff - -#ifdef __GNUC__ -# define DEPRECATED __attribute__ ((deprecated)) -#else -# define DEPRECATED -#endif - -#if 1 -typedef struct _mgaDrmRegion { - drm_handle_t handle; - unsigned int offset; - drmSize size; -} mgaDrmRegion, *mgaDrmRegionPtr; -#else -#define mgaDrmRegion drmRegion -#endif - -typedef struct { - int chipset; - int width DEPRECATED; - int height DEPRECATED; - int mem DEPRECATED; - int cpp; - - int agpMode; - - unsigned int frontOffset; - unsigned int frontPitch; - - unsigned int backOffset; - unsigned int backPitch; - - unsigned int depthOffset; - unsigned int depthPitch; - - unsigned int textureOffset; - unsigned int textureSize; - int logTextureGranularity DEPRECATED; - - /* Allow calculation of setup dma addresses. - */ - unsigned int agpBufferOffset DEPRECATED; - - unsigned int agpTextureOffset; - unsigned int agpTextureSize; - int logAgpTextureGranularity DEPRECATED; - - unsigned int mAccess DEPRECATED; - - /** - * \name DRM memory regions. - * - * \todo - * Several of these fields are no longer used (and will never be used - * again) on the client-side. None of them, except \c registers, are used - * on the server-side. At some point when it is safe to do so (probably - * for the X.org 6.9 / 7.0 release), these fields should be removed. - */ - /*@{*/ - mgaDrmRegion registers; /**< MMIO registers. */ - mgaDrmRegion status DEPRECATED; /**< No longer used on the client-side. */ - mgaDrmRegion primary; /**< Primary DMA region. */ - mgaDrmRegion buffers DEPRECATED; /**< No longer used on the client-side. */ - /*@}*/ - - unsigned int sarea_priv_offset; -} MGADRIRec, *MGADRIPtr; - -#endif diff --git a/src/mesa/drivers/dri/mga/server/mga_macros.h b/src/mesa/drivers/dri/mga/server/mga_macros.h deleted file mode 100644 index 189e1415d05..00000000000 --- a/src/mesa/drivers/dri/mga/server/mga_macros.h +++ /dev/null @@ -1,117 +0,0 @@ - -#ifndef _MGA_MACROS_H_ -#define _MGA_MACROS_H_ - -#ifndef PSZ -#define PSZ 8 -#endif - -#if PSZ == 8 -#define REPLICATE(r) r &= 0xFF; r |= r << 8; r |= r << 16 -#elif PSZ == 16 -#define REPLICATE(r) r &= 0xFFFF; r |= r << 16 -#elif PSZ == 24 -#define REPLICATE(r) r &= 0xFFFFFF; r |= r << 24 -#else -#define REPLICATE(r) /* */ -#endif - -#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) - -#ifdef XF86DRI -#define MGA_SYNC_XTAG 0x275f4200 - -#define MGABUSYWAIT() do { \ -OUTREG(MGAREG_DWGSYNC, MGA_SYNC_XTAG); \ -while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \ -}while(0); - -#endif - -#define MGAISBUSY() (INREG8(MGAREG_Status + 2) & 0x01) - -#define WAITFIFO(cnt) \ - if(!pMga->UsePCIRetry) {\ - register int n = cnt; \ - if(n > pMga->FifoSize) n = pMga->FifoSize; \ - while(pMga->fifoCount < (n))\ - pMga->fifoCount = INREG8(MGAREG_FIFOSTATUS);\ - pMga->fifoCount -= n;\ - } - -#define XYADDRESS(x,y) \ - ((y) * pMga->CurrentLayout.displayWidth + (x) + pMga->YDstOrg) - -#define MAKEDMAINDEX(index) ((((index) >> 2) & 0x7f) | (((index) >> 6) & 0x80)) - -#define DMAINDICES(one,two,three,four) \ - ( MAKEDMAINDEX(one) | \ - (MAKEDMAINDEX(two) << 8) | \ - (MAKEDMAINDEX(three) << 16) | \ - (MAKEDMAINDEX(four) << 24) ) - -#if PSZ == 24 -#define SET_PLANEMASK(p) /**/ -#else -#define SET_PLANEMASK(p) \ - if(!(pMga->AccelFlags & MGA_NO_PLANEMASK) && ((p) != pMga->PlaneMask)) { \ - pMga->PlaneMask = (p); \ - REPLICATE((p)); \ - OUTREG(MGAREG_PLNWT,(p)); \ - } -#endif - -#define SET_FOREGROUND(c) \ - if((c) != pMga->FgColor) { \ - pMga->FgColor = (c); \ - REPLICATE((c)); \ - OUTREG(MGAREG_FCOL,(c)); \ - } - -#define SET_BACKGROUND(c) \ - if((c) != pMga->BgColor) { \ - pMga->BgColor = (c); \ - REPLICATE((c)); \ - OUTREG(MGAREG_BCOL,(c)); \ - } - -#define DISABLE_CLIP() { \ - pMga->AccelFlags &= ~CLIPPER_ON; \ - WAITFIFO(1); \ - OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); } - -#ifdef XF86DRI -#define CHECK_DMA_QUIESCENT(pMGA, pScrn) { \ - if (!pMGA->haveQuiescense) { \ - pMGA->GetQuiescence( pScrn ); \ - } \ -} -#else -#define CHECK_DMA_QUIESCENT(pMGA, pScrn) -#endif - -#ifdef USEMGAHAL -#define HAL_CHIPSETS ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || \ - (pMga->Chipset == PCI_CHIP_MGAG200) || \ - (pMga->Chipset == PCI_CHIP_MGAG400) || \ - (pMga->Chipset == PCI_CHIP_MGAG550)) - -#define MGA_HAL(x) { \ - MGAPtr pMga = MGAPTR(pScrn); \ - if (pMga->HALLoaded && HAL_CHIPSETS) { x; } \ -} -#define MGA_NOT_HAL(x) { \ - MGAPtr pMga = MGAPTR(pScrn); \ - if (!pMga->HALLoaded || !HAL_CHIPSETS) { x; } \ -} -#else -#define MGA_NOT_HAL(x) { x; } -#endif - -#define MGAISGx50(x) ( (((x)->Chipset == PCI_CHIP_MGAG400) && ((x)->ChipRev >= 0x80)) || \ - ((x)->Chipset == PCI_CHIP_MGAG550) ) - -#define MGA_DH_NEEDS_HAL(x) (((x)->Chipset == PCI_CHIP_MGAG400) && \ - ((x)->ChipRev < 0x80)) - -#endif /* _MGA_MACROS_H_ */ diff --git a/src/mesa/drivers/dri/mga/server/mga_reg.h b/src/mesa/drivers/dri/mga/server/mga_reg.h deleted file mode 100644 index d51366d44e2..00000000000 --- a/src/mesa/drivers/dri/mga/server/mga_reg.h +++ /dev/null @@ -1,482 +0,0 @@ - - - - - - -/* - * MGA Millennium (MGA2064W) functions - * MGA Mystique (MGA1064SG) functions - * - * Copyright 1996 The XFree86 Project, Inc. - * - * Authors - * Dirk Hohndel - * David Dawes - * Contributors: - * Guy DESBIEF, Aix-en-provence, France - * MGA1064SG Mystique register file - */ - - -#ifndef _MGA_REG_H_ -#define _MGA_REG_H_ - -#define MGAREG_DWGCTL 0x1c00 -#define MGAREG_MACCESS 0x1c04 -#define MGA_MACCESS_PW16 0x00000001 -#define MGA_MACCESS_PW32 0x00000002 -/* the following is a mystique only register */ -#define MGAREG_MCTLWTST 0x1c08 -#define MGAREG_ZORG 0x1c0c - -#define MGAREG_PAT0 0x1c10 -#define MGAREG_PAT1 0x1c14 -#define MGAREG_PLNWT 0x1c1c - -#define MGAREG_BCOL 0x1c20 -#define MGAREG_FCOL 0x1c24 - -#define MGAREG_SRC0 0x1c30 -#define MGAREG_SRC1 0x1c34 -#define MGAREG_SRC2 0x1c38 -#define MGAREG_SRC3 0x1c3c - -#define MGAREG_XYSTRT 0x1c40 -#define MGAREG_XYEND 0x1c44 - -#define MGAREG_SHIFT 0x1c50 -/* the following is a mystique only register */ -#define MGAREG_DMAPAD 0x1c54 -#define MGAREG_SGN 0x1c58 -#define MGAREG_LEN 0x1c5c - -#define MGAREG_AR0 0x1c60 -#define MGAREG_AR1 0x1c64 -#define MGAREG_AR2 0x1c68 -#define MGAREG_AR3 0x1c6c -#define MGAREG_AR4 0x1c70 -#define MGAREG_AR5 0x1c74 -#define MGAREG_AR6 0x1c78 - -#define MGAREG_CXBNDRY 0x1c80 -#define MGAREG_FXBNDRY 0x1c84 -#define MGAREG_YDSTLEN 0x1c88 -#define MGAREG_PITCH 0x1c8c - -#define MGAREG_YDST 0x1c90 -#define MGAREG_YDSTORG 0x1c94 -#define MGAREG_YTOP 0x1c98 -#define MGAREG_YBOT 0x1c9c - -#define MGAREG_CXLEFT 0x1ca0 -#define MGAREG_CXRIGHT 0x1ca4 -#define MGAREG_FXLEFT 0x1ca8 -#define MGAREG_FXRIGHT 0x1cac - -#define MGAREG_XDST 0x1cb0 - -#define MGAREG_DR0 0x1cc0 -#define MGAREG_DR1 0x1cc4 -#define MGAREG_DR2 0x1cc8 -#define MGAREG_DR3 0x1ccc - -#define MGAREG_DR4 0x1cd0 -#define MGAREG_DR5 0x1cd4 -#define MGAREG_DR6 0x1cd8 -#define MGAREG_DR7 0x1cdc - -#define MGAREG_DR8 0x1ce0 -#define MGAREG_DR9 0x1ce4 -#define MGAREG_DR10 0x1ce8 -#define MGAREG_DR11 0x1cec - -#define MGAREG_DR12 0x1cf0 -#define MGAREG_DR13 0x1cf4 -#define MGAREG_DR14 0x1cf8 -#define MGAREG_DR15 0x1cfc - -#define MGAREG_SRCORG 0x2cb4 -#define MGAREG_DSTORG 0x2cb8 - -/* add or or this to one of the previous "power registers" to start - the drawing engine */ - -#define MGAREG_EXEC 0x0100 - -#define MGAREG_FIFOSTATUS 0x1e10 -#define MGAREG_Status 0x1e14 -#define MGAREG_ICLEAR 0x1e18 -#define MGAREG_IEN 0x1e1c - -#define MGAREG_VCOUNT 0x1e20 - -#define MGAREG_Reset 0x1e40 - -#define MGAREG_OPMODE 0x1e54 - -/* Warp Registers */ -#define MGAREG_WIADDR 0x1dc0 -#define MGAREG_WIADDR2 0x1dd8 -#define MGAREG_WGETMSB 0x1dc8 -#define MGAREG_WVRTXSZ 0x1dcc -#define MGAREG_WACCEPTSEQ 0x1dd4 -#define MGAREG_WMISC 0x1e70 - -/* OPMODE register additives */ - -#define MGAOPM_DMA_GENERAL (0x00 << 2) -#define MGAOPM_DMA_BLIT (0x01 << 2) -#define MGAOPM_DMA_VECTOR (0x10 << 2) - -/* DWGCTL register additives */ - -/* Lines */ - -#define MGADWG_LINE_OPEN 0x00 -#define MGADWG_AUTOLINE_OPEN 0x01 -#define MGADWG_LINE_CLOSE 0x02 -#define MGADWG_AUTOLINE_CLOSE 0x03 - -/* Trapezoids */ -#define MGADWG_TRAP 0x04 -#define MGADWG_TEXTURE_TRAP 0x05 - -/* BitBlts */ - -#define MGADWG_BITBLT 0x08 -#define MGADWG_FBITBLT 0x0c -#define MGADWG_ILOAD 0x09 -#define MGADWG_ILOAD_SCALE 0x0d -#define MGADWG_ILOAD_FILTER 0x0f -#define MGADWG_ILOAD_HIQH 0x07 -#define MGADWG_ILOAD_HIQHV 0x0e -#define MGADWG_IDUMP 0x0a - -/* atype access to WRAM */ - -#define MGADWG_RPL ( 0x00 << 4 ) -#define MGADWG_RSTR ( 0x01 << 4 ) -#define MGADWG_ZI ( 0x03 << 4 ) -#define MGADWG_BLK ( 0x04 << 4 ) -#define MGADWG_I ( 0x07 << 4 ) - -/* specifies whether bit blits are linear or xy */ -#define MGADWG_LINEAR ( 0x01 << 7 ) - -/* z drawing mode. use MGADWG_NOZCMP for always */ - -#define MGADWG_NOZCMP ( 0x00 << 8 ) -#define MGADWG_ZE ( 0x02 << 8 ) -#define MGADWG_ZNE ( 0x03 << 8 ) -#define MGADWG_ZLT ( 0x04 << 8 ) -#define MGADWG_ZLTE ( 0x05 << 8 ) -#define MGADWG_GT ( 0x06 << 8 ) -#define MGADWG_GTE ( 0x07 << 8 ) - -/* use this to force colour expansion circuitry to do its stuff */ - -#define MGADWG_SOLID ( 0x01 << 11 ) - -/* ar register at zero */ - -#define MGADWG_ARZERO ( 0x01 << 12 ) - -#define MGADWG_SGNZERO ( 0x01 << 13 ) - -#define MGADWG_SHIFTZERO ( 0x01 << 14 ) - -/* See table on 4-43 for bop ALU operations */ - -/* See table on 4-44 for translucidity masks */ - -#define MGADWG_BMONOLEF ( 0x00 << 25 ) -#define MGADWG_BMONOWF ( 0x04 << 25 ) -#define MGADWG_BPLAN ( 0x01 << 25 ) - -/* note that if bfcol is specified and you're doing a bitblt, it causes - a fbitblt to be performed, so check that you obey the fbitblt rules */ - -#define MGADWG_BFCOL ( 0x02 << 25 ) -#define MGADWG_BUYUV ( 0x0e << 25 ) -#define MGADWG_BU32BGR ( 0x03 << 25 ) -#define MGADWG_BU32RGB ( 0x07 << 25 ) -#define MGADWG_BU24BGR ( 0x0b << 25 ) -#define MGADWG_BU24RGB ( 0x0f << 25 ) - -#define MGADWG_PATTERN ( 0x01 << 29 ) -#define MGADWG_TRANSC ( 0x01 << 30 ) -#define MGAREG_MISC_WRITE 0x3c2 -#define MGAREG_MISC_READ 0x3cc -#define MGAREG_MISC_IOADSEL (0x1 << 0) -#define MGAREG_MISC_RAMMAPEN (0x1 << 1) -#define MGAREG_MISC_CLK_SEL_VGA25 (0x0 << 2) -#define MGAREG_MISC_CLK_SEL_VGA28 (0x1 << 2) -#define MGAREG_MISC_CLK_SEL_MGA_PIX (0x2 << 2) -#define MGAREG_MISC_CLK_SEL_MGA_MSK (0x3 << 2) -#define MGAREG_MISC_VIDEO_DIS (0x1 << 4) -#define MGAREG_MISC_HIGH_PG_SEL (0x1 << 5) - -/* MMIO VGA registers */ -#define MGAREG_SEQ_INDEX 0x1fc4 -#define MGAREG_SEQ_DATA 0x1fc5 -#define MGAREG_CRTC_INDEX 0x1fd4 -#define MGAREG_CRTC_DATA 0x1fd5 -#define MGAREG_CRTCEXT_INDEX 0x1fde -#define MGAREG_CRTCEXT_DATA 0x1fdf - - - -/* MGA bits for registers PCI_OPTION_REG */ -#define MGA1064_OPT_SYS_CLK_PCI ( 0x00 << 0 ) -#define MGA1064_OPT_SYS_CLK_PLL ( 0x01 << 0 ) -#define MGA1064_OPT_SYS_CLK_EXT ( 0x02 << 0 ) -#define MGA1064_OPT_SYS_CLK_MSK ( 0x03 << 0 ) - -#define MGA1064_OPT_SYS_CLK_DIS ( 0x01 << 2 ) -#define MGA1064_OPT_G_CLK_DIV_1 ( 0x01 << 3 ) -#define MGA1064_OPT_M_CLK_DIV_1 ( 0x01 << 4 ) - -#define MGA1064_OPT_SYS_PLL_PDN ( 0x01 << 5 ) -#define MGA1064_OPT_VGA_ION ( 0x01 << 8 ) - -/* MGA registers in PCI config space */ -#define PCI_MGA_INDEX 0x44 -#define PCI_MGA_DATA 0x48 -#define PCI_MGA_OPTION2 0x50 -#define PCI_MGA_OPTION3 0x54 - -#define RAMDAC_OFFSET 0x3c00 - -/* TVP3026 direct registers */ - -#define TVP3026_INDEX 0x00 -#define TVP3026_WADR_PAL 0x00 -#define TVP3026_COL_PAL 0x01 -#define TVP3026_PIX_RD_MSK 0x02 -#define TVP3026_RADR_PAL 0x03 -#define TVP3026_CUR_COL_ADDR 0x04 -#define TVP3026_CUR_COL_DATA 0x05 -#define TVP3026_DATA 0x0a -#define TVP3026_CUR_RAM 0x0b -#define TVP3026_CUR_XLOW 0x0c -#define TVP3026_CUR_XHI 0x0d -#define TVP3026_CUR_YLOW 0x0e -#define TVP3026_CUR_YHI 0x0f - -/* TVP3026 indirect registers */ - -#define TVP3026_SILICON_REV 0x01 -#define TVP3026_CURSOR_CTL 0x06 -#define TVP3026_LATCH_CTL 0x0f -#define TVP3026_TRUE_COLOR_CTL 0x18 -#define TVP3026_MUX_CTL 0x19 -#define TVP3026_CLK_SEL 0x1a -#define TVP3026_PAL_PAGE 0x1c -#define TVP3026_GEN_CTL 0x1d -#define TVP3026_MISC_CTL 0x1e -#define TVP3026_GEN_IO_CTL 0x2a -#define TVP3026_GEN_IO_DATA 0x2b -#define TVP3026_PLL_ADDR 0x2c -#define TVP3026_PIX_CLK_DATA 0x2d -#define TVP3026_MEM_CLK_DATA 0x2e -#define TVP3026_LOAD_CLK_DATA 0x2f -#define TVP3026_KEY_RED_LOW 0x32 -#define TVP3026_KEY_RED_HI 0x33 -#define TVP3026_KEY_GREEN_LOW 0x34 -#define TVP3026_KEY_GREEN_HI 0x35 -#define TVP3026_KEY_BLUE_LOW 0x36 -#define TVP3026_KEY_BLUE_HI 0x37 -#define TVP3026_KEY_CTL 0x38 -#define TVP3026_MCLK_CTL 0x39 -#define TVP3026_SENSE_TEST 0x3a -#define TVP3026_TEST_DATA 0x3b -#define TVP3026_CRC_LSB 0x3c -#define TVP3026_CRC_MSB 0x3d -#define TVP3026_CRC_CTL 0x3e -#define TVP3026_ID 0x3f -#define TVP3026_RESET 0xff - - -/* MGA1064 DAC Register file */ -/* MGA1064 direct registers */ - -#define MGA1064_INDEX 0x00 -#define MGA1064_WADR_PAL 0x00 -#define MGA1064_COL_PAL 0x01 -#define MGA1064_PIX_RD_MSK 0x02 -#define MGA1064_RADR_PAL 0x03 -#define MGA1064_DATA 0x0a - -#define MGA1064_CUR_XLOW 0x0c -#define MGA1064_CUR_XHI 0x0d -#define MGA1064_CUR_YLOW 0x0e -#define MGA1064_CUR_YHI 0x0f - -/* MGA1064 indirect registers */ -#define MGA1064_DVI_PIPE_CTL 0x03 -#define MGA1064_CURSOR_BASE_ADR_LOW 0x04 -#define MGA1064_CURSOR_BASE_ADR_HI 0x05 -#define MGA1064_CURSOR_CTL 0x06 -#define MGA1064_CURSOR_COL0_RED 0x08 -#define MGA1064_CURSOR_COL0_GREEN 0x09 -#define MGA1064_CURSOR_COL0_BLUE 0x0a - -#define MGA1064_CURSOR_COL1_RED 0x0c -#define MGA1064_CURSOR_COL1_GREEN 0x0d -#define MGA1064_CURSOR_COL1_BLUE 0x0e - -#define MGA1064_CURSOR_COL2_RED 0x010 -#define MGA1064_CURSOR_COL2_GREEN 0x011 -#define MGA1064_CURSOR_COL2_BLUE 0x012 - -#define MGA1064_VREF_CTL 0x018 - -#define MGA1064_MUL_CTL 0x19 -#define MGA1064_MUL_CTL_8bits 0x0 -#define MGA1064_MUL_CTL_15bits 0x01 -#define MGA1064_MUL_CTL_16bits 0x02 -#define MGA1064_MUL_CTL_24bits 0x03 -#define MGA1064_MUL_CTL_32bits 0x04 -#define MGA1064_MUL_CTL_2G8V16bits 0x05 -#define MGA1064_MUL_CTL_G16V16bits 0x06 -#define MGA1064_MUL_CTL_32_24bits 0x07 - -#define MGAGDAC_XVREFCTRL 0x18 -#define MGA1064_PIX_CLK_CTL 0x1a -#define MGA1064_PIX_CLK_CTL_CLK_DIS ( 0x01 << 2 ) -#define MGA1064_PIX_CLK_CTL_CLK_POW_DOWN ( 0x01 << 3 ) -#define MGA1064_PIX_CLK_CTL_SEL_PCI ( 0x00 << 0 ) -#define MGA1064_PIX_CLK_CTL_SEL_PLL ( 0x01 << 0 ) -#define MGA1064_PIX_CLK_CTL_SEL_EXT ( 0x02 << 0 ) -#define MGA1064_PIX_CLK_CTL_SEL_MSK ( 0x03 << 0 ) - -#define MGA1064_GEN_CTL 0x1d -#define MGA1064_MISC_CTL 0x1e -#define MGA1064_MISC_CTL_DAC_POW_DN ( 0x01 << 0 ) -#define MGA1064_MISC_CTL_VGA ( 0x01 << 1 ) -#define MGA1064_MISC_CTL_DIS_CON ( 0x03 << 1 ) -#define MGA1064_MISC_CTL_MAFC ( 0x02 << 1 ) -#define MGA1064_MISC_CTL_VGA8 ( 0x01 << 3 ) -#define MGA1064_MISC_CTL_DAC_RAM_CS ( 0x01 << 4 ) - -#define MGA1064_GEN_IO_CTL 0x2a -#define MGA1064_GEN_IO_DATA 0x2b -#define MGA1064_SYS_PLL_M 0x2c -#define MGA1064_SYS_PLL_N 0x2d -#define MGA1064_SYS_PLL_P 0x2e -#define MGA1064_SYS_PLL_STAT 0x2f -#define MGA1064_ZOOM_CTL 0x38 -#define MGA1064_SENSE_TST 0x3a - -#define MGA1064_CRC_LSB 0x3c -#define MGA1064_CRC_MSB 0x3d -#define MGA1064_CRC_CTL 0x3e -#define MGA1064_COL_KEY_MSK_LSB 0x40 -#define MGA1064_COL_KEY_MSK_MSB 0x41 -#define MGA1064_COL_KEY_LSB 0x42 -#define MGA1064_COL_KEY_MSB 0x43 -#define MGA1064_PIX_PLLA_M 0x44 -#define MGA1064_PIX_PLLA_N 0x45 -#define MGA1064_PIX_PLLA_P 0x46 -#define MGA1064_PIX_PLLB_M 0x48 -#define MGA1064_PIX_PLLB_N 0x49 -#define MGA1064_PIX_PLLB_P 0x4a -#define MGA1064_PIX_PLLC_M 0x4c -#define MGA1064_PIX_PLLC_N 0x4d -#define MGA1064_PIX_PLLC_P 0x4e - -#define MGA1064_PIX_PLL_STAT 0x4f - -/*Added for G450 dual head*/ -/* Supported PLL*/ -#define __PIXEL_PLL 1 -#define __SYSTEM_PLL 2 -#define __VIDEO_PLL 3 - -#define MGA1064_VID_PLL_P 0x8D -#define MGA1064_VID_PLL_M 0x8E -#define MGA1064_VID_PLL_N 0x8F - -#define MGA1064_DISP_CTL 0x8a -#define MGA1064_SYNC_CTL 0x8b -#define MGA1064_PWR_CTL 0xa0 -#define MGA1064_PAN_CTL 0xa2 - -/* Using crtc2 */ -#define MGAREG2_C2CTL 0x10 -#define MGAREG2_C2HPARAM 0x14 -#define MGAREG2_C2HSYNC 0x18 -#define MGAREG2_C2VPARAM 0x1c -#define MGAREG2_C2VSYNC 0x20 -#define MGAREG2_C2STARTADD0 0x28 - -#define MGAREG2_C2OFFSET 0x40 -#define MGAREG2_C2DATACTL 0x4c - -#define MGAREG_C2CTL 0x3c10 -#define MGAREG_C2HPARAM 0x3c14 -#define MGAREG_C2HSYNC 0x3c18 -#define MGAREG_C2VPARAM 0x3c1c -#define MGAREG_C2VSYNC 0x3c20 -#define MGAREG_C2STARTADD0 0x3c28 - -#define MGAREG_C2OFFSET 0x3c40 -#define MGAREG_C2DATACTL 0x3c4c - -#define MGA1064_DISP_CTL 0x8a -#define MGA1064_SYNC_CTL 0x8b -#define MGA1064_PWR_CTL 0xa0 - -/* video register */ - -#define MGAREG_BESA1C3ORG 0x3d60 -#define MGAREG_BESA1CORG 0x3d10 -#define MGAREG_BESA1ORG 0x3d00 -#define MGAREG_BESCTL 0x3d20 -#define MGAREG_BESGLOBCTL 0x3dc0 -#define MGAREG_BESHCOORD 0x3d28 -#define MGAREG_BESHISCAL 0x3d30 -#define MGAREG_BESHSRCEND 0x3d3c -#define MGAREG_BESHSRCLST 0x3d50 -#define MGAREG_BESHSRCST 0x3d38 -#define MGAREG_BESLUMACTL 0x3d40 -#define MGAREG_BESPITCH 0x3d24 -#define MGAREG_BESV1SRCLST 0x3d54 -#define MGAREG_BESV1WGHT 0x3d48 -#define MGAREG_BESVCOORD 0x3d2c -#define MGAREG_BESVISCAL 0x3d34 - -/* texture engine registers */ - -#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_TEXORG 0x2c24 -#define MGAREG_TEXWIDTH 0x2c28 -#define MGAREG_TEXHEIGHT 0x2c2c -#define MGAREG_TEXCTL 0x2c30 -#define MGAREG_TEXCTL2 0x2c3c -#define MGAREG_TEXTRANS 0x2c34 -#define MGAREG_TEXTRANSHIGH 0x2c38 -#define MGAREG_TEXFILTER 0x2c58 -#define MGAREG_ALPHASTART 0x2c70 -#define MGAREG_ALPHAXINC 0x2c74 -#define MGAREG_ALPHAYINC 0x2c78 -#define MGAREG_ALPHACTRL 0x2c7c -#define MGAREG_DWGSYNC 0x2c4c - -#define MGAREG_AGP_PLL 0x1e4c -#define MGA_AGP2XPLL_ENABLE 0x1 -#define MGA_AGP2XPLL_DISABLE 0x0 - -#endif diff --git a/src/mesa/drivers/dri/r128/Makefile b/src/mesa/drivers/dri/r128/Makefile deleted file mode 100644 index 8b23ccc8cbe..00000000000 --- a/src/mesa/drivers/dri/r128/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# src/mesa/drivers/dri/r128/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = r128_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - r128_context.c \ - r128_lock.c \ - r128_state.c \ - r128_texstate.c \ - r128_dd.c \ - r128_screen.c \ - r128_tex.c \ - r128_tris.c \ - r128_ioctl.c \ - r128_span.c \ - r128_texmem.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c deleted file mode 100644 index 247d86ca008..00000000000 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ /dev/null @@ -1,369 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Gareth Hughes <[email protected]> - * - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/simple_list.h" -#include "main/imports.h" -#include "main/extensions.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_dd.h" -#include "r128_state.h" -#include "r128_span.h" -#include "r128_tex.h" -#include "r128_tris.h" - -#include "vblank.h" -#include "utils.h" -#include "texmem.h" -#include "xmlpool.h" /* for symbolic values of enum-type options */ - -#ifndef R128_DEBUG -int R128_DEBUG = 0; -#endif - -#define need_GL_EXT_blend_minmax -#define need_GL_EXT_fog_coord -#define need_GL_EXT_secondary_color -#include "main/remap_helper.h" - -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_texture_edge_clamp", NULL }, - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_MESA_ycbcr_texture", NULL }, - { "GL_NV_blend_square", NULL }, - { NULL, NULL } -}; - -static const struct dri_debug_control debug_control[] = -{ - { "ioctl", DEBUG_VERBOSE_IOCTL }, - { "verb", DEBUG_VERBOSE_MSG }, - { "dri", DEBUG_VERBOSE_DRI }, - { "2d", DEBUG_VERBOSE_2D }, - { "sync", DEBUG_ALWAYS_SYNC }, - { "api", DEBUG_VERBOSE_API }, - { "fall", DEBUG_VERBOSE_FALL }, - { NULL, 0 } -}; - -/* Create the device specific context. - */ -GLboolean r128CreateContext( gl_api api, - const struct gl_config *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - struct gl_context *ctx, *shareCtx; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - struct dd_function_table functions; - r128ContextPtr rmesa; - r128ScreenPtr r128scrn; - int i; - - /* Allocate the r128 context */ - rmesa = (r128ContextPtr) CALLOC( sizeof(*rmesa) ); - if ( !rmesa ) - return GL_FALSE; - - /* Init default driver functions then plug in our Radeon-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions( &functions ); - r128InitDriverFuncs( &functions ); - r128InitIoctlFuncs( &functions ); - r128InitTextureFuncs( &functions ); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((r128ContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - rmesa->glCtx = _mesa_create_context(API_OPENGL, glVisual, shareCtx, - &functions, (void *) rmesa); - if (!rmesa->glCtx) { - FREE(rmesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = rmesa; - ctx = rmesa->glCtx; - - rmesa->driContext = driContextPriv; - rmesa->driScreen = sPriv; - rmesa->driDrawable = NULL; - rmesa->hHWContext = driContextPriv->hHWContext; - rmesa->driHwLock = &sPriv->pSAREA->lock; - rmesa->driFd = sPriv->fd; - - r128scrn = rmesa->r128Screen = (r128ScreenPtr)(sPriv->private); - - /* Parse configuration files */ - driParseConfigFiles (&rmesa->optionCache, &r128scrn->optionCache, - r128scrn->driScreen->myNum, "r128"); - - rmesa->sarea = (drm_r128_sarea_t *)((char *)sPriv->pSAREA + - r128scrn->sarea_priv_offset); - - rmesa->CurrentTexObj[0] = NULL; - rmesa->CurrentTexObj[1] = NULL; - - (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) ); - make_empty_list( & rmesa->swapped ); - - rmesa->nr_heaps = r128scrn->numTexHeaps; - for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { - rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa, - r128scrn->texSize[i], - 12, - R128_NR_TEX_REGIONS, - (drmTextureRegionPtr)rmesa->sarea->tex_list[i], - &rmesa->sarea->tex_age[i], - &rmesa->swapped, - sizeof( r128TexObj ), - (destroy_texture_object_t *) r128DestroyTexObj ); - - driSetTextureSwapCounterLocation( rmesa->texture_heaps[i], - & rmesa->c_textureSwaps ); - } - rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache, - "texture_depth"); - if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB) - rmesa->texture_depth = ( r128scrn->cpp == 4 ) ? - DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16; - - - rmesa->RenderIndex = -1; /* Impossible value */ - rmesa->vert_buf = NULL; - rmesa->num_verts = 0; - RENDERINPUTS_ONES( rmesa->tnl_state_bitset ); - - /* Set the maximum texture size small enough that we can guarentee that - * all texture units can bind a maximal texture and have them both in - * texturable memory at once. - */ - - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureImageUnits = 2; - ctx->Const.MaxTextureCoordUnits = 2; - - driCalculateMaxTextureLevels( rmesa->texture_heaps, - rmesa->nr_heaps, - & ctx->Const, - 4, - 10, /* max 2D texture size is 1024x1024 */ - 0, /* 3D textures unsupported. */ - 0, /* cube textures unsupported. */ - 0, /* texture rectangles unsupported. */ - 11, - GL_FALSE, - 0 ); - - /* 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; - - ctx->Const.MaxDrawBuffers = 1; - -#if ENABLE_PERF_BOXES - rmesa->boxes = driQueryOptionb(&rmesa->optionCache, "performance_boxes"); -#endif - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ -/* _tnl_destroy_pipeline( ctx ); */ -/* _tnl_install_pipeline( ctx, r128_pipeline ); */ - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - _tnl_allow_pixel_fog( ctx, GL_FALSE ); - _tnl_allow_vertex_fog( ctx, GL_TRUE ); - - driInitExtensions( ctx, card_extensions, GL_TRUE ); - if (sPriv->drm_version.minor >= 4) - _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" ); - - r128InitTriFuncs( ctx ); - r128DDInitStateFuncs( ctx ); - r128DDInitSpanFuncs( ctx ); - r128DDInitState( rmesa ); - - driContextPriv->driverPrivate = (void *)rmesa; - -#if DO_DEBUG - R128_DEBUG = driParseDebugString( getenv( "R128_DEBUG" ), - debug_control ); -#endif - - if (driQueryOptionb(&rmesa->optionCache, "no_rast")) { - fprintf(stderr, "disabling 3D acceleration\n"); - FALLBACK(rmesa, R128_FALLBACK_DISABLE, 1); - } - - return GL_TRUE; -} - -/* Destroy the device specific context. - */ -void r128DestroyContext( __DRIcontext *driContextPriv ) -{ - r128ContextPtr rmesa = (r128ContextPtr) driContextPriv->driverPrivate; - - assert(rmesa); /* should never be null */ - if ( rmesa ) { - GLboolean release_texture_heaps; - - - release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1); - - _swsetup_DestroyContext( rmesa->glCtx ); - _tnl_DestroyContext( rmesa->glCtx ); - _vbo_DestroyContext( rmesa->glCtx ); - _swrast_DestroyContext( rmesa->glCtx ); - - if ( release_texture_heaps ) { - /* This share group is about to go away, free our private - * texture object data. - */ - int i; - - for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { - driDestroyTextureHeap( rmesa->texture_heaps[ i ] ); - rmesa->texture_heaps[ i ] = NULL; - } - - assert( is_empty_list( & rmesa->swapped ) ); - } - - /* free the Mesa context */ - rmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(rmesa->glCtx); - - /* free the option cache */ - driDestroyOptionCache (&rmesa->optionCache); - - FREE( rmesa ); - } - -#if 0 - /* Use this to force shared object profiling. */ - glx_fini_prof(); -#endif -} - - -/* Force the context `c' to be the current context and associate with it - * buffer `b'. - */ -GLboolean -r128MakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ) -{ - 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 (driDrawPriv->swap_interval == (unsigned)-1) { - driDrawPriv->vblFlags = (newR128Ctx->r128Screen->irq != 0) - ? driGetDefaultVBlankFlags(&newR128Ctx->optionCache) - : VBLANK_FLAG_NO_IRQ; - - driDrawableInitVBlank( driDrawPriv ); - } - newR128Ctx->driDrawable = driDrawPriv; - - _mesa_make_current( newR128Ctx->glCtx, - (struct gl_framebuffer *) driDrawPriv->driverPrivate, - (struct gl_framebuffer *) driReadPriv->driverPrivate ); - - newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP; - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - return GL_TRUE; -} - - -/* Force the context `c' to be unbound from its buffer. - */ -GLboolean -r128UnbindContext( __DRIcontext *driContextPriv ) -{ - return GL_TRUE; -} diff --git a/src/mesa/drivers/dri/r128/r128_context.h b/src/mesa/drivers/dri/r128/r128_context.h deleted file mode 100644 index 0a06c43878d..00000000000 --- a/src/mesa/drivers/dri/r128/r128_context.h +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __R128_CONTEXT_H__ -#define __R128_CONTEXT_H__ - -#include "dri_util.h" -#include "drm.h" -#include "r128_drm.h" - -#include "main/mtypes.h" -#include "tnl/t_vertex.h" - -#include "r128_reg.h" - -#include "texmem.h" - -struct r128_context; -typedef struct r128_context r128ContextRec; -typedef struct r128_context *r128ContextPtr; - -#include "r128_lock.h" -#include "r128_texobj.h" -#include "r128_screen.h" - -/* Flags for what context state needs to be updated: - */ -#define R128_NEW_ALPHA 0x0001 -#define R128_NEW_DEPTH 0x0002 -#define R128_NEW_FOG 0x0004 -#define R128_NEW_CLIP 0x0008 -#define R128_NEW_CULL 0x0010 -#define R128_NEW_MASKS 0x0020 -#define R128_NEW_RENDER_NOT 0x0040 -#define R128_NEW_WINDOW 0x0080 -#define R128_NEW_CONTEXT 0x0100 -#define R128_NEW_ALL 0x01ff - -/* Flags for software fallback cases: - */ -#define R128_FALLBACK_TEXTURE 0x0001 -#define R128_FALLBACK_DRAW_BUFFER 0x0002 -#define R128_FALLBACK_READ_BUFFER 0x0004 -#define R128_FALLBACK_STENCIL 0x0008 -#define R128_FALLBACK_RENDER_MODE 0x0010 -#define R128_FALLBACK_LOGICOP 0x0020 -#define R128_FALLBACK_SEP_SPECULAR 0x0040 -#define R128_FALLBACK_BLEND_EQ 0x0080 -#define R128_FALLBACK_BLEND_FUNC 0x0100 -#define R128_FALLBACK_PROJTEX 0x0200 -#define R128_FALLBACK_DISABLE 0x0400 - - -/* 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: - */ -#define R128_BLEND_ENV_COLOR 0x1 -#define R128_BLEND_MULTITEX 0x2 - -/* Subpixel offsets for window coordinates (triangles): - */ -#define SUBPIXEL_X (0.0F) -#define SUBPIXEL_Y (0.125F) - - -typedef void (*r128_tri_func)( r128ContextPtr, - r128Vertex *, - r128Vertex *, - r128Vertex * ); - -typedef void (*r128_line_func)( r128ContextPtr, - r128Vertex *, - r128Vertex * ); - -typedef void (*r128_point_func)( r128ContextPtr, - r128Vertex * ); - - -struct r128_context { - struct gl_context *glCtx; /* Mesa context */ - - /* Driver and hardware state management - */ - GLuint new_state; - GLuint dirty; /* Hardware state to be updated */ - drm_r128_context_regs_t setup; - - /* Vertex state */ - GLuint vertex_size; - GLuint vertex_format; - struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; - GLuint vertex_attr_count; - char *verts; /* points to tnl->clipspace.vertex_buf */ - GLuint num_verts; - int coloroffset, specoffset; - DECLARE_RENDERINPUTS(tnl_state_bitset); /* tnl->render_inputs for this _tnl_install_attrs */ - - GLuint NewGLState; - GLuint Fallback; - GLuint RenderIndex; - GLfloat hw_viewport[16]; - GLfloat depth_scale; - - uint32_t ClearColor; /* Color used to clear color buffer */ - uint32_t ClearDepth; /* Value used to clear depth buffer */ - uint32_t ClearStencil; /* Value used to clear stencil */ - - /* Map GL texture units onto hardware - */ - GLint multitex; - GLint tmu_source[2]; - GLuint tex_combine[2]; - GLuint blend_flags; - GLuint env_color; - - /* Texture object bookkeeping - */ - unsigned nr_heaps; - driTexHeap * texture_heaps[ R128_NR_TEX_HEAPS ]; - driTextureObject swapped; - - r128TexObjPtr CurrentTexObj[2]; - - int texture_depth; - - /* Fallback rasterization functions - */ - r128_point_func draw_point; - r128_line_func draw_line; - r128_tri_func draw_tri; - - /* Vertex buffers - */ - drmBufPtr vert_buf; - - GLuint hw_primitive; - GLenum render_primitive; - - /* Page flipping - */ - GLuint doPageFlip; - - /* Cliprect and scissor information - */ - GLuint numClipRects; /* Cliprects for the draw buffer */ - drm_clip_rect_t *pClipRects; - - GLuint scissor; - drm_clip_rect_t ScissorRect; /* Current software scissor */ - - /* Mirrors of some DRI state - */ - __DRIcontext *driContext; /* DRI context */ - __DRIscreen *driScreen; /* DRI screen */ - __DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */ - - unsigned int lastStamp; /* mirror driDrawable->lastStamp */ - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - - r128ScreenPtr r128Screen; /* Screen private DRI data */ - drm_r128_sarea_t *sarea; /* Private SAREA data */ - - /* Performance counters - */ - GLuint boxes; /* Draw performance boxes */ - GLuint hardwareWentIdle; - GLuint c_clears; - GLuint c_drawWaits; - GLuint c_textureSwaps; - GLuint c_textureBytes; - GLuint c_vertexBuffers; - - /* Configuration cache - */ - driOptionCache optionCache; -}; - -#define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx)) - -#define R128_IS_PLAIN( rmesa ) \ - (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128) -#define R128_IS_PRO( rmesa ) \ - (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_PRO) -#define R128_IS_MOBILITY( rmesa ) \ - (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY) - - -extern GLboolean r128CreateContext( gl_api api, - const struct gl_config *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ); - -extern void r128DestroyContext( __DRIcontext * ); - -extern GLboolean r128MakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ); - -extern GLboolean r128UnbindContext( __DRIcontext *driContextPriv ); - -/* ================================================================ - * Debugging: - */ -#define DO_DEBUG 1 -#define ENABLE_PERF_BOXES 0 - -#if DO_DEBUG -extern int R128_DEBUG; -#else -#define R128_DEBUG 0 -#endif - -#define DEBUG_ALWAYS_SYNC 0x01 -#define DEBUG_VERBOSE_API 0x02 -#define DEBUG_VERBOSE_MSG 0x04 -#define DEBUG_VERBOSE_LRU 0x08 -#define DEBUG_VERBOSE_DRI 0x10 -#define DEBUG_VERBOSE_IOCTL 0x20 -#define DEBUG_VERBOSE_2D 0x40 -#define DEBUG_VERBOSE_FALL 0x80 - -#endif /* __R128_CONTEXT_H__ */ diff --git a/src/mesa/drivers/dri/r128/r128_dd.c b/src/mesa/drivers/dri/r128/r128_dd.c deleted file mode 100644 index cfe2387948d..00000000000 --- a/src/mesa/drivers/dri/r128/r128_dd.c +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_dd.h" - -#include "main/context.h" - -#include "utils.h" - -/* Return the width and height of the current color buffer. - */ -static void r128GetBufferSize( struct gl_framebuffer *buffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - LOCK_HARDWARE( rmesa ); - *width = rmesa->driDrawable->w; - *height = rmesa->driDrawable->h; - UNLOCK_HARDWARE( rmesa ); -} - -/* Return various strings for glGetString(). - */ -static const GLubyte *r128GetString( struct gl_context *ctx, GLenum name ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - static char buffer[128]; - unsigned offset; - const char * card_name = "Rage 128"; - GLuint agp_mode = rmesa->r128Screen->IsPCI ? 0 : - rmesa->r128Screen->AGPMode; - - switch ( name ) { - case GL_VENDOR: - return (GLubyte *)"VA Linux Systems, Inc."; - - case GL_RENDERER: - /* Select the spefic chipset. - */ - if ( R128_IS_PRO( rmesa ) ) { - card_name = "Rage 128 Pro"; - } - else if ( R128_IS_MOBILITY( rmesa ) ) { - card_name = "Rage 128 Mobility"; - } - - offset = driGetRendererString( buffer, card_name, agp_mode ); - - 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 r128Flush( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - -#if ENABLE_PERF_BOXES - if ( rmesa->boxes ) { - LOCK_HARDWARE( rmesa ); - r128PerformanceBoxesLocked( rmesa ); - UNLOCK_HARDWARE( rmesa ); - } - - /* Log the performance counters if necessary */ - r128PerformanceCounters( rmesa ); -#endif -} - -/* Make sure all commands have been sent to the hardware and have - * completed processing. - */ -static void r128Finish( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - rmesa->c_drawWaits++; -#endif - - r128Flush( ctx ); - r128WaitForIdle( rmesa ); -} - - -/* Initialize the driver's misc functions. - */ -void r128InitDriverFuncs( struct dd_function_table *functions ) -{ - functions->GetBufferSize = r128GetBufferSize; - functions->GetString = r128GetString; - functions->Finish = r128Finish; - functions->Flush = r128Flush; -} diff --git a/src/mesa/drivers/dri/r128/r128_dd.h b/src/mesa/drivers/dri/r128/r128_dd.h deleted file mode 100644 index ce038853c48..00000000000 --- a/src/mesa/drivers/dri/r128/r128_dd.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#ifndef __R128_DD_H__ -#define __R128_DD_H__ - -extern void r128InitDriverFuncs( struct dd_function_table *functions ); - -#endif diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.c b/src/mesa/drivers/dri/r128/r128_ioctl.c deleted file mode 100644 index 950e1d4fbd5..00000000000 --- a/src/mesa/drivers/dri/r128/r128_ioctl.c +++ /dev/null @@ -1,820 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * - */ -#include <errno.h> - -#define STANDALONE_MMIO -#include "r128_context.h" -#include "r128_state.h" -#include "r128_ioctl.h" -#include "main/imports.h" -#include "main/macros.h" - -#include "swrast/swrast.h" - -#include "vblank.h" -#include "mmio.h" -#include "drirenderbuffer.h" - -#define R128_TIMEOUT 2048 -#define R128_IDLE_RETRY 32 - - -/* ============================================================= - * Hardware vertex buffer handling - */ - -/* Get a new VB from the pool of vertex buffers in AGP space. - */ -drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa ) -{ - int fd = rmesa->r128Screen->driScreen->fd; - int index = 0; - int size = 0; - drmDMAReq dma; - drmBufPtr buf = NULL; - int to = 0; - int ret; - - dma.context = rmesa->hHWContext; - dma.send_count = 0; - dma.send_list = NULL; - dma.send_sizes = NULL; - dma.flags = 0; - dma.request_count = 1; - dma.request_size = R128_BUFFER_SIZE; - dma.request_list = &index; - dma.request_sizes = &size; - dma.granted_count = 0; - - while ( !buf && ( to++ < R128_TIMEOUT ) ) { - ret = drmDMA( fd, &dma ); - - if ( ret == 0 ) { - buf = &rmesa->r128Screen->buffers->list[index]; - buf->used = 0; -#if ENABLE_PERF_BOXES - /* Bump the performance counter */ - rmesa->c_vertexBuffers++; -#endif - return buf; - } - } - - if ( !buf ) { - drmCommandNone( fd, DRM_R128_CCE_RESET); - UNLOCK_HARDWARE( rmesa ); - fprintf( stderr, "Error: Could not get new VB... exiting\n" ); - exit( -1 ); - } - - return buf; -} - -void r128FlushVerticesLocked( r128ContextPtr rmesa ) -{ - drm_clip_rect_t *pbox = rmesa->pClipRects; - int nbox = rmesa->numClipRects; - drmBufPtr buffer = rmesa->vert_buf; - int count = rmesa->num_verts; - int prim = rmesa->hw_primitive; - int fd = rmesa->driScreen->fd; - drm_r128_vertex_t vertex; - int i; - - rmesa->num_verts = 0; - rmesa->vert_buf = NULL; - - if ( !buffer ) - return; - - if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) - r128EmitHwStateLocked( rmesa ); - - if ( !nbox ) - count = 0; - - if ( nbox >= R128_NR_SAREA_CLIPRECTS ) - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - - if ( !count || !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) ) - { - if ( nbox < 3 ) { - rmesa->sarea->nbox = 0; - } else { - rmesa->sarea->nbox = nbox; - } - - vertex.prim = prim; - vertex.idx = buffer->idx; - vertex.count = count; - vertex.discard = 1; - drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(vertex) ); - } - else - { - for ( i = 0 ; i < nbox ; ) { - int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox ); - drm_clip_rect_t *b = rmesa->sarea->boxes; - int discard = 0; - - rmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++ ) { - *b++ = pbox[i]; - } - - /* Finished with the buffer? - */ - if ( nr == nbox ) { - discard = 1; - } - - rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS; - - vertex.prim = prim; - vertex.idx = buffer->idx; - vertex.count = count; - vertex.discard = discard; - drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(vertex) ); - } - } - - rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS; -} - - - - - -/* ================================================================ - * Texture uploads - */ - -void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer, - GLint offset, GLint pitch, GLint format, - GLint x, GLint y, GLint width, GLint height ) -{ - drm_r128_blit_t blit; - GLint ret; - - blit.idx = buffer->idx; - blit.offset = offset; - blit.pitch = pitch; - blit.format = format; - blit.x = x; - blit.y = y; - blit.width = width; - blit.height = height; - - ret = drmCommandWrite( rmesa->driFd, DRM_R128_BLIT, - &blit, sizeof(blit) ); - - if ( ret ) { - UNLOCK_HARDWARE( rmesa ); - fprintf( stderr, "DRM_R128_BLIT: return = %d\n", ret ); - exit( 1 ); - } -} - - -/* ================================================================ - * SwapBuffers with client-side throttling - */ - -static void delay( void ) { -/* Prevent an optimizing compiler from removing a spin loop */ -} - -#define R128_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. - */ -static int r128WaitForFrameCompletion( r128ContextPtr rmesa ) -{ - unsigned char *R128MMIO = rmesa->r128Screen->mmio.map; - int i; - int wait = 0; - - while ( 1 ) { - uint32_t frame = read_MMIO_LE32( R128MMIO, R128_LAST_FRAME_REG ); - - if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) { - break; - } - - /* Spin in place a bit so we aren't hammering the register */ - wait++; - for ( i = 0 ; i < 1024 ; i++ ) { - delay(); - } - } - - return wait; -} - -/* Copy the back color buffer to the front color buffer. - */ -void r128CopyBuffer( __DRIdrawable *dPriv ) -{ - r128ContextPtr rmesa; - GLint nbox, i, ret; - GLboolean missed_target; - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "\n********************************\n" ); - fprintf( stderr, "\n%s( %p )\n\n", - __FUNCTION__, (void *)rmesa->glCtx ); - fflush( stderr ); - } - - FLUSH_BATCH( rmesa ); - - LOCK_HARDWARE( rmesa ); - - /* Throttle the frame rate -- only allow one pending swap buffers - * request at a time. - */ - if ( !r128WaitForFrameCompletion( rmesa ) ) { - rmesa->hardwareWentIdle = 1; - } else { - rmesa->hardwareWentIdle = 0; - } - - UNLOCK_HARDWARE( rmesa ); - driWaitForVBlank( dPriv, &missed_target ); - LOCK_HARDWARE( rmesa ); - - nbox = dPriv->numClipRects; /* must be in locked region */ - - for ( i = 0 ; i < nbox ; ) { - GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , nbox ); - drm_clip_rect_t *box = dPriv->pClipRects; - drm_clip_rect_t *b = rmesa->sarea->boxes; - GLint n = 0; - - for ( ; i < nr ; i++ ) { - *b++ = box[i]; - n++; - } - rmesa->sarea->nbox = n; - - ret = drmCommandNone( rmesa->driFd, DRM_R128_SWAP ); - - if ( ret ) { - UNLOCK_HARDWARE( rmesa ); - fprintf( stderr, "DRM_R128_SWAP: return = %d\n", ret ); - exit( 1 ); - } - } - - if ( R128_DEBUG & DEBUG_ALWAYS_SYNC ) { - i = 0; - do { - ret = drmCommandNone(rmesa->driFd, DRM_R128_CCE_IDLE); - } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY ); - } - - UNLOCK_HARDWARE( rmesa ); - - rmesa->new_state |= R128_NEW_CONTEXT; - rmesa->dirty |= (R128_UPLOAD_CONTEXT | - R128_UPLOAD_MASKS | - R128_UPLOAD_CLIPRECTS); - -#if ENABLE_PERF_BOXES - /* Log the performance counters if necessary */ - r128PerformanceCounters( rmesa ); -#endif -} - -void r128PageFlip( __DRIdrawable *dPriv ) -{ - r128ContextPtr rmesa; - GLint ret; - GLboolean missed_target; - - 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__, (void *)rmesa->glCtx, rmesa->sarea->pfCurrentPage ); - } - - FLUSH_BATCH( rmesa ); - - LOCK_HARDWARE( rmesa ); - - /* Throttle the frame rate -- only allow one pending swap buffers - * request at a time. - */ - if ( !r128WaitForFrameCompletion( rmesa ) ) { - rmesa->hardwareWentIdle = 1; - } else { - rmesa->hardwareWentIdle = 0; - } - - UNLOCK_HARDWARE( rmesa ); - driWaitForVBlank( dPriv, &missed_target ); - LOCK_HARDWARE( rmesa ); - - /* The kernel will have been initialized to perform page flipping - * on a swapbuffers ioctl. - */ - ret = drmCommandNone( rmesa->driFd, DRM_R128_FLIP ); - - UNLOCK_HARDWARE( rmesa ); - - if ( ret ) { - fprintf( stderr, "DRM_R128_FLIP: return = %d\n", ret ); - exit( 1 ); - } - - /* Get ready for drawing next frame. Update the renderbuffers' - * flippedOffset/Pitch fields so we draw into the right place. - */ - driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer, - rmesa->sarea->pfCurrentPage); - - rmesa->new_state |= R128_NEW_WINDOW; - - /* FIXME: Do we need this anymore? */ - rmesa->new_state |= R128_NEW_CONTEXT; - rmesa->dirty |= (R128_UPLOAD_CONTEXT | - R128_UPLOAD_MASKS | - R128_UPLOAD_CLIPRECTS); - -#if ENABLE_PERF_BOXES - /* Log the performance counters if necessary */ - r128PerformanceCounters( rmesa ); -#endif -} - - -/* ================================================================ - * Buffer clear - */ - -static void r128Clear( struct gl_context *ctx, GLbitfield mask ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - __DRIdrawable *dPriv = rmesa->driDrawable; - drm_r128_clear_t clear; - GLuint flags = 0; - GLint i; - GLint ret; - GLuint depthmask = 0; - GLint cx, cy, cw, ch; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s:\n", __FUNCTION__ ); - } - - FLUSH_BATCH( rmesa ); - - /* 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 & 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 & BUFFER_BIT_FRONT_LEFT ) { - flags |= R128_FRONT; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if ( mask & BUFFER_BIT_BACK_LEFT ) { - flags |= R128_BACK; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) { - flags |= R128_DEPTH; - /* if we're at 16 bits, extra plane mask won't hurt */ - depthmask |= 0x00ffffff; - mask &= ~BUFFER_BIT_DEPTH; - } - - if ( mask & BUFFER_BIT_STENCIL && - (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24) ) { - flags |= R128_DEPTH; - depthmask |= ctx->Stencil.WriteMask[0] << 24; - mask &= ~BUFFER_BIT_STENCIL; - } - - if ( flags ) { - - LOCK_HARDWARE( rmesa ); - - /* compute region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - - /* Flip top to bottom */ - cx += dPriv->x; - cy = dPriv->y + dPriv->h - cy - ch; - - /* FIXME: Do we actually need this? - */ - if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) { - r128EmitHwStateLocked( rmesa ); - } - - for ( i = 0 ; i < rmesa->numClipRects ; ) { - GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , rmesa->numClipRects ); - drm_clip_rect_t *box = rmesa->pClipRects; - drm_clip_rect_t *b = rmesa->sarea->boxes; - GLint n = 0; - - if (cw != dPriv->w || ch != dPriv->h) { - /* clear subregion */ - 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 { - /* clear whole window */ - for ( ; i < nr ; i++ ) { - *b++ = box[i]; - n++; - } - } - - rmesa->sarea->nbox = n; - - if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) { - fprintf( stderr, - "DRM_R128_CLEAR: flag 0x%x color %x depth %x nbox %d\n", - flags, - (GLuint)rmesa->ClearColor, - (GLuint)rmesa->ClearDepth, - rmesa->sarea->nbox ); - } - - clear.flags = flags; - clear.clear_color = rmesa->ClearColor; - clear.clear_depth = rmesa->ClearDepth; - clear.color_mask = rmesa->setup.plane_3d_mask_c; - clear.depth_mask = depthmask; - - ret = drmCommandWrite( rmesa->driFd, DRM_R128_CLEAR, - &clear, sizeof(clear) ); - - if ( ret ) { - UNLOCK_HARDWARE( rmesa ); - fprintf( stderr, "DRM_R128_CLEAR: return = %d\n", ret ); - exit( 1 ); - } - } - - UNLOCK_HARDWARE( rmesa ); - - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - } - - if ( mask ) - _swrast_Clear( ctx, mask ); -} - - -/* ================================================================ - * Depth spans, pixels - */ - -void r128WriteDepthSpanLocked( r128ContextPtr rmesa, - GLuint n, GLint x, GLint y, - const GLuint depth[], - const GLubyte mask[] ) -{ - drm_clip_rect_t *pbox = rmesa->pClipRects; - drm_r128_depth_t d; - int nbox = rmesa->numClipRects; - int fd = rmesa->driScreen->fd; - int i; - - if ( !nbox || !n ) { - return; - } - if ( nbox >= R128_NR_SAREA_CLIPRECTS ) { - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - } - - if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) ) - { - if ( nbox < 3 ) { - rmesa->sarea->nbox = 0; - } else { - rmesa->sarea->nbox = nbox; - } - - d.func = R128_WRITE_SPAN; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = (unsigned int *)depth; - d.mask = (unsigned char *)mask; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - - } - else - { - for (i = 0 ; i < nbox ; ) { - int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox ); - drm_clip_rect_t *b = rmesa->sarea->boxes; - - rmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++) { - *b++ = pbox[i]; - } - - rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS; - - d.func = R128_WRITE_SPAN; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = (unsigned int *)depth; - d.mask = (unsigned char *)mask; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - } - - rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS; -} - -void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n, - const GLint x[], const GLint y[], - const GLuint depth[], - const GLubyte mask[] ) -{ - drm_clip_rect_t *pbox = rmesa->pClipRects; - drm_r128_depth_t d; - int nbox = rmesa->numClipRects; - int fd = rmesa->driScreen->fd; - int i; - - if ( !nbox || !n ) { - return; - } - if ( nbox >= R128_NR_SAREA_CLIPRECTS ) { - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - } - - if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) ) - { - if ( nbox < 3 ) { - rmesa->sarea->nbox = 0; - } else { - rmesa->sarea->nbox = nbox; - } - - d.func = R128_WRITE_PIXELS; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = (unsigned int *)depth; - d.mask = (unsigned char *)mask; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - else - { - for (i = 0 ; i < nbox ; ) { - int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox ); - drm_clip_rect_t *b = rmesa->sarea->boxes; - - rmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++) { - *b++ = pbox[i]; - } - - rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS; - - d.func = R128_WRITE_PIXELS; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = (unsigned int *)depth; - d.mask = (unsigned char *)mask; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - } - - rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS; -} - -void r128ReadDepthSpanLocked( r128ContextPtr rmesa, - GLuint n, GLint x, GLint y ) -{ - drm_clip_rect_t *pbox = rmesa->pClipRects; - drm_r128_depth_t d; - int nbox = rmesa->numClipRects; - int fd = rmesa->driScreen->fd; - int i; - - if ( !nbox || !n ) { - return; - } - if ( nbox >= R128_NR_SAREA_CLIPRECTS ) { - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - } - - if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) ) - { - if ( nbox < 3 ) { - rmesa->sarea->nbox = 0; - } else { - rmesa->sarea->nbox = nbox; - } - - d.func = R128_READ_SPAN; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = NULL; - d.mask = NULL; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - else - { - for (i = 0 ; i < nbox ; ) { - int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox ); - drm_clip_rect_t *b = rmesa->sarea->boxes; - - rmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++) { - *b++ = pbox[i]; - } - - rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS; - - d.func = R128_READ_SPAN; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = NULL; - d.mask = NULL; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - } - - rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS; -} - -void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n, - const GLint x[], const GLint y[] ) -{ - drm_clip_rect_t *pbox = rmesa->pClipRects; - drm_r128_depth_t d; - int nbox = rmesa->numClipRects; - int fd = rmesa->driScreen->fd; - int i; - - if ( !nbox || !n ) { - return; - } - if ( nbox >= R128_NR_SAREA_CLIPRECTS ) { - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - } - - if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) ) - { - if ( nbox < 3 ) { - rmesa->sarea->nbox = 0; - } else { - rmesa->sarea->nbox = nbox; - } - - d.func = R128_READ_PIXELS; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = NULL; - d.mask = NULL; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - else - { - for (i = 0 ; i < nbox ; ) { - int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox ); - drm_clip_rect_t *b = rmesa->sarea->boxes; - - rmesa->sarea->nbox = nr - i; - for ( ; i < nr ; i++) { - *b++ = pbox[i]; - } - - rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS; - - d.func = R128_READ_PIXELS; - d.n = n; - d.x = (int*)&x; - d.y = (int*)&y; - d.buffer = NULL; - d.mask = NULL; - - drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d)); - } - } - - rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS; -} - - -void r128WaitForIdleLocked( r128ContextPtr rmesa ) -{ - int fd = rmesa->r128Screen->driScreen->fd; - int to = 0; - int ret, i; - - do { - i = 0; - do { - ret = drmCommandNone( fd, DRM_R128_CCE_IDLE); - } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY ); - } while ( ( ret == -EBUSY ) && ( to++ < R128_TIMEOUT ) ); - - if ( ret < 0 ) { - drmCommandNone( fd, DRM_R128_CCE_RESET); - UNLOCK_HARDWARE( rmesa ); - fprintf( stderr, "Error: Rage 128 timed out... exiting\n" ); - exit( -1 ); - } -} - -void r128InitIoctlFuncs( struct dd_function_table *functions ) -{ - functions->Clear = r128Clear; -} diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.h b/src/mesa/drivers/dri/r128/r128_ioctl.h deleted file mode 100644 index 84ace900eec..00000000000 --- a/src/mesa/drivers/dri/r128/r128_ioctl.h +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * - */ - -#ifndef __R128_IOCTL_H__ -#define __R128_IOCTL_H__ - -#include "r128_dri.h" -#include "r128_reg.h" -#include "r128_lock.h" - -#define R128_BUFFER_MAX_DWORDS (R128_BUFFER_SIZE / sizeof(uint32_t)) - - -extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa ); -extern void r128FlushVerticesLocked( r128ContextPtr rmesa ); - -static INLINE void *r128AllocDmaLow( r128ContextPtr rmesa, int count, - int vert_size ) -{ - uint32_t *head; - int bytes = count * vert_size; - - if ( !rmesa->vert_buf ) { - LOCK_HARDWARE( 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 = (uint32_t *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used); - rmesa->vert_buf->used += bytes; - rmesa->num_verts += count; - - return head; -} - -extern void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer, - GLint offset, GLint pitch, GLint format, - GLint x, GLint y, GLint width, GLint height ); - -extern void r128WriteDepthSpanLocked( r128ContextPtr rmesa, - GLuint n, GLint x, GLint y, - const GLuint depth[], - const GLubyte mask[] ); -extern void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n, - const GLint x[], const GLint y[], - const GLuint depth[], - const GLubyte mask[] ); -extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa, - GLuint n, GLint x, GLint y ); -extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n, - const GLint x[], const GLint y[] ); - -extern void r128CopyBuffer( __DRIdrawable *dPriv ); -extern void r128PageFlip( __DRIdrawable *dPriv ); -void r128WaitForVBlank( r128ContextPtr rmesa ); - -extern void r128WaitForIdleLocked( r128ContextPtr rmesa ); - - -extern void r128InitIoctlFuncs( struct dd_function_table *functions ); - - -/* ================================================================ - * Helper macros: - */ - -#define FLUSH_BATCH( rmesa ) \ -do { \ - if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) \ - fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \ - if ( rmesa->vert_buf ) { \ - r128FlushVertices( rmesa ); \ - } \ -} while (0) - -/* 64-bit align the next element address, and then make room for the - * next indexed prim packet header. - */ -#define ALIGN_NEXT_ELT( rmesa ) \ -do { \ - rmesa->next_elt = (GLushort *) \ - (((GLuint)rmesa->next_elt + 7) & ~0x7); \ - rmesa->next_elt = (GLushort *) \ - ((GLubyte *)rmesa->next_elt + R128_INDEX_PRIM_OFFSET); \ -} while (0) - -#define r128FlushVertices( rmesa ) \ -do { \ - LOCK_HARDWARE( rmesa ); \ - r128FlushVerticesLocked( rmesa ); \ - UNLOCK_HARDWARE( rmesa ); \ -} while (0) - -#define r128FlushElts( rmesa ) \ -do { \ - LOCK_HARDWARE( rmesa ); \ - r128FlushEltsLocked( rmesa ); \ - UNLOCK_HARDWARE( rmesa ); \ -} while (0) - -#define r128WaitForIdle( rmesa ) \ - do { \ - LOCK_HARDWARE( rmesa ); \ - r128WaitForIdleLocked( rmesa ); \ - UNLOCK_HARDWARE( rmesa ); \ - } while (0) - -#endif /* __R128_IOCTL_H__ */ diff --git a/src/mesa/drivers/dri/r128/r128_lock.c b/src/mesa/drivers/dri/r128/r128_lock.c deleted file mode 100644 index c1fa068d1fd..00000000000 --- a/src/mesa/drivers/dri/r128/r128_lock.c +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * - */ - -#include "r128_context.h" -#include "r128_lock.h" - -#include "drirenderbuffer.h" - - -#if DEBUG_LOCKING -char *prevLockFile = NULL; -int prevLockLine = 0; -#endif - - -/* Turn on/off page flipping according to the flags in the sarea: - */ -static void -r128UpdatePageFlipping( r128ContextPtr rmesa ) -{ - rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip; - if (rmesa->glCtx->WinSysDrawBuffer) { - driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer, - rmesa->sarea->pfCurrentPage); - } - rmesa->new_state |= R128_NEW_WINDOW; -} - -/* Update the hardware state. This is called if another main/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 r128GetLock( r128ContextPtr rmesa, GLuint flags ) -{ - __DRIdrawable *dPriv = rmesa->driDrawable; - __DRIscreen *sPriv = rmesa->driScreen; - drm_r128_sarea_t *sarea = rmesa->sarea; - int i; - - drmGetLock( rmesa->driFd, rmesa->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( sPriv, dPriv ); - - if ( rmesa->lastStamp != dPriv->lastStamp ) { - r128UpdatePageFlipping( rmesa ); - driUpdateFramebufferSize(rmesa->glCtx, dPriv); - rmesa->lastStamp = dPriv->lastStamp; - rmesa->new_state |= R128_NEW_CLIP; - RENDERINPUTS_ONES( rmesa->tnl_state_bitset ); - } - - rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_CLIPRECTS; - - rmesa->numClipRects = dPriv->numClipRects; - rmesa->pClipRects = dPriv->pClipRects; - - if ( sarea->ctx_owner != rmesa->hHWContext ) { - sarea->ctx_owner = rmesa->hHWContext; - rmesa->dirty = R128_UPLOAD_ALL; - } - - for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { - DRI_AGE_TEXTURES( rmesa->texture_heaps[i] ); - } -} diff --git a/src/mesa/drivers/dri/r128/r128_lock.h b/src/mesa/drivers/dri/r128/r128_lock.h deleted file mode 100644 index 1fc8cbe29f0..00000000000 --- a/src/mesa/drivers/dri/r128/r128_lock.h +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __R128_LOCK_H__ -#define __R128_LOCK_H__ - -extern void r128GetLock( r128ContextPtr rmesa, 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( rmesa ) \ - do { \ - char __ret = 0; \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( rmesa->driHwLock, rmesa->hHWContext, \ - (DRM_LOCK_HELD | rmesa->hHWContext), __ret ); \ - if ( __ret ) \ - r128GetLock( rmesa, 0 ); \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware. - */ -#define UNLOCK_HARDWARE( rmesa ) \ - do { \ - DRM_UNLOCK( rmesa->driFd, \ - rmesa->driHwLock, \ - rmesa->hHWContext ); \ - DEBUG_RESET(); \ - } while (0) - -#endif /* __R128_LOCK_H__ */ diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c deleted file mode 100644 index bbcb6ee1808..00000000000 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ /dev/null @@ -1,524 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#include "r128_dri.h" - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_span.h" - -#include "main/context.h" -#include "main/imports.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" - -#include "utils.h" -#include "vblank.h" - -#include "GL/internal/dri_interface.h" - -/* R128 configuration - */ -#include "xmlpool.h" - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_QUALITY - DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) -#if ENABLE_PERF_BOXES - DRI_CONF_PERFORMANCE_BOXES(false) -#endif - DRI_CONF_SECTION_END -DRI_CONF_END; -#if ENABLE_PERF_BOXES -static const GLuint __driNConfigOptions = 4; -#else -static const GLuint __driNConfigOptions = 3; -#endif - -#if 1 -/* Including xf86PciInfo.h introduces a bunch of errors... - */ -#define PCI_CHIP_RAGE128LE 0x4C45 -#define PCI_CHIP_RAGE128LF 0x4C46 -#define PCI_CHIP_RAGE128PF 0x5046 -#define PCI_CHIP_RAGE128PR 0x5052 -#define PCI_CHIP_RAGE128RE 0x5245 -#define PCI_CHIP_RAGE128RF 0x5246 -#define PCI_CHIP_RAGE128RK 0x524B -#define PCI_CHIP_RAGE128RL 0x524C -#endif - - -/* Create the device specific screen private data struct. - */ -static r128ScreenPtr -r128CreateScreen( __DRIscreen *sPriv ) -{ - r128ScreenPtr r128Screen; - R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv; - int i; - - if (sPriv->devPrivSize != sizeof(R128DRIRec)) { - fprintf(stderr,"\nERROR! sizeof(R128DRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - r128Screen = (r128ScreenPtr) CALLOC( sizeof(*r128Screen) ); - if ( !r128Screen ) return NULL; - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&r128Screen->optionCache, - __driConfigOptions, __driNConfigOptions); - - /* This is first since which regions we map depends on whether or - * not we are using a PCI card. - */ - r128Screen->IsPCI = r128DRIPriv->IsPCI; - r128Screen->sarea_priv_offset = r128DRIPriv->sarea_priv_offset; - - if (sPriv->drm_version.minor >= 3) { - drm_r128_getparam_t gp; - int ret; - - gp.param = R128_PARAM_IRQ_NR; - gp.value = &r128Screen->irq; - - ret = drmCommandWriteRead( sPriv->fd, DRM_R128_GETPARAM, - &gp, sizeof(gp)); - if (ret) { - fprintf(stderr, "drmR128GetParam (R128_PARAM_IRQ_NR): %d\n", ret); - FREE( r128Screen ); - return NULL; - } - } - - r128Screen->mmio.handle = r128DRIPriv->registerHandle; - r128Screen->mmio.size = r128DRIPriv->registerSize; - if ( drmMap( sPriv->fd, - r128Screen->mmio.handle, - r128Screen->mmio.size, - (drmAddressPtr)&r128Screen->mmio.map ) ) { - FREE( r128Screen ); - return NULL; - } - - r128Screen->buffers = drmMapBufs( sPriv->fd ); - if ( !r128Screen->buffers ) { - drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size ); - FREE( r128Screen ); - return NULL; - } - - if ( !r128Screen->IsPCI ) { - r128Screen->agpTextures.handle = r128DRIPriv->agpTexHandle; - r128Screen->agpTextures.size = r128DRIPriv->agpTexMapSize; - if ( drmMap( sPriv->fd, - r128Screen->agpTextures.handle, - r128Screen->agpTextures.size, - (drmAddressPtr)&r128Screen->agpTextures.map ) ) { - drmUnmapBufs( r128Screen->buffers ); - drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size ); - FREE( r128Screen ); - return NULL; - } - } - - switch ( r128DRIPriv->deviceID ) { - case PCI_CHIP_RAGE128RE: - case PCI_CHIP_RAGE128RF: - case PCI_CHIP_RAGE128RK: - case PCI_CHIP_RAGE128RL: - r128Screen->chipset = R128_CARD_TYPE_R128; - break; - case PCI_CHIP_RAGE128PF: - r128Screen->chipset = R128_CARD_TYPE_R128_PRO; - break; - case PCI_CHIP_RAGE128LE: - case PCI_CHIP_RAGE128LF: - r128Screen->chipset = R128_CARD_TYPE_R128_MOBILITY; - break; - default: - r128Screen->chipset = R128_CARD_TYPE_R128; - break; - } - - r128Screen->cpp = r128DRIPriv->bpp / 8; - r128Screen->AGPMode = r128DRIPriv->AGPMode; - - r128Screen->frontOffset = r128DRIPriv->frontOffset; - r128Screen->frontPitch = r128DRIPriv->frontPitch; - r128Screen->backOffset = r128DRIPriv->backOffset; - r128Screen->backPitch = r128DRIPriv->backPitch; - r128Screen->depthOffset = r128DRIPriv->depthOffset; - r128Screen->depthPitch = r128DRIPriv->depthPitch; - r128Screen->spanOffset = r128DRIPriv->spanOffset; - - if ( r128DRIPriv->textureSize == 0 ) { - r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = - r128DRIPriv->agpTexOffset + R128_AGP_TEX_OFFSET; - r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->agpTexMapSize; - r128Screen->logTexGranularity[R128_LOCAL_TEX_HEAP] = - r128DRIPriv->log2AGPTexGran; - } else { - r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureOffset; - r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureSize; - r128Screen->logTexGranularity[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran; - } - - if ( !r128Screen->agpTextures.map || r128DRIPriv->textureSize == 0 ) { - r128Screen->numTexHeaps = R128_NR_TEX_HEAPS - 1; - r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0; - r128Screen->texSize[R128_AGP_TEX_HEAP] = 0; - r128Screen->logTexGranularity[R128_AGP_TEX_HEAP] = 0; - } else { - r128Screen->numTexHeaps = R128_NR_TEX_HEAPS; - r128Screen->texOffset[R128_AGP_TEX_HEAP] = - r128DRIPriv->agpTexOffset + R128_AGP_TEX_OFFSET; - r128Screen->texSize[R128_AGP_TEX_HEAP] = r128DRIPriv->agpTexMapSize; - r128Screen->logTexGranularity[R128_AGP_TEX_HEAP] = - r128DRIPriv->log2AGPTexGran; - } - - r128Screen->driScreen = sPriv; - - i = 0; - if ( r128Screen->irq != 0 ) { - r128Screen->extensions[i++] = &driSwapControlExtension.base; - r128Screen->extensions[i++] = &driMediaStreamCounterExtension.base; - } - r128Screen->extensions[i++] = NULL; - sPriv->extensions = r128Screen->extensions; - - return r128Screen; -} - -/* Destroy the device specific screen private data struct. - */ -static void -r128DestroyScreen( __DRIscreen *sPriv ) -{ - r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private; - - if ( !r128Screen ) - return; - - if ( !r128Screen->IsPCI ) { - drmUnmap( (drmAddress)r128Screen->agpTextures.map, - r128Screen->agpTextures.size ); - } - drmUnmapBufs( r128Screen->buffers ); - drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size ); - - /* free all option information */ - driDestroyOptionInfo (&r128Screen->optionCache); - - FREE( r128Screen ); - sPriv->private = NULL; -} - - -/* Create and initialize the Mesa and driver specific pixmap buffer - * data. - */ -static GLboolean -r128CreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap ) -{ - r128ScreenPtr screen = (r128ScreenPtr) driScrnPriv->private; - - 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; - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - NULL, - screen->cpp, - screen->frontOffset, screen->frontPitch, - driDrawPriv); - r128SetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - NULL, - screen->cpp, - screen->backOffset, screen->backPitch, - driDrawPriv); - r128SetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - r128SetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_S8_Z24, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - r128SetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0 && !swStencil) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(MESA_FORMAT_S8, - NULL, - screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - r128SetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - swDepth, - swStencil, - swAccum, - swAlpha, - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -r128DestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - - -/* Copy the back color buffer to the front color buffer */ -static void -r128SwapBuffers(__DRIdrawable *dPriv) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - r128ContextPtr rmesa; - struct gl_context *ctx; - rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = rmesa->glCtx; - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( 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, "%s: drawable has no context!", __FUNCTION__); - } -} - - -/* Initialize the driver specific screen private data. - */ -static GLboolean -r128InitDriver( __DRIscreen *sPriv ) -{ - sPriv->private = (void *) r128CreateScreen( sPriv ); - - if ( !sPriv->private ) { - r128DestroyScreen( sPriv ); - return GL_FALSE; - } - - return GL_TRUE; -} - -static const __DRIconfig ** -r128FillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - struct gl_config * m; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - int i; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGR; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, back_buffer_modes, - back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, - __LINE__); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const __DRIconfig **) configs; -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -r128InitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { 4, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 2, 2, 0 }; - R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions2( "Rage128", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) - return NULL; - - if (!r128InitDriver(psp)) - return NULL; - - return r128FillInModes( psp, - dri_priv->bpp, - (dri_priv->bpp == 16) ? 16 : 24, - (dri_priv->bpp == 16) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = r128InitScreen, - .DestroyScreen = r128DestroyScreen, - .CreateContext = r128CreateContext, - .DestroyContext = r128DestroyContext, - .CreateBuffer = r128CreateBuffer, - .DestroyBuffer = r128DestroyBuffer, - .SwapBuffers = r128SwapBuffers, - .MakeCurrent = r128MakeCurrent, - .UnbindContext = r128UnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/r128/r128_screen.h b/src/mesa/drivers/dri/r128/r128_screen.h deleted file mode 100644 index 8d450adff34..00000000000 --- a/src/mesa/drivers/dri/r128/r128_screen.h +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#ifndef __R128_SCREEN_H__ -#define __R128_SCREEN_H__ - -#include "xmlconfig.h" - -typedef struct { - drm_handle_t handle; /* Handle to the DRM region */ - drmSize size; /* Size of the DRM region */ - unsigned char *map; /* Mapping of the DRM region */ -} r128RegionRec, *r128RegionPtr; - -typedef struct { - - GLint chipset; - GLint cpp; - GLint IsPCI; /* Current card is a PCI card */ - GLint AGPMode; - unsigned int irq; /* IRQ number (0 means none) */ - - GLuint frontOffset; - GLuint frontPitch; - GLuint backOffset; - GLuint backPitch; - - GLuint depthOffset; - GLuint depthPitch; - GLuint spanOffset; - - /* Shared texture data */ - GLint numTexHeaps; - GLint texOffset[R128_NR_TEX_HEAPS]; - GLint texSize[R128_NR_TEX_HEAPS]; - GLint logTexGranularity[R128_NR_TEX_HEAPS]; - - r128RegionRec mmio; - r128RegionRec agpTextures; - - drmBufMapPtr buffers; - - __DRIscreen *driScreen; - unsigned int sarea_priv_offset; - - /* Configuration cache with default values for all contexts */ - driOptionCache optionCache; - - const __DRIextension *extensions[4]; - -} r128ScreenRec, *r128ScreenPtr; - - -#endif /* __R128_SCREEN_H__ */ diff --git a/src/mesa/drivers/dri/r128/r128_span.c b/src/mesa/drivers/dri/r128/r128_span.c deleted file mode 100644 index 04bdbe612e5..00000000000 --- a/src/mesa/drivers/dri/r128/r128_span.c +++ /dev/null @@ -1,449 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Keith Whitwell <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_span.h" - -#include "swrast/swrast.h" - -#define DBG 0 - -#define HAVE_HW_DEPTH_SPANS 1 -#define HAVE_HW_DEPTH_PIXELS 1 -#define HAVE_HW_STENCIL_SPANS 1 -#define HAVE_HW_STENCIL_PIXELS 1 - -#define LOCAL_VARS \ - r128ContextPtr rmesa = R128_CONTEXT(ctx); \ - __DRIscreen *sPriv = rmesa->driScreen; \ - __DRIdrawable *dPriv = rmesa->driDrawable; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint height = dPriv->h; \ - GLuint p; \ - (void) p; - -#define LOCAL_DEPTH_VARS \ - r128ContextPtr rmesa = R128_CONTEXT(ctx); \ - r128ScreenPtr r128scrn = rmesa->r128Screen; \ - __DRIscreen *sPriv = rmesa->driScreen; \ - __DRIdrawable *dPriv = rmesa->driDrawable; \ - GLuint height = dPriv->h; \ - (void) r128scrn; (void) sPriv; (void) height - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define Y_FLIP( _y ) (height - _y - 1) - -#define HW_LOCK() - -#define HW_UNLOCK() - - - -/* ================================================================ - * Color buffer - */ - -/* 16 bit, RGB565 color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_RGB -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 - -#define TAG(x) r128##x##_RGB565 -#define TAG2(x,y) r128##x##_RGB565##y -#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset \ - + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp) -#include "spantmp2.h" - - -/* 32 bit, ARGB8888 color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_BGRA -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV - -#define TAG(x) r128##x##_ARGB8888 -#define TAG2(x,y) r128##x##_ARGB8888##y -#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset \ - + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp) -#include "spantmp2.h" - -/* Idling in the depth/stencil span functions: - * For writes, the kernel reads from the given user-space buffer at dispatch - * time, and then writes to the depth buffer asynchronously. - * For reads, the kernel reads from the depth buffer and writes to the span - * temporary asynchronously. - * So, if we're going to read from the span temporary, we need to idle before - * doing so. But we don't need to idle after write, because the CPU won't - * be accessing the destination, only the accelerator (through 3d rendering or - * depth span reads) - * However, due to interactions from pixel cache between 2d (what we do with - * depth) and 3d (all other parts of the system), we idle at the begin and end - * of a set of span operations, which should cover the pix cache issue. - * Except, we still have major issues, as shown by no_rast=true glxgears, or - * stencilwrap. - */ - -/* ================================================================ - * Depth buffer - */ - -/* These functions require locking */ -#undef HW_LOCK -#undef HW_UNLOCK -#define HW_LOCK() LOCK_HARDWARE(R128_CONTEXT(ctx)); -#define HW_UNLOCK() UNLOCK_HARDWARE(R128_CONTEXT(ctx)); - -/* 16-bit depth buffer functions - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH_SPAN() \ -do { \ - r128WriteDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y, \ - (const GLuint *) depth, mask ); \ -} while (0) - -#define WRITE_DEPTH_PIXELS() \ -do { \ - GLint ox[MAX_WIDTH]; \ - GLint oy[MAX_WIDTH]; \ - for ( i = 0 ; i < n ; i++ ) { \ - ox[i] = x[i] + dPriv->x; \ - oy[i] = Y_FLIP( y[i] ) + dPriv->y; \ - } \ - r128WriteDepthPixelsLocked( rmesa, n, ox, oy, (const GLuint *) depth, mask ); \ -} while (0) - -#define READ_DEPTH_SPAN() \ -do { \ - GLushort *buf = (GLushort *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - GLint i; \ - \ - r128ReadDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y ); \ - r128WaitForIdleLocked( rmesa ); \ - \ - for ( i = 0 ; i < n ; i++ ) { \ - depth[i] = buf[i]; \ - } \ -} while (0) - -#define READ_DEPTH_PIXELS() \ -do { \ - GLushort *buf = (GLushort *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - GLint i, remaining = n; \ - \ - while ( remaining > 0 ) { \ - GLint ox[128]; \ - GLint oy[128]; \ - GLint count; \ - \ - if ( remaining <= 128 ) { \ - count = remaining; \ - } else { \ - count = 128; \ - } \ - for ( i = 0 ; i < count ; i++ ) { \ - ox[i] = x[i] + dPriv->x; \ - oy[i] = Y_FLIP( y[i] ) + dPriv->y; \ - } \ - \ - r128ReadDepthPixelsLocked( rmesa, count, ox, oy ); \ - r128WaitForIdleLocked( rmesa ); \ - \ - for ( i = 0 ; i < count ; i++ ) { \ - depth[i] = buf[i]; \ - } \ - depth += count; \ - x += count; \ - y += count; \ - remaining -= count; \ - } \ -} while (0) - -#define TAG(x) r128##x##_z16 -#include "depthtmp.h" - - -/* 24-bit depth, 8-bit stencil buffer functions - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH_SPAN() \ -do { \ - GLuint buf[n]; \ - GLint i; \ - GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - r128ReadDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y ); \ - r128WaitForIdleLocked( rmesa ); \ - for ( i = 0 ; i < n ; i++ ) { \ - buf[i] = (readbuf[i] & 0xff000000) | (depth[i] & 0x00ffffff); \ - } \ - r128WriteDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y, \ - buf, mask ); \ -} while (0) - -#define WRITE_DEPTH_PIXELS() \ -do { \ - GLuint buf[n]; \ - GLint ox[MAX_WIDTH]; \ - GLint oy[MAX_WIDTH]; \ - GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - for ( i = 0 ; i < n ; i++ ) { \ - ox[i] = x[i] + dPriv->x; \ - oy[i] = Y_FLIP( y[i] ) + dPriv->y; \ - } \ - r128ReadDepthPixelsLocked( rmesa, n, ox, oy ); \ - r128WaitForIdleLocked( rmesa ); \ - for ( i = 0 ; i < n ; i++ ) { \ - buf[i] = (readbuf[i] & 0xff000000) | (depth[i] & 0x00ffffff); \ - } \ - r128WriteDepthPixelsLocked( rmesa, n, ox, oy, buf, mask ); \ -} while (0) - -#define READ_DEPTH_SPAN() \ -do { \ - GLuint *buf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - GLint i; \ - \ - /*if (n >= 128) fprintf(stderr, "Large number of pixels: %d\n", n);*/ \ - r128ReadDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y ); \ - r128WaitForIdleLocked( rmesa ); \ - \ - for ( i = 0 ; i < n ; i++ ) { \ - depth[i] = buf[i] & 0x00ffffff; \ - } \ -} while (0) - -#define READ_DEPTH_PIXELS() \ -do { \ - GLuint *buf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - GLint i, remaining = n; \ - \ - while ( remaining > 0 ) { \ - GLint ox[128]; \ - GLint oy[128]; \ - GLint count; \ - \ - if ( remaining <= 128 ) { \ - count = remaining; \ - } else { \ - count = 128; \ - } \ - for ( i = 0 ; i < count ; i++ ) { \ - ox[i] = x[i] + dPriv->x; \ - oy[i] = Y_FLIP( y[i] ) + dPriv->y; \ - } \ - \ - r128ReadDepthPixelsLocked( rmesa, count, ox, oy ); \ - r128WaitForIdleLocked( rmesa ); \ - \ - for ( i = 0 ; i < count ; i++ ) { \ - depth[i] = buf[i] & 0x00ffffff; \ - } \ - depth += count; \ - x += count; \ - y += count; \ - remaining -= count; \ - } \ -} while (0) - -#define TAG(x) r128##x##_z24_s8 -#include "depthtmp.h" - - - -/* ================================================================ - * Stencil buffer - */ - -/* 24 bit depth, 8 bit stencil depthbuffer functions - */ -#define WRITE_STENCIL_SPAN() \ -do { \ - GLuint buf[n]; \ - GLint i; \ - GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - r128ReadDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y ); \ - r128WaitForIdleLocked( rmesa ); \ - for ( i = 0 ; i < n ; i++ ) { \ - buf[i] = (readbuf[i] & 0x00ffffff) | (stencil[i] << 24); \ - } \ - r128WriteDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y, \ - buf, mask ); \ -} while (0) - -#define WRITE_STENCIL_PIXELS() \ -do { \ - GLuint buf[n]; \ - GLint ox[MAX_WIDTH]; \ - GLint oy[MAX_WIDTH]; \ - GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - for ( i = 0 ; i < n ; i++ ) { \ - ox[i] = x[i] + dPriv->x; \ - oy[i] = Y_FLIP( y[i] ) + dPriv->y; \ - } \ - r128ReadDepthPixelsLocked( rmesa, n, ox, oy ); \ - r128WaitForIdleLocked( rmesa ); \ - for ( i = 0 ; i < n ; i++ ) { \ - buf[i] = (readbuf[i] & 0x00ffffff) | (stencil[i] << 24); \ - } \ - r128WriteDepthPixelsLocked( rmesa, n, ox, oy, buf, mask ); \ -} while (0) - -#define READ_STENCIL_SPAN() \ -do { \ - GLuint *buf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - GLint i; \ - \ - /*if (n >= 128) fprintf(stderr, "Large number of pixels: %d\n", n);*/ \ - r128ReadDepthSpanLocked( rmesa, n, \ - x + dPriv->x, \ - y + dPriv->y ); \ - r128WaitForIdleLocked( rmesa ); \ - \ - for ( i = 0 ; i < n ; i++ ) { \ - stencil[i] = (buf[i] & 0xff000000) >> 24; \ - } \ -} while (0) - -#define READ_STENCIL_PIXELS() \ -do { \ - GLuint *buf = (GLuint *)((GLubyte *)sPriv->pFB + \ - r128scrn->spanOffset); \ - GLint i, remaining = n; \ - \ - while ( remaining > 0 ) { \ - GLint ox[128]; \ - GLint oy[128]; \ - GLint count; \ - \ - if ( remaining <= 128 ) { \ - count = remaining; \ - } else { \ - count = 128; \ - } \ - for ( i = 0 ; i < count ; i++ ) { \ - ox[i] = x[i] + dPriv->x; \ - oy[i] = Y_FLIP( y[i] ) + dPriv->y; \ - } \ - \ - r128ReadDepthPixelsLocked( rmesa, count, ox, oy ); \ - r128WaitForIdleLocked( rmesa ); \ - \ - for ( i = 0 ; i < count ; i++ ) { \ - stencil[i] = (buf[i] & 0xff000000) >> 24; \ - } \ - stencil += count; \ - x += count; \ - y += count; \ - remaining -= count; \ - } \ -} while (0) - -#define TAG(x) radeon##x##_z24_s8 -#include "stenciltmp.h" - -static void -r128SpanRenderStart( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - FLUSH_BATCH(rmesa); - LOCK_HARDWARE(rmesa); - r128WaitForIdleLocked( rmesa ); -} - -static void -r128SpanRenderFinish( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - _swrast_flush( ctx ); - r128WaitForIdleLocked( rmesa ); - UNLOCK_HARDWARE( rmesa ); -} - -void r128DDInitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = r128SpanRenderStart; - swdd->SpanRenderFinish = r128SpanRenderFinish; -} - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -r128SetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis) -{ - if (drb->Base.Format == MESA_FORMAT_RGB565) { - r128InitPointers_RGB565(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_ARGB8888) { - r128InitPointers_ARGB8888(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_Z16) { - r128InitDepthPointers_z16(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_S8_Z24) { - r128InitDepthPointers_z24_s8(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_S8) { - radeonInitStencilPointers_z24_s8(&drb->Base); - } -} diff --git a/src/mesa/drivers/dri/r128/r128_span.h b/src/mesa/drivers/dri/r128/r128_span.h deleted file mode 100644 index adb571d4d0f..00000000000 --- a/src/mesa/drivers/dri/r128/r128_span.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#ifndef __R128_SPAN_H__ -#define __R128_SPAN_H__ - -#include "drirenderbuffer.h" - -extern void r128DDInitSpanFuncs( struct gl_context *ctx ); - -extern void -r128SetSpanFunctions(driRenderbuffer *rb, const struct gl_config *vis); - -#endif diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c deleted file mode 100644 index 7ce082ead22..00000000000 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ /dev/null @@ -1,1443 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * Keith Whitwell <[email protected]> - * - */ - -#include "r128_context.h" -#include "r128_state.h" -#include "r128_ioctl.h" -#include "r128_tris.h" -#include "r128_tex.h" - -#include "main/context.h" -#include "main/enums.h" -#include "main/colormac.h" -#include "main/macros.h" -#include "main/state.h" -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "swrast_setup/swrast_setup.h" - -#include "drirenderbuffer.h" - - -/* ============================================================= - * Alpha blending - */ - - -/** - * Calculate the hardware blend factor setting. This same function is used - * for source and destination of both alpha and RGB. - * - * \returns - * The hardware register value for the specified blend factor. This value - * will need to be shifted into the correct position for either source or - * destination factor. - * - * \todo - * Since the two cases where source and destination are handled differently - * are essentially error cases, they should never happen. Determine if these - * cases can be removed. - */ -static int blend_factor( r128ContextPtr rmesa, GLenum factor, GLboolean is_src ) -{ - int func; - - switch ( factor ) { - case GL_ZERO: - func = R128_ALPHA_BLEND_ZERO; - break; - case GL_ONE: - func = R128_ALPHA_BLEND_ONE; - break; - - case GL_SRC_COLOR: - func = R128_ALPHA_BLEND_SRCCOLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - func = R128_ALPHA_BLEND_INVSRCCOLOR; - break; - case GL_SRC_ALPHA: - func = R128_ALPHA_BLEND_SRCALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - func = R128_ALPHA_BLEND_INVSRCALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - func = (is_src) ? R128_ALPHA_BLEND_SAT : R128_ALPHA_BLEND_ZERO; - break; - - case GL_DST_COLOR: - func = R128_ALPHA_BLEND_DSTCOLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - func = R128_ALPHA_BLEND_INVDSTCOLOR; - break; - case GL_DST_ALPHA: - func = R128_ALPHA_BLEND_DSTALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - func = R128_ALPHA_BLEND_INVDSTALPHA; - break; - - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - default: - FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE ); - func = (is_src) ? R128_ALPHA_BLEND_ONE : R128_ALPHA_BLEND_ZERO; - break; - } - - return func; -} - - -static void r128UpdateAlphaMode( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint a = rmesa->setup.misc_3d_state_cntl_reg; - GLuint t = rmesa->setup.tex_cntl_c; - - if ( ctx->Color.AlphaEnabled ) { - GLubyte ref; - - CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef); - - a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK); - - switch ( ctx->Color.AlphaFunc ) { - case GL_NEVER: - a |= R128_ALPHA_TEST_NEVER; - break; - case GL_LESS: - a |= R128_ALPHA_TEST_LESS; - break; - case GL_LEQUAL: - a |= R128_ALPHA_TEST_LESSEQUAL; - break; - case GL_EQUAL: - a |= R128_ALPHA_TEST_EQUAL; - break; - case GL_GEQUAL: - a |= R128_ALPHA_TEST_GREATEREQUAL; - break; - case GL_GREATER: - a |= R128_ALPHA_TEST_GREATER; - break; - case GL_NOTEQUAL: - a |= R128_ALPHA_TEST_NEQUAL; - break; - case GL_ALWAYS: - a |= R128_ALPHA_TEST_ALWAYS; - break; - } - - a |= ref & R128_REF_ALPHA_MASK; - t |= R128_ALPHA_TEST_ENABLE; - } else { - t &= ~R128_ALPHA_TEST_ENABLE; - } - - FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_FALSE ); - - if ( ctx->Color.BlendEnabled ) { - a &= ~((R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_SRC_SHIFT) | - (R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_DST_SHIFT) - | R128_ALPHA_COMB_FCN_MASK); - - a |= blend_factor( rmesa, ctx->Color.Blend[0].SrcRGB, GL_TRUE ) - << R128_ALPHA_BLEND_SRC_SHIFT; - a |= blend_factor( rmesa, ctx->Color.Blend[0].DstRGB, GL_FALSE ) - << R128_ALPHA_BLEND_DST_SHIFT; - - switch (ctx->Color.Blend[0].EquationRGB) { - case GL_FUNC_ADD: - a |= R128_ALPHA_COMB_ADD_CLAMP; - break; - case GL_FUNC_SUBTRACT: - a |= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP; - break; - default: - FALLBACK( rmesa, R128_FALLBACK_BLEND_EQ, GL_TRUE ); - } - - t |= R128_ALPHA_ENABLE; - } else { - t &= ~R128_ALPHA_ENABLE; - } - - if ( rmesa->setup.misc_3d_state_cntl_reg != a ) { - rmesa->setup.misc_3d_state_cntl_reg = a; - rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS; - } - if ( rmesa->setup.tex_cntl_c != t ) { - rmesa->setup.tex_cntl_c = t; - rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS; - } -} - -static void r128DDAlphaFunc( struct gl_context *ctx, GLenum func, GLfloat ref ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_ALPHA; -} - -static void r128DDBlendEquationSeparate( struct gl_context *ctx, - GLenum modeRGB, GLenum modeA ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - assert( modeRGB == modeA ); - FLUSH_BATCH( rmesa ); - - /* 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, - (modeRGB != GL_FUNC_ADD) && (modeRGB != GL_FUNC_SUBTRACT)); - - rmesa->new_state |= R128_NEW_ALPHA; -} - -static void r128DDBlendFuncSeparate( struct gl_context *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_ALPHA; -} - -/* ============================================================= - * Stencil - */ - -static void -r128DDStencilFuncSeparate( struct gl_context *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint refmask = (((ctx->Stencil.Ref[0] & 0xff) << 0) | - ((ctx->Stencil.ValueMask[0] & 0xff) << 16) | - ((ctx->Stencil.WriteMask[0] & 0xff) << 24)); - GLuint z = rmesa->setup.z_sten_cntl_c; - - z &= ~R128_STENCIL_TEST_MASK; - switch ( ctx->Stencil.Function[0] ) { - case GL_NEVER: - z |= R128_STENCIL_TEST_NEVER; - break; - case GL_LESS: - z |= R128_STENCIL_TEST_LESS; - break; - case GL_EQUAL: - z |= R128_STENCIL_TEST_EQUAL; - break; - case GL_LEQUAL: - z |= R128_STENCIL_TEST_LESSEQUAL; - break; - case GL_GREATER: - z |= R128_STENCIL_TEST_GREATER; - break; - case GL_NOTEQUAL: - z |= R128_STENCIL_TEST_NEQUAL; - break; - case GL_GEQUAL: - z |= R128_STENCIL_TEST_GREATEREQUAL; - break; - case GL_ALWAYS: - z |= R128_STENCIL_TEST_ALWAYS; - break; - } - - if ( rmesa->setup.sten_ref_mask_c != refmask ) { - rmesa->setup.sten_ref_mask_c = refmask; - rmesa->dirty |= R128_UPLOAD_MASKS; - } - if ( rmesa->setup.z_sten_cntl_c != z ) { - rmesa->setup.z_sten_cntl_c = z; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } -} - -static void -r128DDStencilMaskSeparate( struct gl_context *ctx, GLenum face, GLuint mask ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint refmask = (((ctx->Stencil.Ref[0] & 0xff) << 0) | - ((ctx->Stencil.ValueMask[0] & 0xff) << 16) | - ((ctx->Stencil.WriteMask[0] & 0xff) << 24)); - - if ( rmesa->setup.sten_ref_mask_c != refmask ) { - rmesa->setup.sten_ref_mask_c = refmask; - rmesa->dirty |= R128_UPLOAD_MASKS; - } -} - -static void r128DDStencilOpSeparate( struct gl_context *ctx, GLenum face, GLenum fail, - GLenum zfail, GLenum zpass ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint z = rmesa->setup.z_sten_cntl_c; - - if (!( ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24 )) - return; - - z &= ~(R128_STENCIL_S_FAIL_MASK | R128_STENCIL_ZPASS_MASK | - R128_STENCIL_ZFAIL_MASK); - - switch ( ctx->Stencil.FailFunc[0] ) { - case GL_KEEP: - z |= R128_STENCIL_S_FAIL_KEEP; - break; - case GL_ZERO: - z |= R128_STENCIL_S_FAIL_ZERO; - break; - case GL_REPLACE: - z |= R128_STENCIL_S_FAIL_REPLACE; - break; - case GL_INCR: - z |= R128_STENCIL_S_FAIL_INC; - break; - case GL_DECR: - z |= R128_STENCIL_S_FAIL_DEC; - break; - case GL_INVERT: - z |= R128_STENCIL_S_FAIL_INV; - break; - case GL_INCR_WRAP: - z |= R128_STENCIL_S_FAIL_INC_WRAP; - break; - case GL_DECR_WRAP: - z |= R128_STENCIL_S_FAIL_DEC_WRAP; - break; - } - - switch ( ctx->Stencil.ZFailFunc[0] ) { - case GL_KEEP: - z |= R128_STENCIL_ZFAIL_KEEP; - break; - case GL_ZERO: - z |= R128_STENCIL_ZFAIL_ZERO; - break; - case GL_REPLACE: - z |= R128_STENCIL_ZFAIL_REPLACE; - break; - case GL_INCR: - z |= R128_STENCIL_ZFAIL_INC; - break; - case GL_DECR: - z |= R128_STENCIL_ZFAIL_DEC; - break; - case GL_INVERT: - z |= R128_STENCIL_ZFAIL_INV; - break; - case GL_INCR_WRAP: - z |= R128_STENCIL_ZFAIL_INC_WRAP; - break; - case GL_DECR_WRAP: - z |= R128_STENCIL_ZFAIL_DEC_WRAP; - break; - } - - switch ( ctx->Stencil.ZPassFunc[0] ) { - case GL_KEEP: - z |= R128_STENCIL_ZPASS_KEEP; - break; - case GL_ZERO: - z |= R128_STENCIL_ZPASS_ZERO; - break; - case GL_REPLACE: - z |= R128_STENCIL_ZPASS_REPLACE; - break; - case GL_INCR: - z |= R128_STENCIL_ZPASS_INC; - break; - case GL_DECR: - z |= R128_STENCIL_ZPASS_DEC; - break; - case GL_INVERT: - z |= R128_STENCIL_ZPASS_INV; - break; - case GL_INCR_WRAP: - z |= R128_STENCIL_ZPASS_INC_WRAP; - break; - case GL_DECR_WRAP: - z |= R128_STENCIL_ZPASS_DEC_WRAP; - break; - } - - if ( rmesa->setup.z_sten_cntl_c != z ) { - rmesa->setup.z_sten_cntl_c = z; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } -} - -static void r128DDClearStencil( struct gl_context *ctx, GLint s ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - if (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24) { - rmesa->ClearDepth &= 0x00ffffff; - rmesa->ClearDepth |= ctx->Stencil.Clear << 24; - } -} - -/* ============================================================= - * Depth testing - */ - -static void r128UpdateZMode( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint z = rmesa->setup.z_sten_cntl_c; - GLuint t = rmesa->setup.tex_cntl_c; - - if ( ctx->Depth.Test ) { - z &= ~R128_Z_TEST_MASK; - - switch ( ctx->Depth.Func ) { - case GL_NEVER: - z |= R128_Z_TEST_NEVER; - break; - case GL_ALWAYS: - z |= R128_Z_TEST_ALWAYS; - break; - case GL_LESS: - z |= R128_Z_TEST_LESS; - break; - case GL_LEQUAL: - z |= R128_Z_TEST_LESSEQUAL; - break; - case GL_EQUAL: - z |= R128_Z_TEST_EQUAL; - break; - case GL_GEQUAL: - z |= R128_Z_TEST_GREATEREQUAL; - break; - case GL_GREATER: - z |= R128_Z_TEST_GREATER; - break; - case GL_NOTEQUAL: - z |= R128_Z_TEST_NEQUAL; - break; - } - - t |= R128_Z_ENABLE; - } else { - t &= ~R128_Z_ENABLE; - } - - if ( ctx->Depth.Mask ) { - t |= R128_Z_WRITE_ENABLE; - } else { - t &= ~R128_Z_WRITE_ENABLE; - } - - if ( rmesa->setup.z_sten_cntl_c != z ) { - rmesa->setup.z_sten_cntl_c = z; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } - if ( rmesa->setup.tex_cntl_c != t ) { - rmesa->setup.tex_cntl_c = t; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } -} - -static void r128DDDepthFunc( struct gl_context *ctx, GLenum func ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_DEPTH; -} - -static void r128DDDepthMask( struct gl_context *ctx, GLboolean flag ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_DEPTH; -} - -static void r128DDClearDepth( struct gl_context *ctx, GLclampd d ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - switch ( rmesa->setup.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK ) { - case R128_Z_PIX_WIDTH_16: - rmesa->ClearDepth = d * 0x0000ffff; - break; - case R128_Z_PIX_WIDTH_24: - rmesa->ClearDepth = d * 0x00ffffff; - rmesa->ClearDepth |= ctx->Stencil.Clear << 24; - break; - case R128_Z_PIX_WIDTH_32: - rmesa->ClearDepth = d * 0xffffffff; - break; - } -} - - -/* ============================================================= - * Fog - */ - -static void r128UpdateFogAttrib( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint t = rmesa->setup.tex_cntl_c; - GLubyte c[4]; - GLuint col; - - if ( ctx->Fog.Enabled ) { - t |= R128_FOG_ENABLE; - } else { - t &= ~R128_FOG_ENABLE; - } - - 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 ) { - rmesa->setup.fog_color_c = col; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } - if ( rmesa->setup.tex_cntl_c != t ) { - rmesa->setup.tex_cntl_c = t; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } -} - -static void r128DDFogfv( struct gl_context *ctx, GLenum pname, const GLfloat *param ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_FOG; -} - - -/* ============================================================= - * Clipping - */ - -static void r128UpdateClipping( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - if ( rmesa->driDrawable ) { - __DRIdrawable *drawable = rmesa->driDrawable; - int x1 = 0; - int y1 = 0; - int x2 = drawable->w - 1; - int y2 = drawable->h - 1; - - if ( ctx->Scissor.Enabled ) { - if ( ctx->Scissor.X > x1 ) { - x1 = ctx->Scissor.X; - } - if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y1 ) { - y1 = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height; - } - if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < x2 ) { - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - } - if ( drawable->h - ctx->Scissor.Y - 1 < y2 ) { - y2 = drawable->h - ctx->Scissor.Y - 1; - } - } - - x1 += drawable->x; - y1 += drawable->y; - x2 += drawable->x; - y2 += drawable->y; - - /* Clamp values to screen to avoid wrapping problems */ - if ( x1 < 0 ) - x1 = 0; - else if ( x1 >= rmesa->driScreen->fbWidth ) - x1 = rmesa->driScreen->fbWidth - 1; - if ( y1 < 0 ) - y1 = 0; - else if ( y1 >= rmesa->driScreen->fbHeight ) - y1 = rmesa->driScreen->fbHeight - 1; - if ( x2 < 0 ) - x2 = 0; - else if ( x2 >= rmesa->driScreen->fbWidth ) - x2 = rmesa->driScreen->fbWidth - 1; - if ( y2 < 0 ) - y2 = 0; - else if ( y2 >= rmesa->driScreen->fbHeight ) - y2 = rmesa->driScreen->fbHeight - 1; - - rmesa->setup.sc_top_left_c = (((y1 & 0x3FFF) << 16) | (x1 & 0x3FFF)); - rmesa->setup.sc_bottom_right_c = (((y2 & 0x3FFF) << 16) | (x2 & 0x3FFF)); - - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } -} - -static void r128DDScissor( struct gl_context *ctx, - GLint x, GLint y, GLsizei w, GLsizei h ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_CLIP; -} - - -/* ============================================================= - * Culling - */ - -static void r128UpdateCull( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint f = rmesa->setup.pm4_vc_fpu_setup; - - f &= ~R128_FRONT_DIR_MASK; - - switch ( ctx->Polygon.FrontFace ) { - case GL_CW: - f |= R128_FRONT_DIR_CW; - break; - case GL_CCW: - f |= R128_FRONT_DIR_CCW; - break; - } - - f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID; - - if ( ctx->Polygon.CullFlag ) { - 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 ( 1 || rmesa->setup.pm4_vc_fpu_setup != f ) { - rmesa->setup.pm4_vc_fpu_setup = f; - rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_SETUP; - } -} - -static void r128DDCullFace( struct gl_context *ctx, GLenum mode ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_CULL; -} - -static void r128DDFrontFace( struct gl_context *ctx, GLenum mode ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_CULL; -} - - -/* ============================================================= - * Masks - */ - -static void r128UpdateMasks( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - GLuint mask = r128PackColor( rmesa->r128Screen->cpp, - ctx->Color.ColorMask[0][RCOMP], - ctx->Color.ColorMask[0][GCOMP], - ctx->Color.ColorMask[0][BCOMP], - ctx->Color.ColorMask[0][ACOMP] ); - - if ( rmesa->setup.plane_3d_mask_c != mask ) { - rmesa->setup.plane_3d_mask_c = mask; - rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS; - } -} - -static void r128DDColorMask( struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_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 updateSpecularLighting( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint t = rmesa->setup.tex_cntl_c; - - if ( _mesa_need_secondary_color( ctx ) ) { - 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 ); - } - else { - t |= R128_SPEC_LIGHT_ENABLE; - FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE ); - } - } - else { - t &= ~R128_SPEC_LIGHT_ENABLE; - FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE ); - } - - 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( struct gl_context *ctx, GLenum pname, - const GLfloat *param ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) { - FLUSH_BATCH( rmesa ); - updateSpecularLighting(ctx); - } - - if ( pname == GL_LIGHT_MODEL_TWO_SIDE ) { - FLUSH_BATCH( rmesa ); - r128ChooseRenderState( ctx ); - } -} - -static void r128DDShadeModel( struct gl_context *ctx, GLenum mode ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint s = rmesa->setup.pm4_vc_fpu_setup; - - s &= ~R128_FPU_COLOR_MASK; - - switch ( mode ) { - case GL_FLAT: - s |= R128_FPU_COLOR_FLAT; - break; - case GL_SMOOTH: - s |= R128_FPU_COLOR_GOURAUD; - break; - default: - return; - } - - updateSpecularLighting(ctx); - - if ( rmesa->setup.pm4_vc_fpu_setup != s ) { - FLUSH_BATCH( rmesa ); - rmesa->setup.pm4_vc_fpu_setup = s; - - rmesa->new_state |= R128_NEW_CONTEXT; - rmesa->dirty |= R128_UPLOAD_SETUP; - } -} - - -/* ============================================================= - * Window position - */ - -static void r128UpdateWindow( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - int x = rmesa->driDrawable->x; - int y = rmesa->driDrawable->y; - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - driRenderbuffer *drb = (driRenderbuffer *) rb; - - rmesa->setup.window_xy_offset = (((y & 0xFFF) << R128_WINDOW_Y_SHIFT) | - ((x & 0xFFF) << R128_WINDOW_X_SHIFT)); - - rmesa->setup.dst_pitch_offset_c = (((drb->flippedPitch/8) << 21) | - (drb->flippedOffset >> 5)); - - - rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_WINDOW; -} - - -/* ============================================================= - * Viewport - */ - -static void r128CalcViewport( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = rmesa->hw_viewport; - - /* 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 r128Viewport( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - r128CalcViewport( ctx ); -} - -static void r128DepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - r128CalcViewport( ctx ); -} - - -/* ============================================================= - * Miscellaneous - */ - -static void r128DDClearColor( struct gl_context *ctx, - const GLfloat color[4] ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLubyte c[4]; - - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - rmesa->ClearColor = r128PackColor( rmesa->r128Screen->cpp, - c[0], c[1], c[2], c[3] ); -} - -static void r128DDLogicOpCode( struct gl_context *ctx, GLenum opcode ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - if ( ctx->Color.ColorLogicOpEnabled ) { - FLUSH_BATCH( rmesa ); - - FALLBACK( rmesa, R128_FALLBACK_LOGICOP, opcode != GL_COPY ); - } -} - -static void r128DDDrawBuffer( struct gl_context *ctx, GLenum mode ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ - FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - else { - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - case BUFFER_BACK_LEFT: - FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ - FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE ); - break; - } - } - - rmesa->new_state |= R128_NEW_WINDOW; -} - -static void r128DDReadBuffer( struct gl_context *ctx, GLenum mode ) -{ - /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */ -} - - -/* ============================================================= - * Polygon stipple - */ - -static void r128DDPolygonStipple( struct gl_context *ctx, const GLubyte *mask ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint stipple[32], i; - drm_r128_stipple_t stippleRec; - - 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 ); - - stippleRec.mask = stipple; - drmCommandWrite( rmesa->driFd, DRM_R128_STIPPLE, - &stippleRec, sizeof(stippleRec) ); - - UNLOCK_HARDWARE( rmesa ); - - rmesa->new_state |= R128_NEW_CONTEXT; - rmesa->dirty |= R128_UPLOAD_CONTEXT; -} - - -/* ============================================================= - * Render mode - */ - -static void r128DDRenderMode( struct gl_context *ctx, GLenum mode ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - FALLBACK( rmesa, R128_FALLBACK_RENDER_MODE, (mode != GL_RENDER) ); -} - - - -/* ============================================================= - * State enable/disable - */ - -static void r128DDEnable( struct gl_context *ctx, GLenum cap, GLboolean state ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %s = %s )\n", - __FUNCTION__, _mesa_lookup_enum_by_nr( cap ), - state ? "GL_TRUE" : "GL_FALSE" ); - } - - switch ( cap ) { - case GL_ALPHA_TEST: - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_ALPHA; - break; - - case GL_BLEND: - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_ALPHA; - - /* 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: - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_CULL; - break; - - case GL_DEPTH_TEST: - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_DEPTH; - break; - - case GL_DITHER: - do { - GLuint t = rmesa->setup.tex_cntl_c; - FLUSH_BATCH( rmesa ); - - if ( ctx->Color.DitherFlag ) { - t |= R128_DITHER_ENABLE; - } else { - t &= ~R128_DITHER_ENABLE; - } - - if ( rmesa->setup.tex_cntl_c != t ) { - rmesa->setup.tex_cntl_c = t; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } - } while (0); - break; - - case GL_FOG: - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_FOG; - break; - - case GL_COLOR_LOGIC_OP: - FLUSH_BATCH( rmesa ); - FALLBACK( rmesa, R128_FALLBACK_LOGICOP, - state && ctx->Color.LogicOp != GL_COPY ); - break; - - case GL_LIGHTING: - case GL_COLOR_SUM_EXT: - updateSpecularLighting(ctx); - break; - - case GL_SCISSOR_TEST: - FLUSH_BATCH( rmesa ); - rmesa->scissor = state; - rmesa->new_state |= R128_NEW_CLIP; - break; - - case GL_STENCIL_TEST: - FLUSH_BATCH( rmesa ); - if ( ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24 ) { - if ( state ) { - rmesa->setup.tex_cntl_c |= R128_STENCIL_ENABLE; - /* Reset the fallback (if any) for bad stencil funcs */ - r128DDStencilOpSeparate( ctx, 0, ctx->Stencil.FailFunc[0], - ctx->Stencil.ZFailFunc[0], - ctx->Stencil.ZPassFunc[0] ); - } else { - rmesa->setup.tex_cntl_c &= ~R128_STENCIL_ENABLE; - FALLBACK( rmesa, R128_FALLBACK_STENCIL, GL_FALSE ); - } - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } else { - FALLBACK( rmesa, R128_FALLBACK_STENCIL, state ); - } - break; - - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - FLUSH_BATCH( rmesa ); - break; - - case GL_POLYGON_STIPPLE: - if ( rmesa->render_primitive == GL_TRIANGLES ) { - FLUSH_BATCH( rmesa ); - rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE; - if ( state ) { - 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; - } - rmesa->new_state |= R128_NEW_CONTEXT; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } - break; - - default: - return; - } -} - - -/* ============================================================= - * State initialization, management - */ - -static void r128DDPrintDirty( const char *msg, GLuint state ) -{ - fprintf( stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n", - msg, - state, - (state & R128_UPLOAD_CORE) ? "core, " : "", - (state & R128_UPLOAD_CONTEXT) ? "context, " : "", - (state & R128_UPLOAD_SETUP) ? "setup, " : "", - (state & R128_UPLOAD_TEX0) ? "tex0, " : "", - (state & R128_UPLOAD_TEX1) ? "tex1, " : "", - (state & R128_UPLOAD_MASKS) ? "masks, " : "", - (state & R128_UPLOAD_WINDOW) ? "window, " : "", - (state & R128_UPLOAD_CLIPRECTS) ? "cliprects, " : "", - (state & R128_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 r128EmitHwStateLocked( r128ContextPtr rmesa ) -{ - drm_r128_sarea_t *sarea = rmesa->sarea; - drm_r128_context_regs_t *regs = &(rmesa->setup); - const r128TexObjPtr t0 = rmesa->CurrentTexObj[0]; - const r128TexObjPtr t1 = rmesa->CurrentTexObj[1]; - - if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) { - r128DDPrintDirty( "r128EmitHwStateLocked", rmesa->dirty ); - } - - if ( rmesa->dirty & (R128_UPLOAD_CONTEXT | - R128_UPLOAD_SETUP | - R128_UPLOAD_MASKS | - R128_UPLOAD_WINDOW | - R128_UPLOAD_CORE) ) { - memcpy( &sarea->context_state, regs, sizeof(sarea->context_state) ); - - if( rmesa->dirty & R128_UPLOAD_CONTEXT ) - { - /* One possible side-effect of uploading a new context is the - * setting of the R128_GMC_AUX_CLIP_DIS bit, which causes all - * auxilliary cliprects to be disabled. So the next command must - * upload them again. */ - rmesa->dirty |= R128_UPLOAD_CLIPRECTS; - } - } - - if ( (rmesa->dirty & R128_UPLOAD_TEX0) && t0 ) { - drm_r128_texture_regs_t *tex = &sarea->tex_state[0]; - - tex->tex_cntl = t0->setup.tex_cntl; - tex->tex_combine_cntl = rmesa->tex_combine[0]; - tex->tex_size_pitch = t0->setup.tex_size_pitch; - memcpy( &tex->tex_offset[0], &t0->setup.tex_offset[0], - sizeof(tex->tex_offset ) ); - tex->tex_border_color = t0->setup.tex_border_color; - } - - if ( (rmesa->dirty & R128_UPLOAD_TEX1) && t1 ) { - drm_r128_texture_regs_t *tex = &sarea->tex_state[1]; - - tex->tex_cntl = t1->setup.tex_cntl; - tex->tex_combine_cntl = rmesa->tex_combine[1]; - tex->tex_size_pitch = t1->setup.tex_size_pitch; - memcpy( &tex->tex_offset[0], &t1->setup.tex_offset[0], - sizeof(tex->tex_offset ) ); - tex->tex_border_color = t1->setup.tex_border_color; - } - - 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; - - sarea->dirty |= rmesa->dirty; - rmesa->dirty &= R128_UPLOAD_CLIPRECTS; -} - -static void r128DDPrintState( const char *msg, GLuint flags ) -{ - fprintf( stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s\n", - msg, - flags, - (flags & R128_NEW_CONTEXT) ? "context, " : "", - (flags & R128_NEW_ALPHA) ? "alpha, " : "", - (flags & R128_NEW_DEPTH) ? "depth, " : "", - (flags & R128_NEW_FOG) ? "fog, " : "", - (flags & R128_NEW_CLIP) ? "clip, " : "", - (flags & R128_NEW_CULL) ? "cull, " : "", - (flags & R128_NEW_MASKS) ? "masks, " : "", - (flags & R128_NEW_WINDOW) ? "window, " : "" ); -} - -void r128DDUpdateHWState( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - int new_state = rmesa->new_state; - - if ( new_state || rmesa->NewGLState & _NEW_TEXTURE ) - { - FLUSH_BATCH( rmesa ); - - rmesa->new_state = 0; - - if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) - r128DDPrintState( "r128UpdateHwState", new_state ); - - /* Update the various parts of the context's state. - */ - if ( new_state & R128_NEW_ALPHA ) - r128UpdateAlphaMode( ctx ); - - if ( new_state & R128_NEW_DEPTH ) - r128UpdateZMode( ctx ); - - if ( new_state & R128_NEW_FOG ) - r128UpdateFogAttrib( ctx ); - - if ( new_state & R128_NEW_CLIP ) - r128UpdateClipping( ctx ); - - if ( new_state & R128_NEW_CULL ) - r128UpdateCull( ctx ); - - if ( new_state & R128_NEW_MASKS ) - r128UpdateMasks( ctx ); - - if ( new_state & R128_NEW_WINDOW ) - { - r128UpdateWindow( ctx ); - r128CalcViewport( ctx ); - } - - if ( rmesa->NewGLState & _NEW_TEXTURE ) { - r128UpdateTextureState( ctx ); - } - } -} - - -static void r128DDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_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 ) -{ - int dst_bpp, depth_bpp; - - switch ( rmesa->r128Screen->cpp ) { - case 2: - dst_bpp = R128_GMC_DST_16BPP; - break; - case 4: - dst_bpp = R128_GMC_DST_32BPP; - break; - default: - fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" ); - exit( -1 ); - } - - rmesa->ClearColor = 0x00000000; - - switch ( rmesa->glCtx->Visual.depthBits ) { - case 16: - rmesa->ClearDepth = 0x0000ffff; - depth_bpp = R128_Z_PIX_WIDTH_16; - rmesa->depth_scale = 1.0 / (GLfloat)0xffff; - break; - case 24: - rmesa->ClearDepth = 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 ); - exit( -1 ); - } - - rmesa->Fallback = 0; - - /* Hardware state: - */ - rmesa->setup.dp_gui_master_cntl_c = (R128_GMC_DST_PITCH_OFFSET_CNTL | - R128_GMC_DST_CLIPPING | - R128_GMC_BRUSH_SOLID_COLOR | - dst_bpp | - R128_GMC_SRC_DATATYPE_COLOR | - R128_GMC_BYTE_MSB_TO_LSB | - R128_GMC_CONVERSION_TEMP_6500 | - R128_ROP3_S | - R128_DP_SRC_SOURCE_MEMORY | - R128_GMC_3D_FCN_EN | - R128_GMC_CLR_CMP_CNTL_DIS | - R128_GMC_AUX_CLIP_DIS | - R128_GMC_WR_MSK_DIS); - - rmesa->setup.sc_top_left_c = 0x00000000; - rmesa->setup.sc_bottom_right_c = 0x1fff1fff; - - rmesa->setup.z_offset_c = rmesa->r128Screen->depthOffset; - rmesa->setup.z_pitch_c = ((rmesa->r128Screen->depthPitch >> 3) | - R128_Z_TILE); - - rmesa->setup.z_sten_cntl_c = (depth_bpp | - R128_Z_TEST_LESS | - R128_STENCIL_TEST_ALWAYS | - R128_STENCIL_S_FAIL_KEEP | - R128_STENCIL_ZPASS_KEEP | - R128_STENCIL_ZFAIL_KEEP); - - rmesa->setup.tex_cntl_c = (R128_Z_WRITE_ENABLE | - R128_SHADE_ENABLE | - R128_DITHER_ENABLE | - R128_ALPHA_IN_TEX_COMPLETE_A | - R128_LIGHT_DIS | - R128_ALPHA_LIGHT_DIS | - R128_TEX_CACHE_FLUSH | - (0x3f << R128_LOD_BIAS_SHIFT)); - - rmesa->setup.misc_3d_state_cntl_reg = (R128_MISC_SCALE_3D_TEXMAP_SHADE | - R128_MISC_SCALE_PIX_REPLICATE | - R128_ALPHA_COMB_ADD_CLAMP | - R128_FOG_VERTEX | - (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) | - (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) | - R128_ALPHA_TEST_ALWAYS); - - rmesa->setup.texture_clr_cmp_clr_c = 0x00000000; - rmesa->setup.texture_clr_cmp_msk_c = 0xffffffff; - - rmesa->setup.fog_color_c = 0x00000000; - - rmesa->setup.pm4_vc_fpu_setup = (R128_FRONT_DIR_CCW | - R128_BACKFACE_SOLID | - R128_FRONTFACE_SOLID | - R128_FPU_COLOR_GOURAUD | - R128_FPU_SUB_PIX_4BITS | - R128_FPU_MODE_3D | - R128_TRAP_BITS_DISABLE | - R128_XFACTOR_2 | - R128_YFACTOR_2 | - R128_FLAT_SHADE_VERTEX_OGL | - R128_FPU_ROUND_TRUNCATE | - R128_WM_SEL_8DW); - - rmesa->setup.setup_cntl = (R128_COLOR_GOURAUD | - R128_PRIM_TYPE_TRI | - R128_TEXTURE_ST_MULT_W | - R128_STARTING_VERTEX_1 | - R128_ENDING_VERTEX_3 | - R128_SU_POLY_LINE_NOT_LAST | - R128_SUB_PIX_4BITS); - - rmesa->setup.tex_size_pitch_c = 0x00000000; - rmesa->setup.constant_color_c = 0x00ffffff; - - rmesa->setup.dp_write_mask = 0xffffffff; - rmesa->setup.sten_ref_mask_c = 0xffff0000; - rmesa->setup.plane_3d_mask_c = 0xffffffff; - - rmesa->setup.window_xy_offset = 0x00000000; - - rmesa->setup.scale_3d_cntl = (R128_SCALE_DITHER_TABLE | - R128_TEX_CACHE_SIZE_FULL | - R128_DITHER_INIT_RESET | - R128_SCALE_3D_TEXMAP_SHADE | - R128_SCALE_PIX_REPLICATE | - R128_ALPHA_COMB_ADD_CLAMP | - R128_FOG_VERTEX | - (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) | - (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) | - R128_ALPHA_TEST_ALWAYS | - R128_COMPOSITE_SHADOW_CMP_EQUAL | - R128_TEX_MAP_ALPHA_IN_TEXTURE | - R128_TEX_CACHE_LINE_SIZE_4QW); - - rmesa->new_state = R128_NEW_ALL; -} - -/* Initialize the driver's state functions. - */ -void r128DDInitStateFuncs( struct gl_context *ctx ) -{ - ctx->Driver.UpdateState = r128DDInvalidateState; - - ctx->Driver.ClearColor = r128DDClearColor; - ctx->Driver.ClearStencil = r128DDClearStencil; - ctx->Driver.DrawBuffer = r128DDDrawBuffer; - ctx->Driver.ReadBuffer = r128DDReadBuffer; - - ctx->Driver.ColorMask = r128DDColorMask; - ctx->Driver.AlphaFunc = r128DDAlphaFunc; - ctx->Driver.BlendEquationSeparate = r128DDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = r128DDBlendFuncSeparate; - ctx->Driver.ClearDepth = r128DDClearDepth; - ctx->Driver.CullFace = r128DDCullFace; - ctx->Driver.FrontFace = r128DDFrontFace; - ctx->Driver.DepthFunc = r128DDDepthFunc; - ctx->Driver.DepthMask = r128DDDepthMask; - ctx->Driver.Enable = r128DDEnable; - ctx->Driver.Fogfv = r128DDFogfv; - ctx->Driver.Hint = NULL; - ctx->Driver.Lightfv = NULL; - ctx->Driver.LightModelfv = r128DDLightModelfv; - 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.StencilFuncSeparate = r128DDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = r128DDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = r128DDStencilOpSeparate; - - ctx->Driver.DepthRange = r128DepthRange; - ctx->Driver.Viewport = r128Viewport; -} diff --git a/src/mesa/drivers/dri/r128/r128_state.h b/src/mesa/drivers/dri/r128/r128_state.h deleted file mode 100644 index 55b0cbf4b77..00000000000 --- a/src/mesa/drivers/dri/r128/r128_state.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#ifndef __R128_STATE_H__ -#define __R128_STATE_H__ - -#include "r128_context.h" - -extern void r128DDInitState( r128ContextPtr rmesa ); -extern void r128DDInitStateFuncs( struct gl_context *ctx ); - -extern void r128DDUpdateState( struct gl_context *ctx ); -extern void r128DDUpdateHWState( struct gl_context *ctx ); - -extern void r128EmitHwStateLocked( r128ContextPtr rmesa ); - -#endif diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c deleted file mode 100644 index a3f6ce8edeb..00000000000 --- a/src/mesa/drivers/dri/r128/r128_tex.c +++ /dev/null @@ -1,615 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * Brian Paul <[email protected]> - */ - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_tex.h" -#include "r128_texobj.h" - -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/texstore.h" -#include "main/teximage.h" -#include "main/texobj.h" -#include "main/imports.h" -#include "main/macros.h" - -#include "xmlpool.h" - -#define TEX_0 1 -#define TEX_1 2 - - -/** - * Set the texture wrap modes. Currently \c GL_REPEAT, \c GL_CLAMP, - * \c GL_CLAMP_TO_EDGE, and \c GL_MIRRORED_REPEAT are supported. - * - * \param t Texture object whose wrap modes are to be set - * \param swrap Wrap mode for the \a s texture coordinate - * \param twrap Wrap mode for the \a t texture coordinate - */ -static void r128SetTexWrap( r128TexObjPtr t, GLenum swrap, GLenum twrap ) -{ - t->setup.tex_cntl &= ~(R128_TEX_CLAMP_S_MASK | R128_TEX_CLAMP_T_MASK); - - 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: - t->setup.tex_cntl |= R128_TEX_CLAMP_S_WRAP; - break; - case GL_MIRRORED_REPEAT: - t->setup.tex_cntl |= R128_TEX_CLAMP_S_MIRROR; - break; - } - - 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: - t->setup.tex_cntl |= R128_TEX_CLAMP_T_WRAP; - break; - case GL_MIRRORED_REPEAT: - t->setup.tex_cntl |= R128_TEX_CLAMP_T_MIRROR; - break; - } -} - -static void r128SetTexFilter( r128TexObjPtr t, GLenum minf, GLenum magf ) -{ - t->setup.tex_cntl &= ~(R128_MIN_BLEND_MASK | R128_MAG_BLEND_MASK); - - switch ( minf ) { - case GL_NEAREST: - t->setup.tex_cntl |= R128_MIN_BLEND_NEAREST; - break; - case GL_LINEAR: - t->setup.tex_cntl |= R128_MIN_BLEND_LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: - t->setup.tex_cntl |= R128_MIN_BLEND_MIPNEAREST; - break; - case GL_LINEAR_MIPMAP_NEAREST: - t->setup.tex_cntl |= R128_MIN_BLEND_MIPLINEAR; - break; - case GL_NEAREST_MIPMAP_LINEAR: - t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST; - break; - case GL_LINEAR_MIPMAP_LINEAR: - t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR; - break; - } - - switch ( magf ) { - case GL_NEAREST: - t->setup.tex_cntl |= R128_MAG_BLEND_NEAREST; - break; - case GL_LINEAR: - t->setup.tex_cntl |= R128_MAG_BLEND_LINEAR; - break; - } -} - -static void r128SetTexBorderColor( r128TexObjPtr t, const GLfloat color[4] ) -{ - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - t->setup.tex_border_color = r128PackColor( 4, c[0], c[1], c[2], c[3] ); -} - - -static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj ) -{ - r128TexObjPtr t; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *) texObj ); - } - - t = (r128TexObjPtr) CALLOC_STRUCT( r128_tex_obj ); - texObj->DriverData = t; - if ( t != NULL ) { - - /* Initialize non-image-dependent parts of the state: - */ - t->base.tObj = texObj; - - /* FIXME Something here to set initial values for other parts of - * FIXME t->setup? - */ - - make_empty_list( (driTextureObject *) t ); - - r128SetTexWrap( t, texObj->Sampler.WrapS, texObj->Sampler.WrapT ); - r128SetTexFilter( t, texObj->Sampler.MinFilter, texObj->Sampler.MagFilter ); - r128SetTexBorderColor( t, texObj->Sampler.BorderColor.f ); - } - - return t; -} - - -/* Called by the _mesa_store_teximage[123]d() functions. */ -static gl_format -r128ChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - const GLboolean do32bpt = - ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 ); - const GLboolean force16bpt = - ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 ); - (void) format; - (void) type; - - switch ( internalFormat ) { - /* non-sized formats with alpha */ - case GL_INTENSITY: - case GL_COMPRESSED_INTENSITY: - case GL_ALPHA: - case GL_COMPRESSED_ALPHA: - case 2: - case GL_LUMINANCE_ALPHA: - case GL_COMPRESSED_LUMINANCE_ALPHA: - case 4: - case GL_RGBA: - case GL_COMPRESSED_RGBA: - if (do32bpt) - return _dri_texformat_argb8888; - else - return _dri_texformat_argb4444; - - /* 16-bit formats with alpha */ - case GL_INTENSITY4: - case GL_ALPHA4: - case GL_LUMINANCE4_ALPHA4: - case GL_RGBA2: - case GL_RGBA4: - return _dri_texformat_argb4444; - - /* 32-bit formats with alpha */ - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - if (!force16bpt) - return _dri_texformat_argb8888; - else - return _dri_texformat_argb4444; - - /* non-sized formats without alpha */ - case 1: - case GL_LUMINANCE: - case GL_COMPRESSED_LUMINANCE: - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - if (do32bpt) - return _dri_texformat_argb8888; - else - return _dri_texformat_rgb565; - - /* 16-bit formats without alpha */ - case GL_LUMINANCE4: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - return _dri_texformat_rgb565; - - /* 32-bit formats without alpha */ - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - if (!force16bpt) - return _dri_texformat_argb8888; - else - return _dri_texformat_rgb565; - - /* color-indexed formats */ - 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 _dri_texformat_ci8; - - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_APPLE || - type == GL_UNSIGNED_BYTE) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - - default: - _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ ); - return MESA_FORMAT_NONE; - } -} - - -static void r128TexImage1D( struct gl_context *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 ) -{ - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) r128AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - return; - } - } - - /* Note, this will call r128ChooseTextureFormat */ - _mesa_store_teximage1d( ctx, target, level, internalFormat, - width, border, format, type, - pixels, packing, texObj, texImage ); - - t->dirty_images[0] |= (1 << level); -} - - -static void r128TexSubImage1D( struct gl_context *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 ) -{ - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - assert( t ); /* this _should_ be true */ - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) r128AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); - return; - } - } - - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, packing, texObj, - texImage); - - t->dirty_images[0] |= (1 << level); -} - - -static void r128TexImage2D( struct gl_context *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 ) -{ - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - if ( t ) { - driSwapOutTextureObject( (driTextureObject *) t ); - } - else { - t = (driTextureObject *) r128AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - - /* Note, this will call r128ChooseTextureFormat */ - _mesa_store_teximage2d(ctx, target, level, internalFormat, - width, height, border, format, type, pixels, - &ctx->Unpack, texObj, texImage); - - t->dirty_images[0] |= (1 << level); -} - - -static void r128TexSubImage2D( struct gl_context *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 ) -{ - driTextureObject * t = (driTextureObject *) texObj->DriverData; - - assert( t ); /* this _should_ be true */ - if ( t ) { - driSwapOutTextureObject( t ); - } - else { - t = (driTextureObject *) r128AllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); - t->dirty_images[0] |= (1 << level); -} - - -static void r128TexEnv( struct gl_context *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - struct gl_texture_unit *texUnit; - GLubyte c[4]; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %s )\n", - __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) ); - } - - switch ( pname ) { - case GL_TEXTURE_ENV_MODE: - FLUSH_BATCH( rmesa ); - rmesa->new_state |= R128_NEW_ALPHA; - break; - - case GL_TEXTURE_ENV_COLOR: - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - 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 ); - rmesa->setup.constant_color_c = rmesa->env_color; - - /* More complex multitexture/multipass fallbacks for GL_BLEND - * can be done later, but this allows a single pass GL_BLEND - * in some cases (ie. Performer town demo). This is only - * applicable to the regular Rage 128, as the Pro and M3 can - * handle true single-pass GL_BLEND texturing. - */ - rmesa->blend_flags &= ~R128_BLEND_ENV_COLOR; - if ( R128_IS_PLAIN( rmesa ) && - rmesa->env_color != 0x00000000 && - rmesa->env_color != 0xff000000 && - rmesa->env_color != 0x00ffffff && - rmesa->env_color != 0xffffffff ) { - rmesa->blend_flags |= R128_BLEND_ENV_COLOR; - } - } - break; - - case GL_TEXTURE_LOD_BIAS: - { - uint32_t t = rmesa->setup.tex_cntl_c; - GLint bias; - uint32_t b; - - /* GTH: This isn't exactly correct, but gives good results up to a - * certain point. It is better than completely ignoring the LOD - * bias. Unfortunately there isn't much range in the bias, the - * spec mentions strides that vary between 0.5 and 2.0 but these - * numbers don't seem to relate to the GL LOD bias value at all. - */ - if ( param[0] >= 1.0 ) { - bias = -128; - } else if ( param[0] >= 0.5 ) { - bias = -64; - } else if ( param[0] >= 0.25 ) { - bias = 0; - } else if ( param[0] >= 0.0 ) { - bias = 63; - } else { - bias = 127; - } - - b = (uint32_t)bias & 0xff; - t &= ~R128_LOD_BIAS_MASK; - t |= (b << R128_LOD_BIAS_SHIFT); - - if ( rmesa->setup.tex_cntl_c != t ) { - FLUSH_BATCH( rmesa ); - rmesa->setup.tex_cntl_c = t; - rmesa->dirty |= R128_UPLOAD_CONTEXT; - } - } - break; - - default: - return; - } -} - - -static void r128TexParameter( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %s )\n", - __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) ); - } - - if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) ) - return; - - switch ( pname ) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - if ( t->base.bound ) FLUSH_BATCH( rmesa ); - r128SetTexFilter( t, tObj->Sampler.MinFilter, tObj->Sampler.MagFilter ); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - if ( t->base.bound ) FLUSH_BATCH( rmesa ); - r128SetTexWrap( t, tObj->Sampler.WrapS, tObj->Sampler.WrapT ); - break; - - case GL_TEXTURE_BORDER_COLOR: - if ( t->base.bound ) FLUSH_BATCH( rmesa ); - r128SetTexBorderColor( t, tObj->Sampler.BorderColor.f ); - 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->base.bound ) FLUSH_BATCH( rmesa ); - driSwapOutTextureObject( (driTextureObject *) t ); - break; - - default: - return; - } -} - -static void r128BindTexture( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *) tObj, - ctx->Texture.CurrentUnit ); - } - - assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_1D) || - (tObj->DriverData != NULL) ); -} - - -static void r128DeleteTexture( struct gl_context *ctx, - struct gl_texture_object *tObj ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - driTextureObject * t = (driTextureObject *) tObj->DriverData; - - if ( t ) { - if ( t->bound && rmesa ) { - FLUSH_BATCH( rmesa ); - } - - driDestroyTextureObject( t ); - } - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); -} - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -r128NewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - r128AllocTexObj( obj ); - return obj; -} - -void r128InitTextureFuncs( struct dd_function_table *functions ) -{ - functions->TexEnv = r128TexEnv; - functions->ChooseTextureFormat = r128ChooseTextureFormat; - functions->TexImage1D = r128TexImage1D; - functions->TexSubImage1D = r128TexSubImage1D; - functions->TexImage2D = r128TexImage2D; - functions->TexSubImage2D = r128TexSubImage2D; - functions->TexParameter = r128TexParameter; - functions->BindTexture = r128BindTexture; - functions->NewTextureObject = r128NewTextureObject; - functions->DeleteTexture = r128DeleteTexture; - functions->IsTextureResident = driIsTextureResident; - - driInitTextureFormats(); -} - diff --git a/src/mesa/drivers/dri/r128/r128_tex.h b/src/mesa/drivers/dri/r128/r128_tex.h deleted file mode 100644 index 98e9b04ad01..00000000000 --- a/src/mesa/drivers/dri/r128/r128_tex.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#ifndef __R128_TEX_H__ -#define __R128_TEX_H__ - -extern void r128UpdateTextureState( struct gl_context *ctx ); - -extern void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t ); - -extern void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t ); - -extern void r128InitTextureFuncs( struct dd_function_table *functions ); - - -/* ================================================================ - * Color conversion macros: - */ - -#define R128PACKCOLOR332( r, g, b ) \ - (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6)) - -#define R128PACKCOLOR1555( r, g, b, a ) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define R128PACKCOLOR565( r, g, b ) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define R128PACKCOLOR888( r, g, b ) \ - (((r) << 16) | ((g) << 8) | (b)) - -#define R128PACKCOLOR8888( r, g, b, a ) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define R128PACKCOLOR4444( r, g, b, a ) \ - ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4)) - -static INLINE uint32_t r128PackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return R128PACKCOLOR565( r, g, b ); - case 4: - return R128PACKCOLOR8888( r, g, b, a ); - default: - return 0; - } -} - -#endif /* __R128_TEX_H__ */ diff --git a/src/mesa/drivers/dri/r128/r128_texmem.c b/src/mesa/drivers/dri/r128/r128_texmem.c deleted file mode 100644 index 412f6d42551..00000000000 --- a/src/mesa/drivers/dri/r128/r128_texmem.c +++ /dev/null @@ -1,299 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * Brian Paul <[email protected]> - */ - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_tex.h" - -#include "main/macros.h" -#include "main/simple_list.h" -#include "main/imports.h" - -#define TEX_0 1 -#define TEX_1 2 - - -/* Destroy hardware state associated with texture `t'. - */ -void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t ) -{ - unsigned i; - - - /* See if it was the driver's current object. - */ - - if ( rmesa != NULL ) - { - for ( i = 0 ; i < rmesa->glCtx->Const.MaxTextureUnits ; i++ ) - { - if ( t == rmesa->CurrentTexObj[ i ] ) { - assert( t->base.bound & (1 << i) ); - rmesa->CurrentTexObj[ i ] = NULL; - } - } - } -} - - -/** - * Upload the texture image associated with texture \a t at the specified - * level at the address relative to \a start. - */ -static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t, - GLint level, - GLint x, GLint y, GLint width, GLint height ) -{ - struct gl_texture_image *image; - int texelsPerDword = 0; - int imageWidth, imageHeight; - int remaining, rows; - int format, dwords; - uint32_t pitch, offset; - int i; - - /* Ensure we have a valid texture to upload */ - if ( ( level < 0 ) || ( level > R128_MAX_TEXTURE_LEVELS ) ) - return; - - image = t->base.tObj->Image[0][level]; - if ( !image ) - return; - - switch ( _mesa_get_format_bytes(image->TexFormat) ) { - 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->base.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++ ) - { - uint32_t *dst; - drmBufPtr buffer; - - assert(image->Data); - - height = MIN2(remaining, rows); - - /* Grab the indirect buffer for the texture blit */ - LOCK_HARDWARE( rmesa ); - buffer = r128GetBufferLocked( rmesa ); - - dst = (uint32_t *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET); - - /* Copy the next chunck of the texture image into the blit buffer */ - { - const GLuint texelBytes = - _mesa_get_format_bytes(image->TexFormat); - const GLubyte *src = (const GLubyte *) image->Data + - (y * image->Width + x) * texelBytes; - const GLuint bytes = width * height * texelBytes; - memcpy(dst, src, bytes); - } - - r128FireBlitLocked( rmesa, buffer, - offset, pitch, format, - x, y, width, height ); - UNLOCK_HARDWARE( rmesa ); - } - - 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. - */ -void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t ) -{ - const GLint numLevels = t->base.lastLevel - t->base.firstLevel + 1; - GLint i; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p, %p )\n", - __FUNCTION__, (void *) rmesa->glCtx, (void *) t ); - } - - assert(t); - - LOCK_HARDWARE( rmesa ); - - if ( !t->base.memBlock ) { - int heap; - - - heap = driAllocateTexture( rmesa->texture_heaps, rmesa->nr_heaps, - (driTextureObject *) t ); - if ( heap == -1 ) { - UNLOCK_HARDWARE( rmesa ); - return; - } - - /* Set the base offset of the texture image */ - assert(t->base.memBlock); - t->bufAddr = rmesa->r128Screen->texOffset[heap] - + t->base.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; - } - } - } - - /* Let the world know we've used this memory recently. - */ - driUpdateTextureLRU( (driTextureObject *) t ); - UNLOCK_HARDWARE( rmesa ); - - /* Upload any images that are new */ - if ( t->base.dirty_images[0] ) { - for ( i = 0 ; i < numLevels; i++ ) { - const GLint j = t->base.firstLevel + i; /* the texObj's level */ - if ( t->base.dirty_images[0] & (1 << j) ) { - uploadSubImage( 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->base.dirty_images[0] = 0; - } -} diff --git a/src/mesa/drivers/dri/r128/r128_texobj.h b/src/mesa/drivers/dri/r128/r128_texobj.h deleted file mode 100644 index efbbb2df781..00000000000 --- a/src/mesa/drivers/dri/r128/r128_texobj.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Gareth Hughes <[email protected]> - * - */ - -#ifndef _R128_TEXOBJ_H_ -#define _R128_TEXOBJ_H_ - -#include "main/mm.h" - -/* Individual texture image information. - */ -typedef struct { - GLuint offset; /* Relative to local texture space */ - GLuint width; - GLuint height; -} r128TexImage; - -typedef struct r128_tex_obj r128TexObj, *r128TexObjPtr; - -/* Texture object in locally shared texture space. - */ -struct r128_tex_obj { - driTextureObject base; - - uint32_t bufAddr; /* Offset to start of locally - shared texture block */ - - GLuint age; - r128TexImage image[R128_MAX_TEXTURE_LEVELS]; /* Image data for all - mipmap levels */ - - uint32_t textureFormat; /* Actual hardware format */ - - drm_r128_texture_regs_t setup; /* Setup regs for texture */ -}; - -#endif /* _R128_TEXOBJ_H_ */ diff --git a/src/mesa/drivers/dri/r128/r128_texstate.c b/src/mesa/drivers/dri/r128/r128_texstate.c deleted file mode 100644 index 11441639411..00000000000 --- a/src/mesa/drivers/dri/r128/r128_texstate.c +++ /dev/null @@ -1,645 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Kevin E. Martin <[email protected]> - * Brian Paul <[email protected]> - */ - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/context.h" -#include "main/macros.h" - -#include "r128_context.h" -#include "r128_ioctl.h" -#include "r128_tris.h" -#include "r128_tex.h" - - -static void r128SetTexImages( r128ContextPtr rmesa, - const struct gl_texture_object *tObj ) -{ - r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData; - struct gl_texture_image *baseImage = tObj->Image[0][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__, (void *) tObj ); - - switch (baseImage->TexFormat) { - case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_ARGB8888_REV: - t->textureFormat = R128_DATATYPE_ARGB8888; - break; - case MESA_FORMAT_ARGB4444: - case MESA_FORMAT_ARGB4444_REV: - t->textureFormat = R128_DATATYPE_ARGB4444; - break; - case MESA_FORMAT_RGB565: - case MESA_FORMAT_RGB565_REV: - 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; - case MESA_FORMAT_YCBCR: - t->textureFormat = R128_DATATYPE_YVYU422; - break; - case MESA_FORMAT_YCBCR_REV: - t->textureFormat = R128_DATATYPE_VYUY422; - break; - default: - _mesa_problem(rmesa->glCtx, "Bad texture format in %s", __FUNCTION__); - }; - - /* Compute which mipmap levels we really want to send to the hardware. - */ - - driCalculateTextureFirstLastLevel( (driTextureObject *) t ); - firstLevel = t->base.firstLevel; - lastLevel = t->base.lastLevel; - - log2Pitch = tObj->Image[0][firstLevel]->WidthLog2; - log2Height = tObj->Image[0][firstLevel]->HeightLog2; - log2Size = MAX2(log2Pitch, log2Height); - log2MinSize = log2Size; - - t->base.dirty_images[0] = 0; - totalSize = 0; - for ( i = firstLevel; i <= lastLevel; i++ ) { - const struct gl_texture_image *texImage; - - texImage = tObj->Image[0][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[0][i]->Width; - t->image[i - firstLevel].height = tObj->Image[0][i]->Height; - - t->base.dirty_images[0] |= (1 << i); - - totalSize += (tObj->Image[0][i]->Height * - tObj->Image[0][i]->Width * - _mesa_get_format_bytes(tObj->Image[0][i]->TexFormat)); - - /* Offsets must be 32-byte aligned for host data blits and tiling */ - totalSize = (totalSize + 31) & ~31; - } - - t->base.totalSize = totalSize; - t->base.firstLevel = firstLevel; - t->base.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; - - /* FYI: r128UploadTexImages( rmesa, t ); used to be called here */ -} - - -/* ================================================================ - * 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 GLboolean r128UpdateTextureEnv( struct gl_context *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[0][tObj->BaseLevel]->_BaseFormat; - GLuint combine; - - if ( R128_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %p, %d )\n", - __FUNCTION__, (void *) 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 GL_FALSE; - } - 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 GL_FALSE; - } - 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 GL_FALSE; - } - 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 */ - return GL_FALSE; - } - break; - - case GL_COLOR_INDEX: - default: - return GL_FALSE; - } - break; - } - - /* Rage 128 has to fake some cases of GL_BLEND, otherwise fallback - * to software rendering. - */ - if ( rmesa->blend_flags ) { - return GL_FALSE; - } - 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 */ - return GL_FALSE; - } - 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 */ - return GL_FALSE; - } - 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 */ - return GL_FALSE; - } - 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 */ - return GL_FALSE; - } - break; - case GL_COLOR_INDEX: - default: - return GL_FALSE; - } - 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 GL_FALSE; - } - break; - - default: - return GL_FALSE; - } - - if ( rmesa->tex_combine[unit] != combine ) { - rmesa->tex_combine[unit] = combine; - rmesa->dirty |= R128_UPLOAD_TEX0 << unit; - } - return GL_TRUE; -} - -static void disable_tex( struct gl_context *ctx, int unit ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - FLUSH_BATCH( rmesa ); - - if ( rmesa->CurrentTexObj[unit] ) { - rmesa->CurrentTexObj[unit]->base.bound &= ~(1 << unit); - rmesa->CurrentTexObj[unit] = NULL; - } - - rmesa->setup.tex_cntl_c &= ~(R128_TEXMAP_ENABLE << unit); - rmesa->setup.tex_size_pitch_c &= ~(R128_TEX_SIZE_PITCH_MASK << - (R128_SEC_TEX_SIZE_PITCH_SHIFT * unit)); - rmesa->dirty |= R128_UPLOAD_CONTEXT; - - /* If either texture unit is disabled, then multitexturing is not - * happening. - */ - - rmesa->blend_flags &= ~R128_BLEND_MULTITEX; -} - -static GLboolean enable_tex_2d( struct gl_context *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 = texUnit->_Current; - r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData; - - /* Need to load the 2d images associated with this unit. - */ - if ( t->base.dirty_images[0] ) { - /* FIXME: For Radeon, RADEON_FIREVERTICES is called here. Should - * FIXME: something similar be done for R128? - */ - /* FLUSH_BATCH( rmesa ); */ - - r128SetTexImages( rmesa, tObj ); - r128UploadTexImages( rmesa, t ); - if ( !t->base.memBlock ) - return GL_FALSE; - } - - return GL_TRUE; -} - -static GLboolean update_tex_common( struct gl_context *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 = texUnit->_Current; - r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData; - - - /* Fallback if there's a texture border */ - if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) { - return GL_FALSE; - } - - - /* Update state if this is a different texture object to last - * time. - */ - if ( rmesa->CurrentTexObj[unit] != t ) { - if ( rmesa->CurrentTexObj[unit] != NULL ) { - /* The old texture is no longer bound to this texture unit. - * Mark it as such. - */ - - rmesa->CurrentTexObj[unit]->base.bound &= - ~(1UL << unit); - } - - rmesa->CurrentTexObj[unit] = t; - t->base.bound |= (1UL << unit); - rmesa->dirty |= R128_UPLOAD_TEX0 << unit; - - driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */ - } - - /* FIXME: We need to update the texture unit if any texture parameters have - * changed, but this texture was already bound. This could be changed to - * work like the Radeon driver where the texture object has it's own - * dirty state flags - */ - rmesa->dirty |= R128_UPLOAD_TEX0 << unit; - - /* register setup */ - rmesa->setup.tex_size_pitch_c &= ~(R128_TEX_SIZE_PITCH_MASK << - (R128_SEC_TEX_SIZE_PITCH_SHIFT * unit)); - - 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; - - /* If the second TMU is enabled, then multitexturing is happening. - */ - if ( R128_IS_PLAIN( rmesa ) ) - rmesa->blend_flags |= R128_BLEND_MULTITEX; - } - - rmesa->dirty |= R128_UPLOAD_CONTEXT; - - - /* FIXME: The Radeon has some cached state so that it can avoid calling - * FIXME: UpdateTextureEnv in some cases. Is that possible here? - */ - return r128UpdateTextureEnv( ctx, unit ); -} - -static GLboolean updateTextureUnit( struct gl_context *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]; - - - if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) { - return (enable_tex_2d( ctx, unit ) && - update_tex_common( ctx, unit )); - } - else if ( texUnit->_ReallyEnabled ) { - return GL_FALSE; - } - else { - disable_tex( ctx, unit ); - return GL_TRUE; - } -} - - -void r128UpdateTextureState( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLboolean ok; - - - /* This works around a quirk with the R128 hardware. If only OpenGL - * TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The - * hardware TEXTURE1 can ONLY be used when hardware TEXTURE0 is also used. - */ - - rmesa->tmu_source[0] = 0; - rmesa->tmu_source[1] = 1; - - if ((ctx->Texture._EnabledUnits & 0x03) == 0x02) { - /* only texture 1 enabled */ - rmesa->tmu_source[0] = 1; - rmesa->tmu_source[1] = 0; - } - - ok = (updateTextureUnit( ctx, 0 ) && - updateTextureUnit( ctx, 1 )); - - FALLBACK( rmesa, R128_FALLBACK_TEXTURE, !ok ); -} diff --git a/src/mesa/drivers/dri/r128/r128_tris.c b/src/mesa/drivers/dri/r128/r128_tris.c deleted file mode 100644 index 92c8a4eb6b8..00000000000 --- a/src/mesa/drivers/dri/r128/r128_tris.c +++ /dev/null @@ -1,797 +0,0 @@ -/* -*- c-basic-offset: 3 -*- */ -/************************************************************************** - -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 <[email protected]> - * - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/macros.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 "r128_tris.h" -#include "r128_state.h" -#include "r128_tex.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( struct gl_context *ctx, GLuint hwprim ); -static void r128RenderPrimitive( struct gl_context *ctx, GLenum prim ); - - -/*********************************************************************** - * Emit primitives as inline vertices * - ***********************************************************************/ - -#define HAVE_QUADS 0 -#define HAVE_LINES 1 -#define HAVE_POINTS 1 -#define HAVE_LE32_VERTS 1 -#define CTX_ARG r128ContextPtr rmesa -#define GET_VERTEX_DWORDS() rmesa->vertex_size -#define ALLOC_VERTS( n, size ) r128AllocDmaLow( rmesa, (n), (size) * 4 ) -#undef LOCAL_VARS -#define LOCAL_VARS \ - r128ContextPtr rmesa = R128_CONTEXT(ctx); \ - const char *vertptr = rmesa->verts; -#define VERT(x) (r128Vertex *)(vertptr + ((x) * vertsize * 4)) -#define VERTEX r128Vertex -#undef TAG -#define TAG(x) r128_##x -#include "tnl_dd/t_dd_triemit.h" -#undef TAG -#undef LOCAL_VARS - - -/*********************************************************************** - * 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_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_quad( rmesa, a, b, c, d ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - rmesa->draw_line( rmesa, v0, v1 ); \ - else \ - r128_line( rmesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - rmesa->draw_point( rmesa, v0 ); \ - else \ - r128_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 { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_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_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX r128Vertex -#define TAB rast_tab - -#define DEPTH_SCALE rmesa->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) (rmesa->verts + (e * rmesa->vertex_size * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - r128_color_t *color = (r128_color_t *)&((v)->ui[coloroffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] - -#define VERT_SET_SPEC( v0, c ) \ -do { \ - if (havespec) { \ - r128_color_t *spec = (r128_color_t *)&((v0)->ui[specoffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ - } \ -} while (0) -#define VERT_COPY_SPEC( v0, v1 ) \ -do { \ - if (havespec) { \ - r128_color_t *spec0 = (r128_color_t *)&((v0)->ui[specoffset]); \ - r128_color_t *spec1 = (r128_color_t *)&((v1)->ui[specoffset]); \ - spec0->red = spec1->red; \ - spec0->green = spec1->green; \ - spec0->blue = spec1->blue; \ - } \ -} while (0) - -/* These don't need LE32_TO_CPU() as they are used to save and restore - * colors which are already in the correct format. - */ -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] -#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[specoffset] -#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[specoffset] = spec[idx] - - -#define LOCAL_VARS(n) \ - r128ContextPtr rmesa = R128_CONTEXT(ctx); \ - GLuint color[n] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - GLuint coloroffset = rmesa->coloroffset; \ - GLuint specoffset = rmesa->specoffset; \ - GLboolean havespec = (rmesa->specoffset != 0); \ - (void) color; (void) spec; (void) specoffset; \ - (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 "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 (R128_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (R128_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_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" - -#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_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(); -} - - - -/*********************************************************************** - * 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 ) -{ - struct gl_context *ctx = rmesa->glCtx; - SWvertex v[3]; - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - _swsetup_Translate( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - - -static void -r128_fallback_line( r128ContextPtr rmesa, - r128Vertex *v0, - r128Vertex *v1 ) -{ - struct gl_context *ctx = rmesa->glCtx; - SWvertex v[2]; - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -static void -r128_fallback_point( r128ContextPtr rmesa, - r128Vertex *v0 ) -{ - struct gl_context *ctx = rmesa->glCtx; - SWvertex v[1]; - _swsetup_Translate( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} - - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - r128_point( rmesa, VERT(start) ) -#define RENDER_LINE( v0, v1 ) \ - r128_line( rmesa, VERT(v0), VERT(v1) ) -#define RENDER_TRI( v0, v1, v2 ) \ - r128_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) ) -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - r128_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 vertsize = rmesa->vertex_size; \ - const char *vertptr = (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" - - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - -#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) -#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) -#define _R128_NEW_RENDER_STATE (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS) - -void r128ChooseRenderState(struct gl_context *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_point; - rmesa->draw_line = r128_line; - rmesa->draw_tri = r128_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.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 = r128_render_tab_verts; - tnl->Driver.Render.PrimTabElts = r128_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = r128_fast_clipped_poly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; - } - - rmesa->RenderIndex = index; - } -} - -/**********************************************************************/ -/* Validate state at pipeline start */ -/**********************************************************************/ - -static void r128RunPipeline( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - if (rmesa->new_state || rmesa->NewGLState & _NEW_TEXTURE) - r128DDUpdateHWState( ctx ); - - if (!rmesa->Fallback && rmesa->NewGLState) { - 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. - */ - -static void r128RasterPrimitive( struct gl_context *ctx, GLuint hwprim ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - 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; - } - - 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 r128SetupAntialias( struct gl_context *ctx, GLenum prim ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - - GLuint currAA, wantAA; - - currAA = (rmesa->setup.pm4_vc_fpu_setup & R128_EDGE_ANTIALIAS) != 0; - if( prim >= GL_TRIANGLES ) - wantAA = ctx->Polygon.SmoothFlag; - else if( prim >= GL_LINES ) - wantAA = ctx->Line.SmoothFlag; - else - wantAA = 0; - - if( wantAA != currAA ) - { - FLUSH_BATCH( rmesa ); - rmesa->setup.pm4_vc_fpu_setup ^= R128_EDGE_ANTIALIAS; - rmesa->dirty |= R128_UPLOAD_SETUP; - } -} - -static void r128RenderPrimitive( struct gl_context *ctx, GLenum prim ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint hw = hw_prim[prim]; - rmesa->render_primitive = prim; - - r128SetupAntialias( ctx, prim ); - - if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - r128RasterPrimitive( ctx, hw ); -} - -#define EMIT_ATTR( ATTR, STYLE, VF, SIZE ) \ -do { \ - rmesa->vertex_attrs[rmesa->vertex_attr_count].attrib = (ATTR); \ - rmesa->vertex_attrs[rmesa->vertex_attr_count].format = (STYLE); \ - rmesa->vertex_attr_count++; \ - vc_frmt |= (VF); \ - offset += (SIZE); \ -} while (0) - -#define EMIT_PAD( SIZE ) \ -do { \ - rmesa->vertex_attrs[rmesa->vertex_attr_count].attrib = 0; \ - rmesa->vertex_attrs[rmesa->vertex_attr_count].format = EMIT_PAD; \ - rmesa->vertex_attrs[rmesa->vertex_attr_count].offset = (SIZE); \ - rmesa->vertex_attr_count++; \ - offset += (SIZE); \ -} while (0) - -static void r128RenderStart( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - GLuint vc_frmt = 0; - GLboolean fallback_projtex = GL_FALSE; - GLuint offset = 0; - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - - /* Important: */ - VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; - rmesa->vertex_attr_count = 0; - rmesa->specoffset = 0; - - /* EMIT_ATTR's must be in order as they tell t_vertex.c how to - * build up a hardware vertex. - */ - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, R128_CCE_VC_FRMT_RHW, 4 ); - else - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 3 ); - - rmesa->coloroffset = offset; -#if MESA_LITTLE_ENDIAN - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, - R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 ); -#else - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ARGB, - R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 ); -#endif - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || - RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { -#if MESA_LITTLE_ENDIAN - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { - rmesa->specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, - R128_CCE_VC_FRMT_SPEC_FRGB, 3 ); - } else - EMIT_PAD( 3 ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R128_CCE_VC_FRMT_SPEC_FRGB, - 1 ); - else - EMIT_PAD( 1 ); -#else - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R128_CCE_VC_FRMT_SPEC_FRGB, - 1 ); - else - EMIT_PAD( 1 ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { - rmesa->specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, - R128_CCE_VC_FRMT_SPEC_FRGB, 3 ); - } else - EMIT_PAD( 3 ); -#endif - } - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(rmesa->tmu_source[0]) )) { - if ( VB->AttribPtr[_TNL_ATTRIB_TEX0 + rmesa->tmu_source[0]]->size > 2 ) - fallback_projtex = GL_TRUE; - EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, R128_CCE_VC_FRMT_S_T, 8 ); - } - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(rmesa->tmu_source[1]) )) { - if ( VB->AttribPtr[_TNL_ATTRIB_TEX0 + rmesa->tmu_source[1]]->size > 2 ) - fallback_projtex = GL_TRUE; - EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, R128_CCE_VC_FRMT_S2_T2, 8 ); - } - - /* projective textures are not supported by the hardware */ - FALLBACK( rmesa, R128_FALLBACK_PROJTEX, fallback_projtex ); - - /* Only need to change the vertex emit code if there has been a - * statechange to a TNL index. - */ - if (!RENDERINPUTS_EQUAL( index_bitset, rmesa->tnl_state_bitset )) { - FLUSH_BATCH( rmesa ); - rmesa->dirty |= R128_UPLOAD_CONTEXT; - - rmesa->vertex_size = - _tnl_install_attrs( ctx, - rmesa->vertex_attrs, - rmesa->vertex_attr_count, - rmesa->hw_viewport, 0 ); - rmesa->vertex_size >>= 2; - - rmesa->vertex_format = vc_frmt; - } -} - -static void r128RenderFinish( struct gl_context *ctx ) -{ - if (R128_CONTEXT(ctx)->RenderIndex & R128_FALLBACK_BIT) - _swrast_flush( ctx ); -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - -static const char * const fallbackStrings[] = { - "Texture mode", - "glDrawBuffer(GL_FRONT_AND_BACK)", - "glReadBuffer", - "glEnable(GL_STENCIL) without hw stencil buffer", - "glRenderMode(selection or feedback)", - "glLogicOp (mode != GL_COPY)", - "GL_SEPARATE_SPECULAR_COLOR", - "glBlendEquation(mode != ADD)", - "glBlendFunc", - "Projective texture", - "Rasterization disable", -}; - - -static const char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - -void r128Fallback( struct gl_context *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; - if ( R128_DEBUG & DEBUG_VERBOSE_FALL ) { - fprintf(stderr, "R128 begin rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } - 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 = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_invalidate_vertex_state( ctx, ~0 ); - _tnl_invalidate_vertices( ctx, ~0 ); - _tnl_install_attrs( ctx, - rmesa->vertex_attrs, - rmesa->vertex_attr_count, - rmesa->hw_viewport, 0 ); - - rmesa->NewGLState |= _R128_NEW_RENDER_STATE; - if ( R128_DEBUG & DEBUG_VERBOSE_FALL ) { - fprintf(stderr, "R128 end rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - -void r128InitTriFuncs( struct gl_context *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(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 = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - (6 + 2 * ctx->Const.MaxTextureUnits) * sizeof(GLfloat) ); - rmesa->verts = (char *)tnl->clipspace.vertex_buf; - RENDERINPUTS_ONES( rmesa->tnl_state_bitset ); - - rmesa->NewGLState |= _R128_NEW_RENDER_STATE; -} diff --git a/src/mesa/drivers/dri/r128/r128_tris.h b/src/mesa/drivers/dri/r128/r128_tris.h deleted file mode 100644 index a1394977656..00000000000 --- a/src/mesa/drivers/dri/r128/r128_tris.h +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * - */ - -#ifndef __R128_TRIS_H__ -#define __R128_TRIS_H__ - -#include "main/mtypes.h" - -extern void r128InitTriFuncs( struct gl_context *ctx ); -extern void r128ChooseRenderState( struct gl_context *ctx ); - -extern void r128Fallback( struct gl_context *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( rmesa, bit, mode ) r128Fallback( rmesa->glCtx, bit, mode ) - - -#endif /* __R128_TRIS_H__ */ diff --git a/src/mesa/drivers/dri/r128/server/pci_ids.h b/src/mesa/drivers/dri/r128/server/pci_ids.h deleted file mode 100644 index fe8b0878748..00000000000 --- a/src/mesa/drivers/dri/r128/server/pci_ids.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Rage128 M3 */ -#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45 -#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46 -/* Rage128 M4 */ -#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46 -#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c -/* Rage128 Pro GL */ -#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041 -#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042 -#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043 -#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044 -#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045 -#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046 -/* Rage128 Pro VR */ -#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047 -#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048 -#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049 -#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A -#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B -#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C -#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D -#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E -#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F -#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050 -#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051 -#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052 -#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452 -#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053 -#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054 -#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055 -#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056 -#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057 -#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058 -/* Rage128 GL */ -#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245 -#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246 -/* Rage128 VR */ -#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245 -#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246 -#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247 -#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b -#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c -#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345 -#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346 -#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347 -#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348 -#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b -#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c -#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d -#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e -/* Rage128 Pro Ultra */ -#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446 -#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544C -#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452 -#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453 -#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454 -#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455 diff --git a/src/mesa/drivers/dri/r128/server/r128.h b/src/mesa/drivers/dri/r128/server/r128.h deleted file mode 100644 index 413c7c66908..00000000000 --- a/src/mesa/drivers/dri/r128/server/r128.h +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, - * Precision Insight, Inc., Cedar Park, Texas, 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, 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, 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: - * Rickard E. Faith <[email protected]> - * Kevin E. Martin <[email protected]> - * - */ - -#ifndef _R128_H_ -#define _R128_H_ - -#include "dri_util.h" - -#define R128_DEBUG 0 /* Turn off debugging output */ -#define R128_IDLE_RETRY 32 /* Fall out of idle loops after this count */ -#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ -#define R128_MMIOSIZE 0x4000 - -#define R128_VBIOS_SIZE 0x00010000 - -#if R128_DEBUG -#define R128TRACE(x) \ - do { \ - ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ - ErrorF x; \ - } while (0); -#else -#define R128TRACE(x) -#endif - - -/* Other macros */ -#define R128_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#define R128_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) -#define R128PTR(pScrn) ((R128InfoPtr)(pScrn)->driverPrivate) - -/** - * \brief Chip families. - */ -typedef enum { - CHIP_FAMILY_UNKNOWN, - CHIP_FAMILY_R128_PCI, - CHIP_FAMILY_R128_AGP, -} R128ChipFamily; - -typedef struct { /* All values in XCLKS */ - int ML; /* Memory Read Latency */ - int MB; /* Memory Burst Length */ - int Trcd; /* RAS to CAS delay */ - int Trp; /* RAS percentage */ - int Twr; /* Write Recovery */ - int CL; /* CAS Latency */ - int Tr2w; /* Read to Write Delay */ - int Rloop; /* Loop Latency */ - int Rloop_fudge; /* Add to ML to get Rloop */ - char *name; -} R128RAMRec, *R128RAMPtr; - -typedef struct { - /* Common registers */ - uint32_t ovr_clr; - uint32_t ovr_wid_left_right; - uint32_t ovr_wid_top_bottom; - uint32_t ov0_scale_cntl; - uint32_t mpp_tb_config; - uint32_t mpp_gp_config; - uint32_t subpic_cntl; - uint32_t viph_control; - uint32_t i2c_cntl_1; - uint32_t gen_int_cntl; - uint32_t cap0_trig_cntl; - uint32_t cap1_trig_cntl; - uint32_t bus_cntl; - uint32_t config_cntl; - - /* Other registers to save for VT switches */ - uint32_t dp_datatype; - uint32_t gen_reset_cntl; - uint32_t clock_cntl_index; - uint32_t amcgpio_en_reg; - uint32_t amcgpio_mask; - - /* CRTC registers */ - uint32_t crtc_gen_cntl; - uint32_t crtc_ext_cntl; - uint32_t dac_cntl; - uint32_t crtc_h_total_disp; - uint32_t crtc_h_sync_strt_wid; - uint32_t crtc_v_total_disp; - uint32_t crtc_v_sync_strt_wid; - uint32_t crtc_offset; - uint32_t crtc_offset_cntl; - uint32_t crtc_pitch; - - /* CRTC2 registers */ - uint32_t crtc2_gen_cntl; - - /* Flat panel registers */ - uint32_t fp_crtc_h_total_disp; - uint32_t fp_crtc_v_total_disp; - uint32_t fp_gen_cntl; - uint32_t fp_h_sync_strt_wid; - uint32_t fp_horz_stretch; - uint32_t fp_panel_cntl; - uint32_t fp_v_sync_strt_wid; - uint32_t fp_vert_stretch; - uint32_t lvds_gen_cntl; - uint32_t tmds_crc; - uint32_t tmds_transmitter_cntl; - - /* Computed values for PLL */ - uint32_t dot_clock_freq; - uint32_t pll_output_freq; - int feedback_div; - int post_div; - - /* PLL registers */ - uint32_t ppll_ref_div; - uint32_t ppll_div_3; - uint32_t htotal_cntl; - - /* DDA register */ - uint32_t dda_config; - uint32_t dda_on_off; - - /* Pallet */ - GLboolean palette_valid; - uint32_t palette[256]; -} R128SaveRec, *R128SavePtr; - -typedef struct { - int Chipset; - GLboolean Primary; - - GLboolean FBDev; - - unsigned long LinearAddr; /* Frame buffer physical address */ - unsigned long BIOSAddr; /* BIOS physical address */ - - unsigned char *MMIO; /* Map of MMIO region */ - unsigned char *FB; /* Map of frame buffer */ - - uint32_t MemCntl; - uint32_t BusCntl; - unsigned long FbMapSize; /* Size of frame buffer, in bytes */ - int Flags; /* Saved copy of mode flags */ - - /* Computed values for FPs */ - int PanelXRes; - int PanelYRes; - int HOverPlus; - int HSyncWidth; - int HBlank; - int VOverPlus; - int VSyncWidth; - int VBlank; - int PanelPwrDly; - - unsigned long cursor_start; - unsigned long cursor_end; - - /* - * XAAForceTransBlit is used to change the behavior of the XAA - * SetupForScreenToScreenCopy function, to make it DGA-friendly. - */ - GLboolean XAAForceTransBlit; - - int fifo_slots; /* Free slots in the FIFO (64 max) */ - int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ - GLboolean dac6bits; /* Use 6 bit DAC? */ - - /* Computed values for Rage 128 */ - int pitch; - int datatype; - uint32_t dp_gui_master_cntl; - - /* Saved values for ScreenToScreenCopy */ - int xdir; - int ydir; - - /* ScanlineScreenToScreenColorExpand support */ - unsigned char *scratch_buffer[1]; - unsigned char *scratch_save; - int scanline_x; - int scanline_y; - int scanline_w; - int scanline_h; - - int scanline_hpass; - int scanline_x1clip; - int scanline_x2clip; - int scanline_rop; - int scanline_fg; - int scanline_bg; - - int scanline_words; - int scanline_direct; - int scanline_bpp; /* Only used for ImageWrite */ - - drm_context_t drmCtx; - - drmSize registerSize; - drm_handle_t registerHandle; - - GLboolean IsPCI; /* Current card is a PCI card */ - drmSize pciSize; - drm_handle_t pciMemHandle; - unsigned char *PCI; /* Map */ - - GLboolean allowPageFlip; /* Enable 3d page flipping */ - GLboolean have3DWindows; /* Are there any 3d clients? */ - int drmMinor; - - drmSize agpSize; - drm_handle_t agpMemHandle; /* Handle from drmAgpAlloc */ - unsigned long agpOffset; - unsigned char *AGP; /* Map */ - int agpMode; - - GLboolean CCEInUse; /* CCE is currently active */ - int CCEMode; /* CCE mode that server/clients use */ - int CCEFifoSize; /* Size of the CCE command FIFO */ - GLboolean CCESecure; /* CCE security enabled */ - int CCEusecTimeout; /* CCE timeout in usecs */ - - /* CCE ring buffer data */ - unsigned long ringStart; /* Offset into AGP space */ - drm_handle_t ringHandle; /* Handle from drmAddMap */ - drmSize ringMapSize; /* Size of map */ - int ringSize; /* Size of ring (in MB) */ - unsigned char *ring; /* Map */ - int ringSizeLog2QW; - - unsigned long ringReadOffset; /* Offset into AGP space */ - drm_handle_t ringReadPtrHandle; /* Handle from drmAddMap */ - drmSize ringReadMapSize; /* Size of map */ - unsigned char *ringReadPtr; /* Map */ - - /* CCE vertex/indirect buffer data */ - unsigned long bufStart; /* Offset into AGP space */ - drm_handle_t bufHandle; /* Handle from drmAddMap */ - drmSize bufMapSize; /* Size of map */ - int bufSize; /* Size of buffers (in MB) */ - unsigned char *buf; /* Map */ - int bufNumBufs; /* Number of buffers */ - drmBufMapPtr buffers; /* Buffer map */ - - /* CCE AGP Texture data */ - unsigned long agpTexStart; /* Offset into AGP space */ - drm_handle_t agpTexHandle; /* Handle from drmAddMap */ - drmSize agpTexMapSize; /* Size of map */ - int agpTexSize; /* Size of AGP tex space (in MB) */ - unsigned char *agpTex; /* Map */ - int log2AGPTexGran; - - /* CCE 2D accleration */ - drmBufPtr indirectBuffer; - int indirectStart; - - /* DRI screen private data */ - int fbX; - int fbY; - int backX; - int backY; - int depthX; - int depthY; - - int frontOffset; - int frontPitch; - int backOffset; - int backPitch; - int depthOffset; - int depthPitch; - int spanOffset; - int textureOffset; - int textureSize; - int log2TexGran; - - /* Saved scissor values */ - uint32_t sc_left; - uint32_t sc_right; - uint32_t sc_top; - uint32_t sc_bottom; - - uint32_t re_top_left; - uint32_t re_width_height; - - uint32_t aux_sc_cntl; - - int irq; - uint32_t gen_int_cntl; - - GLboolean DMAForXv; - -} R128InfoRec, *R128InfoPtr; - -#define R128WaitForFifo(pScrn, entries) \ -do { \ - if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \ - info->fifo_slots -= entries; \ -} while (0) - -extern void r128WaitForFifoFunction(const DRIDriverContext *ctx, int entries); -extern void r128WaitForIdle(const DRIDriverContext *ctx); - -extern void r128WaitForVerticalSync(const DRIDriverContext *ctx); - -extern GLboolean r128AccelInit(const DRIDriverContext *ctx); -extern void r128EngineInit(const DRIDriverContext *ctx); -extern GLboolean r128CursorInit(const DRIDriverContext *ctx); -extern GLboolean r128DGAInit(const DRIDriverContext *ctx); - -extern void r128InitVideo(const DRIDriverContext *ctx); - -extern GLboolean r128DRIScreenInit(const DRIDriverContext *ctx); -extern void r128DRICloseScreen(const DRIDriverContext *ctx); -extern GLboolean r128DRIFinishScreenInit(const DRIDriverContext *ctx); - -#define R128CCE_START(ctx, info) \ -do { \ - int _ret = drmCommandNone(ctx->drmFD, DRM_R128_CCE_START); \ - if (_ret) { \ - fprintf(stderr, \ - "%s: CCE start %d\n", __FUNCTION__, _ret); \ - } \ -} while (0) - -#define R128CCE_STOP(ctx, info) \ -do { \ - int _ret = R128CCEStop(ctx); \ - if (_ret) { \ - fprintf(stderr, \ - "%s: CCE stop %d\n", __FUNCTION__, _ret); \ - } \ -} while (0) - -#define R128CCE_RESET(ctx, info) \ -do { \ - if (info->directRenderingEnabled \ - && R128CCE_USE_RING_BUFFER(info->CCEMode)) { \ - int _ret = drmCommandNone(info->drmFD, DRM_R128_CCE_RESET); \ - if (_ret) { \ - fprintf(stderr, \ - "%s: CCE reset %d\n", __FUNCTION__, _ret); \ - } \ - } \ -} while (0) - - -#define CCE_PACKET0( reg, n ) \ - (R128_CCE_PACKET0 | ((n) << 16) | ((reg) >> 2)) -#define CCE_PACKET1( reg0, reg1 ) \ - (R128_CCE_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2)) -#define CCE_PACKET2() \ - (R128_CCE_PACKET2) -#define CCE_PACKET3( pkt, n ) \ - (R128_CCE_PACKET3 | (pkt) | ((n) << 16)) - - -#define R128_VERBOSE 0 - -#define RING_LOCALS uint32_t *__head; int __count; - -#define R128CCE_REFRESH(pScrn, info) \ -do { \ - if ( R128_VERBOSE ) { \ - fprintf(stderr, "REFRESH( %d ) in %s\n", \ - !info->CCEInUse , __FUNCTION__ ); \ - } \ - if ( !info->CCEInUse ) { \ - R128CCEWaitForIdle(pScrn); \ - BEGIN_RING( 6 ); \ - OUT_RING_REG( R128_RE_TOP_LEFT, info->re_top_left ); \ - OUT_RING_REG( R128_RE_WIDTH_HEIGHT, info->re_width_height ); \ - OUT_RING_REG( R128_AUX_SC_CNTL, info->aux_sc_cntl ); \ - ADVANCE_RING(); \ - info->CCEInUse = TRUE; \ - } \ -} while (0) - -#define BEGIN_RING( n ) do { \ - if ( R128_VERBOSE ) { \ - fprintf(stderr, \ - "BEGIN_RING( %d ) in %s\n", n, __FUNCTION__ ); \ - } \ - if ( !info->indirectBuffer ) { \ - info->indirectBuffer = R128CCEGetBuffer( pScrn ); \ - info->indirectStart = 0; \ - } else if ( (info->indirectBuffer->used + 4*(n)) > \ - info->indirectBuffer->total ) { \ - R128CCEFlushIndirect( pScrn, 1 ); \ - } \ - __head = (pointer)((char *)info->indirectBuffer->address + \ - info->indirectBuffer->used); \ - __count = 0; \ -} while (0) - -#define ADVANCE_RING() do { \ - if ( R128_VERBOSE ) { \ - fprintf(stderr, \ - "ADVANCE_RING() used: %d+%d=%d/%d\n", \ - info->indirectBuffer->used - info->indirectStart, \ - __count * sizeof(uint32_t), \ - info->indirectBuffer->used - info->indirectStart + \ - __count * sizeof(uint32_t), \ - info->indirectBuffer->total - info->indirectStart ); \ - } \ - info->indirectBuffer->used += __count * (int)sizeof(uint32_t); \ -} while (0) - -#define OUT_RING( x ) do { \ - if ( R128_VERBOSE ) { \ - fprintf(stderr, \ - " OUT_RING( 0x%08x )\n", (unsigned int)(x) ); \ - } \ - MMIO_OUT32(&__head[__count++], 0, (x)); \ -} while (0) - -#define OUT_RING_REG( reg, val ) \ -do { \ - OUT_RING( CCE_PACKET0( reg, 0 ) ); \ - OUT_RING( val ); \ -} while (0) - -#define FLUSH_RING() \ -do { \ - if ( R128_VERBOSE ) \ - fprintf(stderr, \ - "FLUSH_RING in %s\n", __FUNCTION__ ); \ - if ( info->indirectBuffer ) { \ - R128CCEFlushIndirect( pScrn, 0 ); \ - } \ -} while (0) - - -#endif diff --git a/src/mesa/drivers/dri/r128/server/r128_dri.h b/src/mesa/drivers/dri/r128/server/r128_dri.h deleted file mode 100644 index 430e5f580bd..00000000000 --- a/src/mesa/drivers/dri/r128/server/r128_dri.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, - * Precision Insight, Inc., Cedar Park, Texas, 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, 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, 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 <[email protected]> - * Rickard E. Faith <[email protected]> - * Gareth Hughes <[email protected]> - * - */ - -#ifndef _R128_DRI_ -#define _R128_DRI_ - -#include "xf86drm.h" -#include "drm.h" - -/* DRI Driver defaults */ -#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM -#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM -#define R128_DEFAULT_AGP_MODE 1 -#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */ -#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */ -#define R128_DEFAULT_BUFFER_SIZE 2 /* MB (must be page aligned) */ -#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */ - -#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */ - -#define R128_AGP_MAX_MODE 4 -#define R128_BUFFER_ALIGN 0x00000fff - -#define R128_CARD_TYPE_R128 1 -#define R128_CARD_TYPE_R128_PRO 2 -#define R128_CARD_TYPE_R128_MOBILITY 3 - -#define R128CCE_USE_RING_BUFFER(m) \ -(((m) == R128_PM4_192BM) || \ - ((m) == R128_PM4_128BM_64INDBM) || \ - ((m) == R128_PM4_64BM_128INDBM) || \ - ((m) == R128_PM4_64BM_64VCBM_64INDBM)) - -typedef struct { - /* DRI screen private data */ - int deviceID; /* PCI device ID */ - int width; /* Width in pixels of display */ - int height; /* Height in scanlines of display */ - int depth; /* Depth of display (8, 15, 16, 24) */ - int bpp; /* Bit depth of display (8, 16, 24, 32) */ - - int IsPCI; /* Current card is a PCI card */ - int AGPMode; - - int frontOffset; /* Start of front buffer */ - int frontPitch; - int backOffset; /* Start of shared back buffer */ - int backPitch; - int depthOffset; /* Start of shared depth buffer */ - int depthPitch; - int spanOffset; /* Start of scratch spanline */ - int textureOffset;/* Start of texture data in frame buffer */ - int textureSize; - int log2TexGran; - - /* MMIO register data */ - drm_handle_t registerHandle; - drmSize registerSize; - - /* CCE AGP Texture data */ - drm_handle_t agpTexHandle; - drmSize agpTexMapSize; - int log2AGPTexGran; - int agpTexOffset; - unsigned int sarea_priv_offset; -} R128DRIRec, *R128DRIPtr; - -#endif diff --git a/src/mesa/drivers/dri/r128/server/r128_macros.h b/src/mesa/drivers/dri/r128/server/r128_macros.h deleted file mode 100644 index f7b945da93f..00000000000 --- a/src/mesa/drivers/dri/r128/server/r128_macros.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * \file server/R128_macros.h - * \brief Macros for R128 MMIO operation. - * - * \authors Kevin E. Martin <[email protected]> - * \authors Rickard E. Faith <[email protected]> - * \authors Alan Hourihane <[email protected]> - */ - -/* - * Copyright 2000 ATI Technologies Inc., Markham, Ontario, 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, 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR - * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _R128_MACROS_H_ -#define _R128_MACROS_H_ - - - -# define MMIO_IN8(base, offset) \ - *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) -# define MMIO_IN16(base, offset) \ - *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset)) -# define MMIO_IN32(base, offset) \ - *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) -# define MMIO_OUT8(base, offset, val) \ - *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val) -# define MMIO_OUT16(base, offset, val) \ - *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset)) = (val) -# define MMIO_OUT32(base, offset, val) \ - *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = (val) - - - /* Memory mapped register access macros */ -#define INREG8(addr) MMIO_IN8(R128MMIO, addr) -#define INREG16(addr) MMIO_IN16(R128MMIO, addr) -#define INREG(addr) MMIO_IN32(R128MMIO, addr) -#define OUTREG8(addr, val) MMIO_OUT8(R128MMIO, addr, val) -#define OUTREG16(addr, val) MMIO_OUT16(R128MMIO, addr, val) -#define OUTREG(addr, val) MMIO_OUT32(R128MMIO, addr, val) - -#define ADDRREG(addr) ((volatile GLuint *)(pointer)(R128MMIO + (addr))) - - -#define OUTREGP(addr, val, mask) \ -do { \ - GLuint tmp = INREG(addr); \ - tmp &= (mask); \ - tmp |= (val); \ - OUTREG(addr, tmp); \ -} while (0) - -#define INPLL(dpy, addr) r128INPLL(dpy, addr) - -#define OUTPLL(addr, val) \ -do { \ - OUTREG8(R128_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \ - R128_PLL_WR_EN)); \ - OUTREG(R128_CLOCK_CNTL_DATA, val); \ -} while (0) - -#define OUTPLLP(dpy, addr, val, mask) \ -do { \ - GLuint tmp = INPLL(dpy, addr); \ - tmp &= (mask); \ - tmp |= (val); \ - OUTPLL(addr, tmp); \ -} while (0) - -#define OUTPAL_START(idx) \ -do { \ - OUTREG8(R128_PALETTE_INDEX, (idx)); \ -} while (0) - -#define OUTPAL_NEXT(r, g, b) \ -do { \ - OUTREG(R128_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \ -} while (0) - -#define OUTPAL_NEXT_CARD32(v) \ -do { \ - OUTREG(R128_PALETTE_DATA, (v & 0x00ffffff)); \ -} while (0) - -#define OUTPAL(idx, r, g, b) \ -do { \ - OUTPAL_START((idx)); \ - OUTPAL_NEXT((r), (g), (b)); \ -} while (0) - -#define INPAL_START(idx) \ -do { \ - OUTREG(R128_PALETTE_INDEX, (idx) << 16); \ -} while (0) - -#define INPAL_NEXT() INREG(R128_PALETTE_DATA) - -#define PAL_SELECT(idx) \ -do { \ - if (!idx) { \ - OUTREG(R128_DAC_CNTL2, INREG(R128_DAC_CNTL2) & \ - (GLuint)~R128_DAC2_PALETTE_ACC_CTL); \ - } else { \ - OUTREG(R128_DAC_CNTL2, INREG(R128_DAC_CNTL2) | \ - R128_DAC2_PALETTE_ACC_CTL); \ - } \ -} while (0) - - -#endif diff --git a/src/mesa/drivers/dri/r128/server/r128_reg.h b/src/mesa/drivers/dri/r128/server/r128_reg.h deleted file mode 100644 index 50033540b9d..00000000000 --- a/src/mesa/drivers/dri/r128/server/r128_reg.h +++ /dev/null @@ -1,1403 +0,0 @@ -/* - * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, - * Precision Insight, Inc., Cedar Park, Texas, 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, 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, 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: - * Rickard E. Faith <[email protected]> - * Kevin E. Martin <[email protected]> - * Gareth Hughes <[email protected]> - * - * References: - * - * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical - * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April - * 1999. - * - * RAGE 128 Software Development Manual (Technical Reference Manual P/N - * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. - * - */ - -#ifndef _R128_REG_H_ -#define _R128_REG_H_ - -#define R128_ADAPTER_ID 0x0f2c /* PCI */ -#define R128_AGP_APER_OFFSET 0x0178 -#define R128_AGP_BASE 0x0170 -#define R128_AGP_CNTL 0x0174 -# define R128_AGP_APER_SIZE_256MB (0x00 << 0) -# define R128_AGP_APER_SIZE_128MB (0x20 << 0) -# define R128_AGP_APER_SIZE_64MB (0x30 << 0) -# define R128_AGP_APER_SIZE_32MB (0x38 << 0) -# define R128_AGP_APER_SIZE_16MB (0x3c << 0) -# define R128_AGP_APER_SIZE_8MB (0x3e << 0) -# define R128_AGP_APER_SIZE_4MB (0x3f << 0) -# define R128_AGP_APER_SIZE_MASK (0x3f << 0) -#define R128_AGP_CNTL_B 0x0b44 -#define R128_AGP_COMMAND 0x0f58 /* PCI */ -#define R128_AGP_PLL_CNTL 0x0010 /* PLL */ -#define R128_AGP_STATUS 0x0f54 /* PCI */ -# define R128_AGP_1X_MODE 0x01 -# define R128_AGP_2X_MODE 0x02 -# define R128_AGP_4X_MODE 0x04 -# define R128_AGP_MODE_MASK 0x07 -#define R128_AMCGPIO_A_REG 0x01a0 -#define R128_AMCGPIO_EN_REG 0x01a8 -#define R128_AMCGPIO_MASK 0x0194 -#define R128_AMCGPIO_Y_REG 0x01a4 -#define R128_ATTRDR 0x03c1 /* VGA */ -#define R128_ATTRDW 0x03c0 /* VGA */ -#define R128_ATTRX 0x03c0 /* VGA */ -#define R128_AUX_SC_CNTL 0x1660 -# define R128_AUX1_SC_EN (1 << 0) -# define R128_AUX1_SC_MODE_OR (0 << 1) -# define R128_AUX1_SC_MODE_NAND (1 << 1) -# define R128_AUX2_SC_EN (1 << 2) -# define R128_AUX2_SC_MODE_OR (0 << 3) -# define R128_AUX2_SC_MODE_NAND (1 << 3) -# define R128_AUX3_SC_EN (1 << 4) -# define R128_AUX3_SC_MODE_OR (0 << 5) -# define R128_AUX3_SC_MODE_NAND (1 << 5) -#define R128_AUX1_SC_BOTTOM 0x1670 -#define R128_AUX1_SC_LEFT 0x1664 -#define R128_AUX1_SC_RIGHT 0x1668 -#define R128_AUX1_SC_TOP 0x166c -#define R128_AUX2_SC_BOTTOM 0x1680 -#define R128_AUX2_SC_LEFT 0x1674 -#define R128_AUX2_SC_RIGHT 0x1678 -#define R128_AUX2_SC_TOP 0x167c -#define R128_AUX3_SC_BOTTOM 0x1690 -#define R128_AUX3_SC_LEFT 0x1684 -#define R128_AUX3_SC_RIGHT 0x1688 -#define R128_AUX3_SC_TOP 0x168c -#define R128_AUX_WINDOW_HORZ_CNTL 0x02d8 -#define R128_AUX_WINDOW_VERT_CNTL 0x02dc - -#define R128_BASE_CODE 0x0f0b -#define R128_BIOS_0_SCRATCH 0x0010 -#define R128_BIOS_1_SCRATCH 0x0014 -#define R128_BIOS_2_SCRATCH 0x0018 -#define R128_BIOS_3_SCRATCH 0x001c -#define R128_BIOS_4_SCRATCH 0x0020 -#define R128_BIOS_5_SCRATCH 0x0024 -# define R128_BIOS_DISPLAY_FP (1 << 0) -# define R128_BIOS_DISPLAY_CRT (2 << 0) -# define R128_BIOS_DISPLAY_FP_CRT (3 << 0) -#define R128_BIOS_6_SCRATCH 0x0028 -#define R128_BIOS_7_SCRATCH 0x002c -#define R128_BIOS_ROM 0x0f30 /* PCI */ -#define R128_BIST 0x0f0f /* PCI */ -#define R128_BM_CHUNK_0_VAL 0x0a18 -# define R128_BM_PTR_FORCE_TO_PCI (1 << 21) -# define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22) -# define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23) -#define R128_BRUSH_DATA0 0x1480 -#define R128_BRUSH_DATA1 0x1484 -#define R128_BRUSH_DATA10 0x14a8 -#define R128_BRUSH_DATA11 0x14ac -#define R128_BRUSH_DATA12 0x14b0 -#define R128_BRUSH_DATA13 0x14b4 -#define R128_BRUSH_DATA14 0x14b8 -#define R128_BRUSH_DATA15 0x14bc -#define R128_BRUSH_DATA16 0x14c0 -#define R128_BRUSH_DATA17 0x14c4 -#define R128_BRUSH_DATA18 0x14c8 -#define R128_BRUSH_DATA19 0x14cc -#define R128_BRUSH_DATA2 0x1488 -#define R128_BRUSH_DATA20 0x14d0 -#define R128_BRUSH_DATA21 0x14d4 -#define R128_BRUSH_DATA22 0x14d8 -#define R128_BRUSH_DATA23 0x14dc -#define R128_BRUSH_DATA24 0x14e0 -#define R128_BRUSH_DATA25 0x14e4 -#define R128_BRUSH_DATA26 0x14e8 -#define R128_BRUSH_DATA27 0x14ec -#define R128_BRUSH_DATA28 0x14f0 -#define R128_BRUSH_DATA29 0x14f4 -#define R128_BRUSH_DATA3 0x148c -#define R128_BRUSH_DATA30 0x14f8 -#define R128_BRUSH_DATA31 0x14fc -#define R128_BRUSH_DATA32 0x1500 -#define R128_BRUSH_DATA33 0x1504 -#define R128_BRUSH_DATA34 0x1508 -#define R128_BRUSH_DATA35 0x150c -#define R128_BRUSH_DATA36 0x1510 -#define R128_BRUSH_DATA37 0x1514 -#define R128_BRUSH_DATA38 0x1518 -#define R128_BRUSH_DATA39 0x151c -#define R128_BRUSH_DATA4 0x1490 -#define R128_BRUSH_DATA40 0x1520 -#define R128_BRUSH_DATA41 0x1524 -#define R128_BRUSH_DATA42 0x1528 -#define R128_BRUSH_DATA43 0x152c -#define R128_BRUSH_DATA44 0x1530 -#define R128_BRUSH_DATA45 0x1534 -#define R128_BRUSH_DATA46 0x1538 -#define R128_BRUSH_DATA47 0x153c -#define R128_BRUSH_DATA48 0x1540 -#define R128_BRUSH_DATA49 0x1544 -#define R128_BRUSH_DATA5 0x1494 -#define R128_BRUSH_DATA50 0x1548 -#define R128_BRUSH_DATA51 0x154c -#define R128_BRUSH_DATA52 0x1550 -#define R128_BRUSH_DATA53 0x1554 -#define R128_BRUSH_DATA54 0x1558 -#define R128_BRUSH_DATA55 0x155c -#define R128_BRUSH_DATA56 0x1560 -#define R128_BRUSH_DATA57 0x1564 -#define R128_BRUSH_DATA58 0x1568 -#define R128_BRUSH_DATA59 0x156c -#define R128_BRUSH_DATA6 0x1498 -#define R128_BRUSH_DATA60 0x1570 -#define R128_BRUSH_DATA61 0x1574 -#define R128_BRUSH_DATA62 0x1578 -#define R128_BRUSH_DATA63 0x157c -#define R128_BRUSH_DATA7 0x149c -#define R128_BRUSH_DATA8 0x14a0 -#define R128_BRUSH_DATA9 0x14a4 -#define R128_BRUSH_SCALE 0x1470 -#define R128_BRUSH_Y_X 0x1474 -#define R128_BUS_CNTL 0x0030 -# define R128_BUS_MASTER_DIS (1 << 6) -# define R128_BUS_RD_DISCARD_EN (1 << 24) -# define R128_BUS_RD_ABORT_EN (1 << 25) -# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28) -# define R128_BUS_WRT_BURST (1 << 29) -# define R128_BUS_READ_BURST (1 << 30) -#define R128_BUS_CNTL1 0x0034 -# define R128_BUS_WAIT_ON_LOCK_EN (1 << 4) - -#define R128_CACHE_CNTL 0x1724 -#define R128_CACHE_LINE 0x0f0c /* PCI */ -#define R128_CAP0_TRIG_CNTL 0x0950 /* ? */ -#define R128_CAP1_TRIG_CNTL 0x09c0 /* ? */ -#define R128_CAPABILITIES_ID 0x0f50 /* PCI */ -#define R128_CAPABILITIES_PTR 0x0f34 /* PCI */ -#define R128_CLK_PIN_CNTL 0x0001 /* PLL */ -#define R128_CLOCK_CNTL_DATA 0x000c -#define R128_CLOCK_CNTL_INDEX 0x0008 -# define R128_PLL_WR_EN (1 << 7) -# define R128_PLL_DIV_SEL (3 << 8) -#define R128_CLR_CMP_CLR_3D 0x1a24 -#define R128_CLR_CMP_CLR_DST 0x15c8 -#define R128_CLR_CMP_CLR_SRC 0x15c4 -#define R128_CLR_CMP_CNTL 0x15c0 -# define R128_SRC_CMP_EQ_COLOR (4 << 0) -# define R128_SRC_CMP_NEQ_COLOR (5 << 0) -# define R128_CLR_CMP_SRC_SOURCE (1 << 24) -#define R128_CLR_CMP_MASK 0x15cc -# define R128_CLR_CMP_MSK 0xffffffff -#define R128_CLR_CMP_MASK_3D 0x1A28 -#define R128_COMMAND 0x0f04 /* PCI */ -#define R128_COMPOSITE_SHADOW_ID 0x1a0c -#define R128_CONFIG_APER_0_BASE 0x0100 -#define R128_CONFIG_APER_1_BASE 0x0104 -#define R128_CONFIG_APER_SIZE 0x0108 -#define R128_CONFIG_BONDS 0x00e8 -#define R128_CONFIG_CNTL 0x00e0 -# define APER_0_BIG_ENDIAN_16BPP_SWAP (1 << 0) -# define APER_0_BIG_ENDIAN_32BPP_SWAP (2 << 0) -#define R128_CONFIG_MEMSIZE 0x00f8 -#define R128_CONFIG_MEMSIZE_EMBEDDED 0x0114 -#define R128_CONFIG_REG_1_BASE 0x010c -#define R128_CONFIG_REG_APER_SIZE 0x0110 -#define R128_CONFIG_XSTRAP 0x00e4 -#define R128_CONSTANT_COLOR_C 0x1d34 -# define R128_CONSTANT_COLOR_MASK 0x00ffffff -# define R128_CONSTANT_COLOR_ONE 0x00ffffff -# define R128_CONSTANT_COLOR_ZERO 0x00000000 -#define R128_CRC_CMDFIFO_ADDR 0x0740 -#define R128_CRC_CMDFIFO_DOUT 0x0744 -#define R128_CRTC_CRNT_FRAME 0x0214 -#define R128_CRTC_DEBUG 0x021c -#define R128_CRTC_EXT_CNTL 0x0054 -# define R128_CRTC_VGA_XOVERSCAN (1 << 0) -# define R128_VGA_ATI_LINEAR (1 << 3) -# define R128_XCRT_CNT_EN (1 << 6) -# define R128_CRTC_HSYNC_DIS (1 << 8) -# define R128_CRTC_VSYNC_DIS (1 << 9) -# define R128_CRTC_DISPLAY_DIS (1 << 10) -# define R128_CRTC_CRT_ON (1 << 15) -# define R128_FP_OUT_EN (1 << 22) -# define R128_FP_ACTIVE (1 << 23) -#define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 -# define R128_CRTC_HSYNC_DIS_BYTE (1 << 0) -# define R128_CRTC_VSYNC_DIS_BYTE (1 << 1) -# define R128_CRTC_DISPLAY_DIS_BYTE (1 << 2) -#define R128_CRTC_GEN_CNTL 0x0050 -# define R128_CRTC_DBL_SCAN_EN (1 << 0) -# define R128_CRTC_INTERLACE_EN (1 << 1) -# define R128_CRTC_CSYNC_EN (1 << 4) -# define R128_CRTC_CUR_EN (1 << 16) -# define R128_CRTC_CUR_MODE_MASK (7 << 17) -# define R128_CRTC_ICON_EN (1 << 20) -# define R128_CRTC_EXT_DISP_EN (1 << 24) -# define R128_CRTC_EN (1 << 25) -# define R128_CRTC_DISP_REQ_EN_B (1 << 26) -#define R128_CRTC_GUI_TRIG_VLINE 0x0218 -#define R128_CRTC_H_SYNC_STRT_WID 0x0204 -# define R128_CRTC_H_SYNC_STRT_PIX (0x07 << 0) -# define R128_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) -# define R128_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 -# define R128_CRTC_H_SYNC_WID (0x3f << 16) -# define R128_CRTC_H_SYNC_WID_SHIFT 16 -# define R128_CRTC_H_SYNC_POL (1 << 23) -#define R128_CRTC_H_TOTAL_DISP 0x0200 -# define R128_CRTC_H_TOTAL (0x01ff << 0) -# define R128_CRTC_H_TOTAL_SHIFT 0 -# define R128_CRTC_H_DISP (0x00ff << 16) -# define R128_CRTC_H_DISP_SHIFT 16 -#define R128_CRTC_OFFSET 0x0224 -#define R128_CRTC_OFFSET_CNTL 0x0228 -#define R128_CRTC_PITCH 0x022c -#define R128_CRTC_STATUS 0x005c -# define R128_CRTC_VBLANK_SAVE (1 << 1) -#define R128_CRTC_V_SYNC_STRT_WID 0x020c -# define R128_CRTC_V_SYNC_STRT (0x7ff << 0) -# define R128_CRTC_V_SYNC_STRT_SHIFT 0 -# define R128_CRTC_V_SYNC_WID (0x1f << 16) -# define R128_CRTC_V_SYNC_WID_SHIFT 16 -# define R128_CRTC_V_SYNC_POL (1 << 23) -#define R128_CRTC_V_TOTAL_DISP 0x0208 -# define R128_CRTC_V_TOTAL (0x07ff << 0) -# define R128_CRTC_V_TOTAL_SHIFT 0 -# define R128_CRTC_V_DISP (0x07ff << 16) -# define R128_CRTC_V_DISP_SHIFT 16 -#define R128_CRTC_VLINE_CRNT_VLINE 0x0210 -# define R128_CRTC_CRNT_VLINE_MASK (0x7ff << 16) -#define R128_CRTC2_CRNT_FRAME 0x0314 -#define R128_CRTC2_DEBUG 0x031c -#define R128_CRTC2_GEN_CNTL 0x03f8 -#define R128_CRTC2_GUI_TRIG_VLINE 0x0318 -#define R128_CRTC2_H_SYNC_STRT_WID 0x0304 -#define R128_CRTC2_H_TOTAL_DISP 0x0300 -#define R128_CRTC2_OFFSET 0x0324 -#define R128_CRTC2_OFFSET_CNTL 0x0328 -#define R128_CRTC2_PITCH 0x032c -#define R128_CRTC2_STATUS 0x03fc -#define R128_CRTC2_V_SYNC_STRT_WID 0x030c -#define R128_CRTC2_V_TOTAL_DISP 0x0308 -#define R128_CRTC2_VLINE_CRNT_VLINE 0x0310 -#define R128_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ -#define R128_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ -#define R128_CUR_CLR0 0x026c -#define R128_CUR_CLR1 0x0270 -#define R128_CUR_HORZ_VERT_OFF 0x0268 -#define R128_CUR_HORZ_VERT_POSN 0x0264 -#define R128_CUR_OFFSET 0x0260 -# define R128_CUR_LOCK (1 << 31) - -#define R128_DAC_CNTL 0x0058 -# define R128_DAC_RANGE_CNTL (3 << 0) -# define R128_DAC_BLANKING (1 << 2) -# define R128_DAC_CRT_SEL_CRTC2 (1 << 4) -# define R128_DAC_PALETTE_ACC_CTL (1 << 5) -# define R128_DAC_8BIT_EN (1 << 8) -# define R128_DAC_VGA_ADR_EN (1 << 13) -# define R128_DAC_MASK_ALL (0xff << 24) -#define R128_DAC_CRC_SIG 0x02cc -#define R128_DAC_DATA 0x03c9 /* VGA */ -#define R128_DAC_MASK 0x03c6 /* VGA */ -#define R128_DAC_R_INDEX 0x03c7 /* VGA */ -#define R128_DAC_W_INDEX 0x03c8 /* VGA */ -#define R128_DDA_CONFIG 0x02e0 -#define R128_DDA_ON_OFF 0x02e4 -#define R128_DEFAULT_OFFSET 0x16e0 -#define R128_DEFAULT_PITCH 0x16e4 -#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 -# define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) -# define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) -#define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820 -#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824 -#define R128_DEVICE_ID 0x0f02 /* PCI */ -#define R128_DP_BRUSH_BKGD_CLR 0x1478 -#define R128_DP_BRUSH_FRGD_CLR 0x147c -#define R128_DP_CNTL 0x16c0 -# define R128_DST_X_LEFT_TO_RIGHT (1 << 0) -# define R128_DST_Y_TOP_TO_BOTTOM (1 << 1) -#define R128_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0 -# define R128_DST_Y_MAJOR (1 << 2) -# define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) -# define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) -#define R128_DP_DATATYPE 0x16c4 -# define R128_HOST_BIG_ENDIAN_EN (1 << 29) -#define R128_DP_GUI_MASTER_CNTL 0x146c -# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) -# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) -# define R128_GMC_SRC_CLIPPING (1 << 2) -# define R128_GMC_DST_CLIPPING (1 << 3) -# define R128_GMC_BRUSH_DATATYPE_MASK (0x0f << 4) -# define R128_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4) -# define R128_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4) -# define R128_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4) -# define R128_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4) -# define R128_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4) -# define R128_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4) -# define R128_GMC_BRUSH_32x32_MONO_FG_BG (8 << 4) -# define R128_GMC_BRUSH_32x32_MONO_FG_LA (9 << 4) -# define R128_GMC_BRUSH_8x8_COLOR (10 << 4) -# define R128_GMC_BRUSH_1X8_COLOR (12 << 4) -# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) -# define R128_GMC_BRUSH_NONE (15 << 4) -# define R128_GMC_DST_8BPP_CI (2 << 8) -# define R128_GMC_DST_15BPP (3 << 8) -# define R128_GMC_DST_16BPP (4 << 8) -# define R128_GMC_DST_24BPP (5 << 8) -# define R128_GMC_DST_32BPP (6 << 8) -# define R128_GMC_DST_8BPP_RGB (7 << 8) -# define R128_GMC_DST_Y8 (8 << 8) -# define R128_GMC_DST_RGB8 (9 << 8) -# define R128_GMC_DST_VYUY (11 << 8) -# define R128_GMC_DST_YVYU (12 << 8) -# define R128_GMC_DST_AYUV444 (14 << 8) -# define R128_GMC_DST_ARGB4444 (15 << 8) -# define R128_GMC_DST_DATATYPE_MASK (0x0f << 8) -# define R128_GMC_DST_DATATYPE_SHIFT 8 -# define R128_GMC_SRC_DATATYPE_MASK (3 << 12) -# define R128_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12) -# define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) -# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) -# define R128_GMC_BYTE_PIX_ORDER (1 << 14) -# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14) -# define R128_GMC_BYTE_LSB_TO_MSB (1 << 14) -# define R128_GMC_CONVERSION_TEMP (1 << 15) -# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15) -# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15) -# define R128_GMC_ROP3_MASK (0xff << 16) -# define R128_DP_SRC_SOURCE_MASK (7 << 24) -# define R128_DP_SRC_SOURCE_MEMORY (2 << 24) -# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24) -# define R128_GMC_3D_FCN_EN (1 << 27) -# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) -# define R128_GMC_AUX_CLIP_DIS (1 << 29) -# define R128_GMC_WR_MSK_DIS (1 << 30) -# define R128_GMC_LD_BRUSH_Y_X (1 << 31) -# define R128_ROP3_ZERO 0x00000000 -# define R128_ROP3_DSa 0x00880000 -# define R128_ROP3_SDna 0x00440000 -# define R128_ROP3_S 0x00cc0000 -# define R128_ROP3_DSna 0x00220000 -# define R128_ROP3_D 0x00aa0000 -# define R128_ROP3_DSx 0x00660000 -# define R128_ROP3_DSo 0x00ee0000 -# define R128_ROP3_DSon 0x00110000 -# define R128_ROP3_DSxn 0x00990000 -# define R128_ROP3_Dn 0x00550000 -# define R128_ROP3_SDno 0x00dd0000 -# define R128_ROP3_Sn 0x00330000 -# define R128_ROP3_DSno 0x00bb0000 -# define R128_ROP3_DSan 0x00770000 -# define R128_ROP3_ONE 0x00ff0000 -# define R128_ROP3_DPa 0x00a00000 -# define R128_ROP3_PDna 0x00500000 -# define R128_ROP3_P 0x00f00000 -# define R128_ROP3_DPna 0x000a0000 -# define R128_ROP3_D 0x00aa0000 -# define R128_ROP3_DPx 0x005a0000 -# define R128_ROP3_DPo 0x00fa0000 -# define R128_ROP3_DPon 0x00050000 -# define R128_ROP3_PDxn 0x00a50000 -# define R128_ROP3_PDno 0x00f50000 -# define R128_ROP3_Pn 0x000f0000 -# define R128_ROP3_DPno 0x00af0000 -# define R128_ROP3_DPan 0x005f0000 - - -#define R128_DP_GUI_MASTER_CNTL_C 0x1c84 -#define R128_DP_MIX 0x16c8 -#define R128_DP_SRC_BKGD_CLR 0x15dc -#define R128_DP_SRC_FRGD_CLR 0x15d8 -#define R128_DP_WRITE_MASK 0x16cc -#define R128_DST_BRES_DEC 0x1630 -#define R128_DST_BRES_ERR 0x1628 -#define R128_DST_BRES_INC 0x162c -#define R128_DST_BRES_LNTH 0x1634 -#define R128_DST_BRES_LNTH_SUB 0x1638 -#define R128_DST_HEIGHT 0x1410 -#define R128_DST_HEIGHT_WIDTH 0x143c -#define R128_DST_HEIGHT_WIDTH_8 0x158c -#define R128_DST_HEIGHT_WIDTH_BW 0x15b4 -#define R128_DST_HEIGHT_Y 0x15a0 -#define R128_DST_OFFSET 0x1404 -#define R128_DST_PITCH 0x1408 -#define R128_DST_PITCH_OFFSET 0x142c -#define R128_DST_PITCH_OFFSET_C 0x1c80 -# define R128_PITCH_SHIFT 21 -# define R128_DST_TILE (1 << 31) -#define R128_DST_WIDTH 0x140c -#define R128_DST_WIDTH_HEIGHT 0x1598 -#define R128_DST_WIDTH_X 0x1588 -#define R128_DST_WIDTH_X_INCY 0x159c -#define R128_DST_X 0x141c -#define R128_DST_X_SUB 0x15a4 -#define R128_DST_X_Y 0x1594 -#define R128_DST_Y 0x1420 -#define R128_DST_Y_SUB 0x15a8 -#define R128_DST_Y_X 0x1438 - -#define R128_EXT_MEM_CNTL 0x0144 - -#define R128_FCP_CNTL 0x0012 /* PLL */ -#define R128_FLUSH_1 0x1704 -#define R128_FLUSH_2 0x1708 -#define R128_FLUSH_3 0x170c -#define R128_FLUSH_4 0x1710 -#define R128_FLUSH_5 0x1714 -#define R128_FLUSH_6 0x1718 -#define R128_FLUSH_7 0x171c -#define R128_FOG_3D_TABLE_START 0x1810 -#define R128_FOG_3D_TABLE_END 0x1814 -#define R128_FOG_3D_TABLE_DENSITY 0x181c -#define R128_FOG_TABLE_INDEX 0x1a14 -#define R128_FOG_TABLE_DATA 0x1a18 -#define R128_FP_CRTC_H_TOTAL_DISP 0x0250 -#define R128_FP_CRTC_V_TOTAL_DISP 0x0254 -#define R128_FP_GEN_CNTL 0x0284 -# define R128_FP_FPON (1 << 0) -# define R128_FP_BLANK_DIS (1 << 1) -# define R128_FP_TDMS_EN (1 << 2) -# define R128_FP_DETECT_SENSE (1 << 8) -# define R128_FP_SEL_CRTC2 (1 << 13) -# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) -# define R128_FP_CRTC_DONT_SHADOW_HEND (1 << 17) -# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18) -# define R128_FP_CRTC_USE_SHADOW_ROWCUR (1 << 19) -# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20) -# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) -# define R128_FP_CRT_SYNC_SEL (1 << 23) -# define R128_FP_USE_SHADOW_EN (1 << 24) -#define R128_FP_H_SYNC_STRT_WID 0x02c4 -#define R128_FP_HORZ_STRETCH 0x028c -# define R128_HORZ_STRETCH_RATIO_MASK 0xffff -# define R128_HORZ_STRETCH_RATIO_SHIFT 0 -# define R128_HORZ_STRETCH_RATIO_MAX 4096 -# define R128_HORZ_PANEL_SIZE (0xff << 16) -# define R128_HORZ_PANEL_SHIFT 16 -# define R128_AUTO_HORZ_RATIO (0 << 24) -# define R128_HORZ_STRETCH_PIXREP (0 << 25) -# define R128_HORZ_STRETCH_BLEND (1 << 25) -# define R128_HORZ_STRETCH_ENABLE (1 << 26) -# define R128_HORZ_FP_LOOP_STRETCH (0x7 << 27) -# define R128_HORZ_STRETCH_RESERVED (1 << 30) -# define R128_HORZ_AUTO_RATIO_FIX_EN (1 << 31) - -#define R128_FP_PANEL_CNTL 0x0288 -# define R128_FP_DIGON (1 << 0) -# define R128_FP_BLON (1 << 1) -#define R128_FP_V_SYNC_STRT_WID 0x02c8 -#define R128_FP_VERT_STRETCH 0x0290 -# define R128_VERT_PANEL_SIZE (0x7ff << 0) -# define R128_VERT_PANEL_SHIFT 0 -# define R128_VERT_STRETCH_RATIO_MASK 0x3ff -# define R128_VERT_STRETCH_RATIO_SHIFT 11 -# define R128_VERT_STRETCH_RATIO_MAX 1024 -# define R128_VERT_STRETCH_ENABLE (1 << 24) -# define R128_VERT_STRETCH_LINEREP (0 << 25) -# define R128_VERT_STRETCH_BLEND (1 << 25) -# define R128_VERT_AUTO_RATIO_EN (1 << 26) -# define R128_VERT_STRETCH_RESERVED 0xf8e00000 - -#define R128_GEN_INT_CNTL 0x0040 -#define R128_GEN_INT_STATUS 0x0044 -# define R128_VSYNC_INT_AK (1 << 2) -# define R128_VSYNC_INT (1 << 2) -#define R128_GEN_RESET_CNTL 0x00f0 -# define R128_SOFT_RESET_GUI (1 << 0) -# define R128_SOFT_RESET_VCLK (1 << 8) -# define R128_SOFT_RESET_PCLK (1 << 9) -# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11) -# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12) -#define R128_GENENB 0x03c3 /* VGA */ -#define R128_GENFC_RD 0x03ca /* VGA */ -#define R128_GENFC_WT 0x03da /* VGA, 0x03ba */ -#define R128_GENMO_RD 0x03cc /* VGA */ -#define R128_GENMO_WT 0x03c2 /* VGA */ -#define R128_GENS0 0x03c2 /* VGA */ -#define R128_GENS1 0x03da /* VGA, 0x03ba */ -#define R128_GPIO_MONID 0x0068 -# define R128_GPIO_MONID_A_0 (1 << 0) -# define R128_GPIO_MONID_A_1 (1 << 1) -# define R128_GPIO_MONID_A_2 (1 << 2) -# define R128_GPIO_MONID_A_3 (1 << 3) -# define R128_GPIO_MONID_Y_0 (1 << 8) -# define R128_GPIO_MONID_Y_1 (1 << 9) -# define R128_GPIO_MONID_Y_2 (1 << 10) -# define R128_GPIO_MONID_Y_3 (1 << 11) -# define R128_GPIO_MONID_EN_0 (1 << 16) -# define R128_GPIO_MONID_EN_1 (1 << 17) -# define R128_GPIO_MONID_EN_2 (1 << 18) -# define R128_GPIO_MONID_EN_3 (1 << 19) -# define R128_GPIO_MONID_MASK_0 (1 << 24) -# define R128_GPIO_MONID_MASK_1 (1 << 25) -# define R128_GPIO_MONID_MASK_2 (1 << 26) -# define R128_GPIO_MONID_MASK_3 (1 << 27) -#define R128_GPIO_MONIDB 0x006c -#define R128_GRPH8_DATA 0x03cf /* VGA */ -#define R128_GRPH8_IDX 0x03ce /* VGA */ -#define R128_GUI_DEBUG0 0x16a0 -#define R128_GUI_DEBUG1 0x16a4 -#define R128_GUI_DEBUG2 0x16a8 -#define R128_GUI_DEBUG3 0x16ac -#define R128_GUI_DEBUG4 0x16b0 -#define R128_GUI_DEBUG5 0x16b4 -#define R128_GUI_DEBUG6 0x16b8 -#define R128_GUI_PROBE 0x16bc -#define R128_GUI_SCRATCH_REG0 0x15e0 -#define R128_GUI_SCRATCH_REG1 0x15e4 -#define R128_GUI_SCRATCH_REG2 0x15e8 -#define R128_GUI_SCRATCH_REG3 0x15ec -#define R128_GUI_SCRATCH_REG4 0x15f0 -#define R128_GUI_SCRATCH_REG5 0x15f4 -#define R128_GUI_STAT 0x1740 -# define R128_GUI_FIFOCNT_MASK 0x0fff -# define R128_GUI_ACTIVE (1 << 31) - -#define R128_HEADER 0x0f0e /* PCI */ -#define R128_HOST_DATA0 0x17c0 -#define R128_HOST_DATA1 0x17c4 -#define R128_HOST_DATA2 0x17c8 -#define R128_HOST_DATA3 0x17cc -#define R128_HOST_DATA4 0x17d0 -#define R128_HOST_DATA5 0x17d4 -#define R128_HOST_DATA6 0x17d8 -#define R128_HOST_DATA7 0x17dc -#define R128_HOST_DATA_LAST 0x17e0 -#define R128_HOST_PATH_CNTL 0x0130 -#define R128_HTOTAL_CNTL 0x0009 /* PLL */ -#define R128_HW_DEBUG 0x0128 -#define R128_HW_DEBUG2 0x011c - -#define R128_I2C_CNTL_1 0x0094 /* ? */ -#define R128_INTERRUPT_LINE 0x0f3c /* PCI */ -#define R128_INTERRUPT_PIN 0x0f3d /* PCI */ -#define R128_IO_BASE 0x0f14 /* PCI */ - -#define R128_LATENCY 0x0f0d /* PCI */ -#define R128_LEAD_BRES_DEC 0x1608 -#define R128_LEAD_BRES_ERR 0x1600 -#define R128_LEAD_BRES_INC 0x1604 -#define R128_LEAD_BRES_LNTH 0x161c -#define R128_LEAD_BRES_LNTH_SUB 0x1624 -#define R128_LVDS_GEN_CNTL 0x02d0 -# define R128_LVDS_ON (1 << 0) -# define R128_LVDS_DISPLAY_DIS (1 << 1) -# define R128_LVDS_EN (1 << 7) -# define R128_LVDS_DIGON (1 << 18) -# define R128_LVDS_BLON (1 << 19) -# define R128_LVDS_SEL_CRTC2 (1 << 23) -# define R128_HSYNC_DELAY_SHIFT 28 -# define R128_HSYNC_DELAY_MASK (0xf << 28) - -#define R128_MAX_LATENCY 0x0f3f /* PCI */ -#define R128_MCLK_CNTL 0x000f /* PLL */ -# define R128_FORCE_GCP (1 << 16) -# define R128_FORCE_PIPE3D_CP (1 << 17) -# define R128_FORCE_RCP (1 << 18) -#define R128_MDGPIO_A_REG 0x01ac -#define R128_MDGPIO_EN_REG 0x01b0 -#define R128_MDGPIO_MASK 0x0198 -#define R128_MDGPIO_Y_REG 0x01b4 -#define R128_MEM_ADDR_CONFIG 0x0148 -#define R128_MEM_BASE 0x0f10 /* PCI */ -#define R128_MEM_CNTL 0x0140 -#define R128_MEM_INIT_LAT_TIMER 0x0154 -#define R128_MEM_INTF_CNTL 0x014c -#define R128_MEM_SDRAM_MODE_REG 0x0158 -#define R128_MEM_STR_CNTL 0x0150 -#define R128_MEM_VGA_RP_SEL 0x003c -#define R128_MEM_VGA_WP_SEL 0x0038 -#define R128_MIN_GRANT 0x0f3e /* PCI */ -#define R128_MM_DATA 0x0004 -#define R128_MM_INDEX 0x0000 -#define R128_MPLL_CNTL 0x000e /* PLL */ -#define R128_MPP_TB_CONFIG 0x01c0 /* ? */ -#define R128_MPP_GP_CONFIG 0x01c8 /* ? */ - -#define R128_N_VIF_COUNT 0x0248 - -#define R128_OVR_CLR 0x0230 -#define R128_OVR_WID_LEFT_RIGHT 0x0234 -#define R128_OVR_WID_TOP_BOTTOM 0x0238 - -/* first overlay unit (there is only one) */ - -#define R128_OV0_Y_X_START 0x0400 -#define R128_OV0_Y_X_END 0x0404 -#define R128_OV0_EXCLUSIVE_HORZ 0x0408 -# define R128_EXCL_HORZ_START_MASK 0x000000ff -# define R128_EXCL_HORZ_END_MASK 0x0000ff00 -# define R128_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000 -# define R128_EXCL_HORZ_EXCLUSIVE_EN 0x80000000 -#define R128_OV0_EXCLUSIVE_VERT 0x040C -# define R128_EXCL_VERT_START_MASK 0x000003ff -# define R128_EXCL_VERT_END_MASK 0x03ff0000 -#define R128_OV0_REG_LOAD_CNTL 0x0410 -# define R128_REG_LD_CTL_LOCK 0x00000001L -# define R128_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L -# define R128_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L -# define R128_REG_LD_CTL_LOCK_READBACK 0x00000008L -#define R128_OV0_SCALE_CNTL 0x0420 -# define R128_SCALER_PIX_EXPAND 0x00000001L -# define R128_SCALER_Y2R_TEMP 0x00000002L -# define R128_SCALER_HORZ_PICK_NEAREST 0x00000003L -# define R128_SCALER_VERT_PICK_NEAREST 0x00000004L -# define R128_SCALER_SIGNED_UV 0x00000010L -# define R128_SCALER_GAMMA_SEL_MASK 0x00000060L -# define R128_SCALER_GAMMA_SEL_BRIGHT 0x00000000L -# define R128_SCALER_GAMMA_SEL_G22 0x00000020L -# define R128_SCALER_GAMMA_SEL_G18 0x00000040L -# define R128_SCALER_GAMMA_SEL_G14 0x00000060L -# define R128_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L -# define R128_SCALER_SURFAC_FORMAT 0x00000f00L -# define R128_SCALER_SOURCE_15BPP 0x00000300L -# define R128_SCALER_SOURCE_16BPP 0x00000400L -# define R128_SCALER_SOURCE_32BPP 0x00000600L -# define R128_SCALER_SOURCE_YUV9 0x00000900L -# define R128_SCALER_SOURCE_YUV12 0x00000A00L -# define R128_SCALER_SOURCE_VYUY422 0x00000B00L -# define R128_SCALER_SOURCE_YVYU422 0x00000C00L -# define R128_SCALER_SMART_SWITCH 0x00008000L -# define R128_SCALER_BURST_PER_PLANE 0x00ff0000L -# define R128_SCALER_DOUBLE_BUFFER 0x01000000L -# define R128_SCALER_DIS_LIMIT 0x08000000L -# define R128_SCALER_PRG_LOAD_START 0x10000000L -# define R128_SCALER_INT_EMU 0x20000000L -# define R128_SCALER_ENABLE 0x40000000L -# define R128_SCALER_SOFT_RESET 0x80000000L -#define R128_OV0_V_INC 0x0424 -#define R128_OV0_P1_V_ACCUM_INIT 0x0428 -# define R128_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L -# define R128_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L -#define R128_OV0_P23_V_ACCUM_INIT 0x042C -#define R128_OV0_P1_BLANK_LINES_AT_TOP 0x0430 -# define R128_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL -# define R128_P1_ACTIVE_LINES_M1 0x0fff0000L -#define R128_OV0_P23_BLANK_LINES_AT_TOP 0x0434 -# define R128_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL -# define R128_P23_ACTIVE_LINES_M1 0x07ff0000L -#define R128_OV0_VID_BUF0_BASE_ADRS 0x0440 -# define R128_VIF_BUF0_PITCH_SEL 0x00000001L -# define R128_VIF_BUF0_TILE_ADRS 0x00000002L -# define R128_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L -# define R128_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L -#define R128_OV0_VID_BUF1_BASE_ADRS 0x0444 -# define R128_VIF_BUF1_PITCH_SEL 0x00000001L -# define R128_VIF_BUF1_TILE_ADRS 0x00000002L -# define R128_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L -# define R128_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L -#define R128_OV0_VID_BUF2_BASE_ADRS 0x0448 -# define R128_VIF_BUF2_PITCH_SEL 0x00000001L -# define R128_VIF_BUF2_TILE_ADRS 0x00000002L -# define R128_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L -# define R128_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L -#define R128_OV0_VID_BUF3_BASE_ADRS 0x044C -#define R128_OV0_VID_BUF4_BASE_ADRS 0x0450 -#define R128_OV0_VID_BUF5_BASE_ADRS 0x0454 -#define R128_OV0_VID_BUF_PITCH0_VALUE 0x0460 -#define R128_OV0_VID_BUF_PITCH1_VALUE 0x0464 -#define R128_OV0_AUTO_FLIP_CNTL 0x0470 -#define R128_OV0_DEINTERLACE_PATTERN 0x0474 -#define R128_OV0_H_INC 0x0480 -#define R128_OV0_STEP_BY 0x0484 -#define R128_OV0_P1_H_ACCUM_INIT 0x0488 -#define R128_OV0_P23_H_ACCUM_INIT 0x048C -#define R128_OV0_P1_X_START_END 0x0494 -#define R128_OV0_P2_X_START_END 0x0498 -#define R128_OV0_P3_X_START_END 0x049C -#define R128_OV0_FILTER_CNTL 0x04A0 -#define R128_OV0_FOUR_TAP_COEF_0 0x04B0 -#define R128_OV0_FOUR_TAP_COEF_1 0x04B4 -#define R128_OV0_FOUR_TAP_COEF_2 0x04B8 -#define R128_OV0_FOUR_TAP_COEF_3 0x04BC -#define R128_OV0_FOUR_TAP_COEF_4 0x04C0 -#define R128_OV0_COLOUR_CNTL 0x04E0 -#define R128_OV0_VIDEO_KEY_CLR 0x04E4 -#define R128_OV0_VIDEO_KEY_MSK 0x04E8 -#define R128_OV0_GRAPHICS_KEY_CLR 0x04EC -#define R128_OV0_GRAPHICS_KEY_MSK 0x04F0 -#define R128_OV0_KEY_CNTL 0x04F4 -# define R128_VIDEO_KEY_FN_MASK 0x00000007L -# define R128_VIDEO_KEY_FN_FALSE 0x00000000L -# define R128_VIDEO_KEY_FN_TRUE 0x00000001L -# define R128_VIDEO_KEY_FN_EQ 0x00000004L -# define R128_VIDEO_KEY_FN_NE 0x00000005L -# define R128_GRAPHIC_KEY_FN_MASK 0x00000070L -# define R128_GRAPHIC_KEY_FN_FALSE 0x00000000L -# define R128_GRAPHIC_KEY_FN_TRUE 0x00000010L -# define R128_GRAPHIC_KEY_FN_EQ 0x00000040L -# define R128_GRAPHIC_KEY_FN_NE 0x00000050L -# define R128_CMP_MIX_MASK 0x00000100L -# define R128_CMP_MIX_OR 0x00000000L -# define R128_CMP_MIX_AND 0x00000100L -#define R128_OV0_TEST 0x04F8 - - -#define R128_PALETTE_DATA 0x00b4 -#define R128_PALETTE_INDEX 0x00b0 -#define R128_PC_DEBUG_MODE 0x1760 -#define R128_PC_GUI_CTLSTAT 0x1748 -#define R128_PC_GUI_MODE 0x1744 -# define R128_PC_IGNORE_UNIFY (1 << 5) -#define R128_PC_MISC_CNTL 0x0188 -#define R128_PC_NGUI_CTLSTAT 0x0184 -# define R128_PC_FLUSH_GUI (3 << 0) -# define R128_PC_RI_GUI (1 << 2) -# define R128_PC_FLUSH_ALL 0x00ff -# define R128_PC_BUSY (1 << 31) -#define R128_PC_NGUI_MODE 0x0180 -#define R128_PCI_GART_PAGE 0x017c -#define R128_PLANE_3D_MASK_C 0x1d44 -#define R128_PLL_TEST_CNTL 0x0013 /* PLL */ -#define R128_PMI_CAP_ID 0x0f5c /* PCI */ -#define R128_PMI_DATA 0x0f63 /* PCI */ -#define R128_PMI_NXT_CAP_PTR 0x0f5d /* PCI */ -#define R128_PMI_PMC_REG 0x0f5e /* PCI */ -#define R128_PMI_PMCSR_REG 0x0f60 /* PCI */ -#define R128_PMI_REGISTER 0x0f5c /* PCI */ -#define R128_PPLL_CNTL 0x0002 /* PLL */ -# define R128_PPLL_RESET (1 << 0) -# define R128_PPLL_SLEEP (1 << 1) -# define R128_PPLL_ATOMIC_UPDATE_EN (1 << 16) -# define R128_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17) -#define R128_PPLL_DIV_0 0x0004 /* PLL */ -#define R128_PPLL_DIV_1 0x0005 /* PLL */ -#define R128_PPLL_DIV_2 0x0006 /* PLL */ -#define R128_PPLL_DIV_3 0x0007 /* PLL */ -# define R128_PPLL_FB3_DIV_MASK 0x07ff -# define R128_PPLL_POST3_DIV_MASK 0x00070000 -#define R128_PPLL_REF_DIV 0x0003 /* PLL */ -# define R128_PPLL_REF_DIV_MASK 0x03ff -# define R128_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */ -# define R128_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */ -#define R128_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */ -#define R128_REG_BASE 0x0f18 /* PCI */ -#define R128_REGPROG_INF 0x0f09 /* PCI */ -#define R128_REVISION_ID 0x0f08 /* PCI */ - -#define R128_SC_BOTTOM 0x164c -#define R128_SC_BOTTOM_RIGHT 0x16f0 -#define R128_SC_BOTTOM_RIGHT_C 0x1c8c -#define R128_SC_LEFT 0x1640 -#define R128_SC_RIGHT 0x1644 -#define R128_SC_TOP 0x1648 -#define R128_SC_TOP_LEFT 0x16ec -#define R128_SC_TOP_LEFT_C 0x1c88 -#define R128_SEQ8_DATA 0x03c5 /* VGA */ -#define R128_SEQ8_IDX 0x03c4 /* VGA */ -#define R128_SNAPSHOT_F_COUNT 0x0244 -#define R128_SNAPSHOT_VH_COUNTS 0x0240 -#define R128_SNAPSHOT_VIF_COUNT 0x024c -#define R128_SRC_OFFSET 0x15ac -#define R128_SRC_PITCH 0x15b0 -#define R128_SRC_PITCH_OFFSET 0x1428 -#define R128_SRC_SC_BOTTOM 0x165c -#define R128_SRC_SC_BOTTOM_RIGHT 0x16f4 -#define R128_SRC_SC_RIGHT 0x1654 -#define R128_SRC_X 0x1414 -#define R128_SRC_X_Y 0x1590 -#define R128_SRC_Y 0x1418 -#define R128_SRC_Y_X 0x1434 -#define R128_STATUS 0x0f06 /* PCI */ -#define R128_SUBPIC_CNTL 0x0540 /* ? */ -#define R128_SUB_CLASS 0x0f0a /* PCI */ -#define R128_SURFACE_DELAY 0x0b00 -#define R128_SURFACE0_INFO 0x0b0c -#define R128_SURFACE0_LOWER_BOUND 0x0b04 -#define R128_SURFACE0_UPPER_BOUND 0x0b08 -#define R128_SURFACE1_INFO 0x0b1c -#define R128_SURFACE1_LOWER_BOUND 0x0b14 -#define R128_SURFACE1_UPPER_BOUND 0x0b18 -#define R128_SURFACE2_INFO 0x0b2c -#define R128_SURFACE2_LOWER_BOUND 0x0b24 -#define R128_SURFACE2_UPPER_BOUND 0x0b28 -#define R128_SURFACE3_INFO 0x0b3c -#define R128_SURFACE3_LOWER_BOUND 0x0b34 -#define R128_SURFACE3_UPPER_BOUND 0x0b38 -#define R128_SW_SEMAPHORE 0x013c - -#define R128_TEST_DEBUG_CNTL 0x0120 -#define R128_TEST_DEBUG_MUX 0x0124 -#define R128_TEST_DEBUG_OUT 0x012c -#define R128_TMDS_CRC 0x02a0 -#define R128_TMDS_TRANSMITTER_CNTL 0x02a4 -# define R128_TMDS_PLLEN (1 << 0) -# define R128_TMDS_PLLRST (1 << 1) -#define R128_TRAIL_BRES_DEC 0x1614 -#define R128_TRAIL_BRES_ERR 0x160c -#define R128_TRAIL_BRES_INC 0x1610 -#define R128_TRAIL_X 0x1618 -#define R128_TRAIL_X_SUB 0x1620 - -#define R128_VCLK_ECP_CNTL 0x0008 /* PLL */ -#define R128_VENDOR_ID 0x0f00 /* PCI */ -#define R128_VGA_DDA_CONFIG 0x02e8 -#define R128_VGA_DDA_ON_OFF 0x02ec -#define R128_VID_BUFFER_CONTROL 0x0900 -#define R128_VIDEOMUX_CNTL 0x0190 -#define R128_VIPH_CONTROL 0x01D0 /* ? */ - -#define R128_WAIT_UNTIL 0x1720 - -#define R128_X_MPLL_REF_FB_DIV 0x000a /* PLL */ -#define R128_XCLK_CNTL 0x000d /* PLL */ -#define R128_XDLL_CNTL 0x000c /* PLL */ -#define R128_XPLL_CNTL 0x000b /* PLL */ - - /* Registers for CCE and Microcode Engine */ -#define R128_PM4_MICROCODE_ADDR 0x07d4 -#define R128_PM4_MICROCODE_RADDR 0x07d8 -#define R128_PM4_MICROCODE_DATAH 0x07dc -#define R128_PM4_MICROCODE_DATAL 0x07e0 - -#define R128_PM4_BUFFER_OFFSET 0x0700 -#define R128_PM4_BUFFER_CNTL 0x0704 -# define R128_PM4_NONPM4 (0 << 28) -# define R128_PM4_192PIO (1 << 28) -# define R128_PM4_192BM (2 << 28) -# define R128_PM4_128PIO_64INDBM (3 << 28) -# define R128_PM4_128BM_64INDBM (4 << 28) -# define R128_PM4_64PIO_128INDBM (5 << 28) -# define R128_PM4_64BM_128INDBM (6 << 28) -# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) -# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) -# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) -#define R128_PM4_BUFFER_WM_CNTL 0x0708 -# define R128_WMA_SHIFT 0 -# define R128_WMB_SHIFT 8 -# define R128_WMC_SHIFT 16 -# define R128_WB_WM_SHIFT 24 -#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c -#define R128_PM4_BUFFER_DL_RPTR 0x0710 -#define R128_PM4_BUFFER_DL_WPTR 0x0714 -# define R128_PM4_BUFFER_DL_DONE (1 << 31) -#define R128_PM4_BUFFER_DL_WPTR_DELAY 0x0718 -# define R128_PRE_WRITE_TIMER_SHIFT 0 -# define R128_PRE_WRITE_LIMIT_SHIFT 23 -#define R128_PM4_VC_FPU_SETUP 0x071c -# define R128_FRONT_DIR_CW (0 << 0) -# define R128_FRONT_DIR_CCW (1 << 0) -# define R128_FRONT_DIR_MASK (1 << 0) -# define R128_BACKFACE_CULL (0 << 1) -# define R128_BACKFACE_POINTS (1 << 1) -# define R128_BACKFACE_LINES (2 << 1) -# define R128_BACKFACE_SOLID (3 << 1) -# define R128_BACKFACE_MASK (3 << 1) -# define R128_FRONTFACE_CULL (0 << 3) -# define R128_FRONTFACE_POINTS (1 << 3) -# define R128_FRONTFACE_LINES (2 << 3) -# define R128_FRONTFACE_SOLID (3 << 3) -# define R128_FRONTFACE_MASK (3 << 3) -# define R128_FPU_COLOR_SOLID (0 << 5) -# define R128_FPU_COLOR_FLAT (1 << 5) -# define R128_FPU_COLOR_GOURAUD (2 << 5) -# define R128_FPU_COLOR_GOURAUD2 (3 << 5) -# define R128_FPU_COLOR_MASK (3 << 5) -# define R128_FPU_SUB_PIX_2BITS (0 << 7) -# define R128_FPU_SUB_PIX_4BITS (1 << 7) -# define R128_FPU_MODE_2D (0 << 8) -# define R128_FPU_MODE_3D (1 << 8) -# define R128_TRAP_BITS_DISABLE (1 << 9) -# define R128_EDGE_ANTIALIAS (1 << 10) -# define R128_SUPERSAMPLE (1 << 11) -# define R128_XFACTOR_2 (0 << 12) -# define R128_XFACTOR_4 (1 << 12) -# define R128_YFACTOR_2 (0 << 13) -# define R128_YFACTOR_4 (1 << 13) -# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14) -# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14) -# define R128_FPU_ROUND_TRUNCATE (0 << 15) -# define R128_FPU_ROUND_NEAREST (1 << 15) -# define R128_WM_SEL_8DW (0 << 16) -# define R128_WM_SEL_16DW (1 << 16) -# define R128_WM_SEL_32DW (2 << 16) -#define R128_PM4_VC_DEBUG_CONFIG 0x07a4 -#define R128_PM4_VC_STAT 0x07a8 -#define R128_PM4_VC_TIMESTAMP0 0x07b0 -#define R128_PM4_VC_TIMESTAMP1 0x07b4 -#define R128_PM4_STAT 0x07b8 -# define R128_PM4_FIFOCNT_MASK 0x0fff -# define R128_PM4_BUSY (1 << 16) -# define R128_PM4_GUI_ACTIVE (1 << 31) -#define R128_PM4_BUFFER_ADDR 0x07f0 -#define R128_PM4_MICRO_CNTL 0x07fc -# define R128_PM4_MICRO_FREERUN (1 << 30) -#define R128_PM4_FIFO_DATA_EVEN 0x1000 -#define R128_PM4_FIFO_DATA_ODD 0x1004 - -#define R128_SCALE_3D_CNTL 0x1a00 -# define R128_SCALE_DITHER_ERR_DIFF (0 << 1) -# define R128_SCALE_DITHER_TABLE (1 << 1) -# define R128_TEX_CACHE_SIZE_FULL (0 << 2) -# define R128_TEX_CACHE_SIZE_HALF (1 << 2) -# define R128_DITHER_INIT_CURR (0 << 3) -# define R128_DITHER_INIT_RESET (1 << 3) -# define R128_ROUND_24BIT (1 << 4) -# define R128_TEX_CACHE_DISABLE (1 << 5) -# define R128_SCALE_3D_NOOP (0 << 6) -# define R128_SCALE_3D_SCALE (1 << 6) -# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6) -# define R128_SCALE_PIX_BLEND (0 << 8) -# define R128_SCALE_PIX_REPLICATE (1 << 8) -# define R128_TEX_CACHE_SPLIT (1 << 9) -# define R128_APPLE_YUV_MODE (1 << 10) -# define R128_TEX_CACHE_PALLETE_MODE (1 << 11) -# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) -# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) -# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) -# define R128_ALPHA_COMB_SUB_SRC_DST_NCLAMP (3 << 12) -# define R128_ALPHA_COMB_FCN_MASK (3 << 12) -# define R128_FOG_VERTEX (0 << 14) -# define R128_FOG_TABLE (1 << 14) -# define R128_SIGNED_DST_CLAMP (1 << 15) - -# define R128_ALPHA_BLEND_ZERO (0 ) -# define R128_ALPHA_BLEND_ONE (1 ) -# define R128_ALPHA_BLEND_SRCCOLOR (2 ) -# define R128_ALPHA_BLEND_INVSRCCOLOR (3 ) -# define R128_ALPHA_BLEND_SRCALPHA (4 ) -# define R128_ALPHA_BLEND_INVSRCALPHA (5 ) -# define R128_ALPHA_BLEND_DSTALPHA (6 ) -# define R128_ALPHA_BLEND_INVDSTALPHA (7 ) -# define R128_ALPHA_BLEND_DSTCOLOR (8 ) -# define R128_ALPHA_BLEND_INVDSTCOLOR (9 ) -# define R128_ALPHA_BLEND_SAT (10) /* aka SRCALPHASAT */ -# define R128_ALPHA_BLEND_BLEND (11) /* aka BOTHSRCALPHA */ -# define R128_ALPHA_BLEND_INVBLEND (12) /* aka BOTHINVSRCALPHA */ -# define R128_ALPHA_BLEND_MASK (15) - -# define R128_ALPHA_BLEND_SRC_SHIFT (16) -# define R128_ALPHA_BLEND_DST_SHIFT (20) - -# define R128_ALPHA_TEST_NEVER (0 << 24) -# define R128_ALPHA_TEST_LESS (1 << 24) -# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) -# define R128_ALPHA_TEST_EQUAL (3 << 24) -# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) -# define R128_ALPHA_TEST_GREATER (5 << 24) -# define R128_ALPHA_TEST_NEQUAL (6 << 24) -# define R128_ALPHA_TEST_ALWAYS (7 << 24) -# define R128_ALPHA_TEST_MASK (7 << 24) -# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) -# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) -# define R128_COMPOSITE_SHADOW (1 << 29) -# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) -# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31) -# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31) -#define R128_SCALE_3D_DATATYPE 0x1a20 - -#define R128_SETUP_CNTL 0x1bc4 -# define R128_DONT_START_TRIANGLE (1 << 0) -# define R128_Z_BIAS (0 << 1) -# define R128_DONT_START_ANY_ON (1 << 2) -# define R128_COLOR_SOLID_COLOR (0 << 3) -# define R128_COLOR_FLAT_VERT_1 (1 << 3) -# define R128_COLOR_FLAT_VERT_2 (2 << 3) -# define R128_COLOR_FLAT_VERT_3 (3 << 3) -# define R128_COLOR_GOURAUD (4 << 3) -# define R128_PRIM_TYPE_TRI (0 << 7) -# define R128_PRIM_TYPE_LINE (1 << 7) -# define R128_PRIM_TYPE_POINT (2 << 7) -# define R128_PRIM_TYPE_POLY_EDGE (3 << 7) -# define R128_TEXTURE_ST_MULT_W (0 << 9) -# define R128_TEXTURE_ST_DIRECT (1 << 9) -# define R128_STARTING_VERTEX_1 (1 << 14) -# define R128_STARTING_VERTEX_2 (2 << 14) -# define R128_STARTING_VERTEX_3 (3 << 14) -# define R128_ENDING_VERTEX_1 (1 << 16) -# define R128_ENDING_VERTEX_2 (2 << 16) -# define R128_ENDING_VERTEX_3 (3 << 16) -# define R128_SU_POLY_LINE_LAST (0 << 18) -# define R128_SU_POLY_LINE_NOT_LAST (1 << 18) -# define R128_SUB_PIX_2BITS (0 << 19) -# define R128_SUB_PIX_4BITS (1 << 19) -# define R128_SET_UP_CONTINUE (1 << 31) - -#define R128_WINDOW_XY_OFFSET 0x1bcc -# define R128_WINDOW_Y_SHIFT 4 -# define R128_WINDOW_X_SHIFT 20 - -#define R128_Z_OFFSET_C 0x1c90 -#define R128_Z_PITCH_C 0x1c94 -# define R128_Z_TILE (1 << 16) -#define R128_Z_STEN_CNTL_C 0x1c98 -# define R128_Z_PIX_WIDTH_16 (0 << 1) -# define R128_Z_PIX_WIDTH_24 (1 << 1) -# define R128_Z_PIX_WIDTH_32 (2 << 1) -# define R128_Z_PIX_WIDTH_MASK (3 << 1) -# define R128_Z_TEST_NEVER (0 << 4) -# define R128_Z_TEST_LESS (1 << 4) -# define R128_Z_TEST_LESSEQUAL (2 << 4) -# define R128_Z_TEST_EQUAL (3 << 4) -# define R128_Z_TEST_GREATEREQUAL (4 << 4) -# define R128_Z_TEST_GREATER (5 << 4) -# define R128_Z_TEST_NEQUAL (6 << 4) -# define R128_Z_TEST_ALWAYS (7 << 4) -# define R128_Z_TEST_MASK (7 << 4) -# define R128_STENCIL_TEST_NEVER (0 << 12) -# define R128_STENCIL_TEST_LESS (1 << 12) -# define R128_STENCIL_TEST_LESSEQUAL (2 << 12) -# define R128_STENCIL_TEST_EQUAL (3 << 12) -# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12) -# define R128_STENCIL_TEST_GREATER (5 << 12) -# define R128_STENCIL_TEST_NEQUAL (6 << 12) -# define R128_STENCIL_TEST_ALWAYS (7 << 12) -# define R128_STENCIL_TEST_MASK (7 << 12) -# define R128_STENCIL_S_FAIL_KEEP (0 << 16) -# define R128_STENCIL_S_FAIL_ZERO (1 << 16) -# define R128_STENCIL_S_FAIL_REPLACE (2 << 16) -# define R128_STENCIL_S_FAIL_INC (3 << 16) -# define R128_STENCIL_S_FAIL_DEC (4 << 16) -# define R128_STENCIL_S_FAIL_INV (5 << 16) -# define R128_STENCIL_S_FAIL_INC_WRAP (6 << 16) /* GUESS */ -# define R128_STENCIL_S_FAIL_DEC_WRAP (7 << 16) /* GUESS */ -# define R128_STENCIL_S_FAIL_MASK (7 << 16) -# define R128_STENCIL_ZPASS_KEEP (0 << 20) -# define R128_STENCIL_ZPASS_ZERO (1 << 20) -# define R128_STENCIL_ZPASS_REPLACE (2 << 20) -# define R128_STENCIL_ZPASS_INC (3 << 20) -# define R128_STENCIL_ZPASS_DEC (4 << 20) -# define R128_STENCIL_ZPASS_INV (5 << 20) -# define R128_STENCIL_ZPASS_INC_WRAP (6 << 20) /* GUESS */ -# define R128_STENCIL_ZPASS_DEC_WRAP (7 << 20) /* GUESS */ -# define R128_STENCIL_ZPASS_MASK (7 << 20) -# define R128_STENCIL_ZFAIL_KEEP (0 << 24) -# define R128_STENCIL_ZFAIL_ZERO (1 << 24) -# define R128_STENCIL_ZFAIL_REPLACE (2 << 24) -# define R128_STENCIL_ZFAIL_INC (3 << 24) -# define R128_STENCIL_ZFAIL_DEC (4 << 24) -# define R128_STENCIL_ZFAIL_INV (5 << 24) -# define R128_STENCIL_ZFAIL_INC_WRAP (6 << 24) /* GUESS */ -# define R128_STENCIL_ZFAIL_DEC_WRAP (7 << 24) /* GUESS */ -# define R128_STENCIL_ZFAIL_MASK (7 << 24) -#define R128_TEX_CNTL_C 0x1c9c -# define R128_Z_ENABLE (1 << 0) -# define R128_Z_WRITE_ENABLE (1 << 1) -# define R128_STENCIL_ENABLE (1 << 3) -# define R128_SHADE_ENABLE (0 << 4) -# define R128_TEXMAP_ENABLE (1 << 4) -# define R128_SEC_TEXMAP_ENABLE (1 << 5) -# define R128_FOG_ENABLE (1 << 7) -# define R128_DITHER_ENABLE (1 << 8) -# define R128_ALPHA_ENABLE (1 << 9) -# define R128_ALPHA_TEST_ENABLE (1 << 10) -# define R128_SPEC_LIGHT_ENABLE (1 << 11) -# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12) -# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13) -# define R128_ALPHA_IN_TEX_LSB_A (1 << 13) -# define R128_LIGHT_DIS (0 << 14) -# define R128_LIGHT_COPY (1 << 14) -# define R128_LIGHT_MODULATE (2 << 14) -# define R128_LIGHT_ADD (3 << 14) -# define R128_LIGHT_BLEND_CONSTANT (4 << 14) -# define R128_LIGHT_BLEND_TEXTURE (5 << 14) -# define R128_LIGHT_BLEND_VERTEX (6 << 14) -# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14) -# define R128_ALPHA_LIGHT_DIS (0 << 18) -# define R128_ALPHA_LIGHT_COPY (1 << 18) -# define R128_ALPHA_LIGHT_MODULATE (2 << 18) -# define R128_ALPHA_LIGHT_ADD (3 << 18) -# define R128_ANTI_ALIAS (1 << 21) -# define R128_TEX_CACHE_FLUSH (1 << 23) -# define R128_LOD_BIAS_SHIFT 24 -# define R128_LOD_BIAS_MASK (0xff << 24) -#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0 -# define R128_REF_ALPHA_MASK 0xff -# define R128_MISC_SCALE_3D_NOOP (0 << 8) -# define R128_MISC_SCALE_3D_SCALE (1 << 8) -# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) -# define R128_MISC_SCALE_PIX_BLEND (0 << 10) -# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) -/* Bits [14:12] are the same as R128_SCALE_3D_CNTL */ -/* Bit [15] is unknown */ -/* Bits [26:16] are the same as R128_SCALE_3D_CNTL */ -/* Bits [31:27] are unknown */ - -#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4 -#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8 -#define R128_FOG_COLOR_C 0x1cac -# define R128_FOG_BLUE_SHIFT 0 -# define R128_FOG_GREEN_SHIFT 8 -# define R128_FOG_RED_SHIFT 16 -#define R128_PRIM_TEX_CNTL_C 0x1cb0 -# define R128_MIN_BLEND_NEAREST (0 << 1) -# define R128_MIN_BLEND_LINEAR (1 << 1) -# define R128_MIN_BLEND_MIPNEAREST (2 << 1) -# define R128_MIN_BLEND_MIPLINEAR (3 << 1) -# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1) -# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1) -# define R128_MIN_BLEND_MASK (7 << 1) -# define R128_MAG_BLEND_NEAREST (0 << 4) -# define R128_MAG_BLEND_LINEAR (1 << 4) -# define R128_MAG_BLEND_MASK (7 << 4) -# define R128_MIP_MAP_DISABLE (1 << 7) -# define R128_TEX_CLAMP_S_WRAP (0 << 8) -# define R128_TEX_CLAMP_S_MIRROR (1 << 8) -# define R128_TEX_CLAMP_S_CLAMP (2 << 8) -# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8) -# define R128_TEX_CLAMP_S_MASK (3 << 8) -# define R128_TEX_WRAP_S (1 << 10) -# define R128_TEX_CLAMP_T_WRAP (0 << 11) -# define R128_TEX_CLAMP_T_MIRROR (1 << 11) -# define R128_TEX_CLAMP_T_CLAMP (2 << 11) -# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11) -# define R128_TEX_CLAMP_T_MASK (3 << 11) -# define R128_TEX_WRAP_T (1 << 13) -# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14) -# define R128_DATATYPE_VQ (0 << 16) -# define R128_DATATYPE_CI4 (1 << 16) -# define R128_DATATYPE_CI8 (2 << 16) -# define R128_DATATYPE_ARGB1555 (3 << 16) -# define R128_DATATYPE_RGB565 (4 << 16) -# define R128_DATATYPE_RGB888 (5 << 16) -# define R128_DATATYPE_ARGB8888 (6 << 16) -# define R128_DATATYPE_RGB332 (7 << 16) -# define R128_DATATYPE_Y8 (8 << 16) -# define R128_DATATYPE_RGB8 (9 << 16) -# define R128_DATATYPE_CI16 (10 << 16) -# define R128_DATATYPE_YVYU422 (11 << 16) -# define R128_DATATYPE_VYUY422 (12 << 16) -# define R128_DATATYPE_AYUV444 (14 << 16) -# define R128_DATATYPE_ARGB4444 (15 << 16) -# define R128_PALLETE_EITHER (0 << 20) -# define R128_PALLETE_1 (1 << 20) -# define R128_PALLETE_2 (2 << 20) -# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24) -# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) -# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) -#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 -# define R128_COMB_DIS (0 << 0) -# define R128_COMB_COPY (1 << 0) -# define R128_COMB_COPY_INP (2 << 0) -# define R128_COMB_MODULATE (3 << 0) -# define R128_COMB_MODULATE2X (4 << 0) -# define R128_COMB_MODULATE4X (5 << 0) -# define R128_COMB_ADD (6 << 0) -# define R128_COMB_ADD_SIGNED (7 << 0) -# define R128_COMB_BLEND_VERTEX (8 << 0) -# define R128_COMB_BLEND_TEXTURE (9 << 0) -# define R128_COMB_BLEND_CONST (10 << 0) -# define R128_COMB_BLEND_PREMULT (11 << 0) -# define R128_COMB_BLEND_PREV (12 << 0) -# define R128_COMB_BLEND_PREMULT_INV (13 << 0) -# define R128_COMB_ADD_SIGNED2X (14 << 0) -# define R128_COMB_BLEND_CONST_COLOR (15 << 0) -# define R128_COMB_MASK (15 << 0) -# define R128_COLOR_FACTOR_CONST_COLOR (0 << 4) -# define R128_COLOR_FACTOR_NCONST_COLOR (1 << 4) -# define R128_COLOR_FACTOR_TEX (4 << 4) -# define R128_COLOR_FACTOR_NTEX (5 << 4) -# define R128_COLOR_FACTOR_ALPHA (6 << 4) -# define R128_COLOR_FACTOR_NALPHA (7 << 4) -# define R128_COLOR_FACTOR_PREV_COLOR (8 << 4) -# define R128_COLOR_FACTOR_MASK (15 << 4) -# define R128_COMB_FCN_MSB (1 << 8) -# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10) -# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10) -# define R128_INPUT_FACTOR_INT_COLOR (4 << 10) -# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10) -# define R128_INPUT_FACTOR_MASK (15 << 10) -# define R128_COMB_ALPHA_DIS (0 << 14) -# define R128_COMB_ALPHA_COPY (1 << 14) -# define R128_COMB_ALPHA_COPY_INP (2 << 14) -# define R128_COMB_ALPHA_MODULATE (3 << 14) -# define R128_COMB_ALPHA_MODULATE2X (4 << 14) -# define R128_COMB_ALPHA_MODULATE4X (5 << 14) -# define R128_COMB_ALPHA_ADD (6 << 14) -# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14) -# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14) -# define R128_COMB_ALPHA_MASK (15 << 14) -# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18) -# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) -# define R128_ALPHA_FACTOR_MASK (15 << 18) -# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25) -# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25) -# define R128_INP_FACTOR_A_MASK (7 << 25) -#define R128_TEX_SIZE_PITCH_C 0x1cb8 -# define R128_TEX_PITCH_SHIFT 0 -# define R128_TEX_SIZE_SHIFT 4 -# define R128_TEX_HEIGHT_SHIFT 8 -# define R128_TEX_MIN_SIZE_SHIFT 12 -# define R128_SEC_TEX_PITCH_SHIFT 16 -# define R128_SEC_TEX_SIZE_SHIFT 20 -# define R128_SEC_TEX_HEIGHT_SHIFT 24 -# define R128_SEC_TEX_MIN_SIZE_SHIFT 28 -# define R128_TEX_PITCH_MASK (0x0f << 0) -# define R128_TEX_SIZE_MASK (0x0f << 4) -# define R128_TEX_HEIGHT_MASK (0x0f << 8) -# define R128_TEX_MIN_SIZE_MASK (0x0f << 12) -# define R128_SEC_TEX_PITCH_MASK (0x0f << 16) -# define R128_SEC_TEX_SIZE_MASK (0x0f << 20) -# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24) -# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) -# define R128_TEX_SIZE_PITCH_SHIFT 0 -# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16 -# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0) -# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) -#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc -#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0 -#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4 -#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8 -#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc -#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0 -#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4 -#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8 -#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc -#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0 -#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4 -# define R128_TEX_NO_TILE (0 << 30) -# define R128_TEX_TILED_BY_HOST (1 << 30) -# define R128_TEX_TILED_BY_STORAGE (2 << 30) -# define R128_TEX_TILED_BY_STORAGE2 (3 << 30) - -#define R128_SEC_TEX_CNTL_C 0x1d00 -# define R128_SEC_SELECT_PRIM_ST (0 << 0) -# define R128_SEC_SELECT_SEC_ST (1 << 0) -#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04 -# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10) -# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10) -# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25) -#define R128_SEC_TEX_0_OFFSET_C 0x1d08 -#define R128_SEC_TEX_1_OFFSET_C 0x1d0c -#define R128_SEC_TEX_2_OFFSET_C 0x1d10 -#define R128_SEC_TEX_3_OFFSET_C 0x1d14 -#define R128_SEC_TEX_4_OFFSET_C 0x1d18 -#define R128_SEC_TEX_5_OFFSET_C 0x1d1c -#define R128_SEC_TEX_6_OFFSET_C 0x1d20 -#define R128_SEC_TEX_7_OFFSET_C 0x1d24 -#define R128_SEC_TEX_8_OFFSET_C 0x1d28 -#define R128_SEC_TEX_9_OFFSET_C 0x1d2c -#define R128_SEC_TEX_10_OFFSET_C 0x1d30 -#define R128_CONSTANT_COLOR_C 0x1d34 -# define R128_CONSTANT_BLUE_SHIFT 0 -# define R128_CONSTANT_GREEN_SHIFT 8 -# define R128_CONSTANT_RED_SHIFT 16 -# define R128_CONSTANT_ALPHA_SHIFT 24 -#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 -# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0 -# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8 -# define R128_PRIM_TEX_BORDER_RED_SHIFT 16 -# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24 -#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c -# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0 -# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8 -# define R128_SEC_TEX_BORDER_RED_SHIFT 16 -# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24 -#define R128_STEN_REF_MASK_C 0x1d40 -# define R128_STEN_REFERENCE_SHIFT 0 -# define R128_STEN_MASK_SHIFT 16 -# define R128_STEN_WRITE_MASK_SHIFT 24 -#define R128_PLANE_3D_MASK_C 0x1d44 -#define R128_TEX_CACHE_STAT_COUNT 0x1974 - - - /* Constants */ -#define R128_AGP_TEX_OFFSET 0x02000000 - -#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0 - - /* CCE packet types */ -#define R128_CCE_PACKET0 0x00000000 -#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000 -#define R128_CCE_PACKET1 0x40000000 -#define R128_CCE_PACKET2 0x80000000 -#define R128_CCE_PACKET3 0xC0000000 -#define R128_CCE_PACKET3_NOP 0xC0001000 -#define R128_CCE_PACKET3_PAINT 0xC0001100 -#define R128_CCE_PACKET3_BITBLT 0xC0001200 -#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300 -#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 -#define R128_CCE_PACKET3_POLYLINE 0xC0001500 -#define R128_CCE_PACKET3_SCALING 0xC0001600 -#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700 -#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800 -#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900 -#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00 -#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 -#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 -#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00 -#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 -#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100 -#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200 -#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 -#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 -#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 -#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600 -#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 -#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 -#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 -#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 -#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 -#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 -#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 -#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 -#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 -#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 -#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 -#define R128_CCE_PACKET3_PURGE 0xC0002D00 -#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 -# define R128_CCE_PACKET_MASK 0xC0000000 -# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 -# define R128_CCE_PACKET_MAX_DWORDS (1 << 12) -# define R128_CCE_PACKET0_REG_MASK 0x000007ff -# define R128_CCE_PACKET1_REG0_MASK 0x000007ff -# define R128_CCE_PACKET1_REG1_MASK 0x003ff800 - -#define R128_CCE_VC_FRMT_RHW 0x00000001 -#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 -#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004 -#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 -#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010 -#define R128_CCE_VC_FRMT_SPEC_F 0x00000020 -#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040 -#define R128_CCE_VC_FRMT_S_T 0x00000080 -#define R128_CCE_VC_FRMT_S2_T2 0x00000100 -#define R128_CCE_VC_FRMT_RHW2 0x00000200 - -#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 -#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 -#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 -#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 -#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 -#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 -#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 -#define R128_CCE_VC_CNTL_NUM_SHIFT 16 - -/* hmm copyed blindly (no specs) from radeon.h ... */ -#define R128_RE_TOP_LEFT 0x26c0 -# define R128_RE_LEFT_SHIFT 0 -# define R128_RE_TOP_SHIFT 16 -#define R128_RE_WIDTH_HEIGHT 0x1c44 -# define R128_RE_WIDTH_SHIFT 0 -# define R128_RE_HEIGHT_SHIFT 16 - -#endif diff --git a/src/mesa/drivers/dri/r128/server/r128_version.h b/src/mesa/drivers/dri/r128/server/r128_version.h deleted file mode 100644 index 783711ef971..00000000000 --- a/src/mesa/drivers/dri/r128/server/r128_version.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000 through 2003 by Marc Aurele La France (TSI @ UQV), [email protected] - * - * 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 Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE 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. - */ - -#ifndef _R128_VERSION_H_ -#define _R128_VERSION_H_ 1 - -#undef R128_NAME -#undef R128_DRIVER_NAME -#undef R128_VERSION_MAJOR -#undef R128_VERSION_MINOR -#undef R128_VERSION_PATCH -#undef R128_VERSION_CURRENT -#undef R128_VERSION_EVALUATE -#undef R128_VERSION_STRINGIFY -#undef R128_VERSION_NAME - -#define R128_NAME "R128" -#define R128_DRIVER_NAME "r128" - -#define R128_VERSION_MAJOR 4 -#define R128_VERSION_MINOR 0 -#define R128_VERSION_PATCH 1 - -#ifndef R128_VERSION_EXTRA -#define R128_VERSION_EXTRA "" -#endif - -#define R128_VERSION_CURRENT \ - ((R128_VERSION_MAJOR << 20) | \ - (R128_VERSION_MINOR << 10) | \ - (R128_VERSION_PATCH)) - -#define R128_VERSION_EVALUATE(__x) #__x -#define R128_VERSION_STRINGIFY(_x) R128_VERSION_EVALUATE(_x) -#define R128_VERSION_NAME \ - R128_VERSION_STRINGIFY(R128_VERSION_MAJOR) "." \ - R128_VERSION_STRINGIFY(R128_VERSION_MINOR) "." \ - R128_VERSION_STRINGIFY(R128_VERSION_MINOR) R128_VERSION_EXTRA - -#endif /* _R128_VERSION_H_ */ diff --git a/src/mesa/drivers/dri/savage/Makefile b/src/mesa/drivers/dri/savage/Makefile deleted file mode 100644 index 03be3468da9..00000000000 --- a/src/mesa/drivers/dri/savage/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# src/mesa/drivers/dri/r128/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = savage_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - savage_xmesa.c \ - savagedd.c \ - savagestate.c \ - savagetex.c \ - savagetris.c \ - savagerender.c \ - savageioctl.c \ - savagespan.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/savage/savage_3d_reg.h b/src/mesa/drivers/dri/savage/savage_3d_reg.h deleted file mode 100644 index 45733cdf929..00000000000 --- a/src/mesa/drivers/dri/savage/savage_3d_reg.h +++ /dev/null @@ -1,711 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SAVAGE_3D_REG_H -#define SAVAGE_3D_REG_H - -#define VIDEO_MEM_ADR 0x02 -#define SYSTEM_MEM_ADR 0x01 -#define AGP_MEM_ADR 0x03 - -/*********************************************************** - - ----------- 3D ENGINE UNIT Registers ------------- - - *********************************************************/ - -typedef union -{ - struct - { - unsigned reserved : 4; - unsigned ofs : 28; - }ni; - uint32_t ui; -} savageRegZPixelOffset; - -/* This reg exists only on Savage4. */ -typedef union -{ - struct - { - unsigned cmpFunc : 3; - unsigned stencilEn : 1; - unsigned readMask : 8; - unsigned writeMask : 8; - unsigned failOp : 3; - unsigned passZfailOp : 3; - unsigned passZpassOp : 3; - unsigned reserved : 3; - }ni; - uint32_t ui; -} savageRegStencilCtrl; - -/************************** - Texture Registers -**************************/ -/* The layout of this reg differs between Savage4 and Savage3D. */ -typedef union -{ - struct - { - unsigned tex0Width : 4; - unsigned tex0Height : 4; - unsigned tex0Fmt : 4; - unsigned tex1Width : 4; - unsigned tex1Height : 4; - unsigned tex1Fmt : 4; - unsigned texBLoopEn : 1; - unsigned tex0En : 1; - unsigned tex1En : 1; - unsigned orthProjEn : 1; - unsigned reserved : 1; - unsigned palSize : 2; - unsigned newPal : 1; - }ni; - uint32_t ui; -} savageRegTexDescr_s4; -typedef union -{ - struct - { - unsigned texWidth : 4; - unsigned reserved1 : 4; - unsigned texHeight : 4; - unsigned reserved2 : 4; - /* Savage3D supports only the first 8 texture formats defined in - enum TexFmt in savge_bci.h. */ - unsigned texFmt : 3; - unsigned palSize : 2; - unsigned reserved3 : 10; - unsigned newPal : 1; - }ni; - uint32_t ui; -} savageRegTexDescr_s3d; - -/* The layout of this reg is the same on Savage4 and Savage3D, - but the Savage4 has two of them, Savage3D has only one. */ -typedef union -{ - struct - { - unsigned inSysTex : 1; - unsigned inAGPTex : 1; - unsigned reserved : 1; - unsigned addr : 29; - }ni; - uint32_t ui; -} savageRegTexAddr; - -/* The layout of this reg is the same on Savage4 and Savage3D. */ -typedef union -{ - struct - { - unsigned reserved : 3; - unsigned addr : 29; - }ni; - uint32_t ui; -} savageRegTexPalAddr; - -/* The layout of this reg on Savage4 and Savage3D are very similar. */ -typedef union -{ - struct - { - unsigned xprClr0 : 16; - unsigned xprClr1 : 16; /* this is reserved on Savage3D */ - }ni; - uint32_t ui; -} savageRegTexXprClr; /* transparency color in RGB565 format*/ - -/* The layout of this reg differs between Savage4 and Savage3D. - * Savage4 has two of them, Savage3D has only one. */ -typedef union -{ - struct - { - unsigned filterMode : 2; - unsigned mipmapEnable : 1; - unsigned dBias : 9; - unsigned dMax : 4; - unsigned uMode : 2; - unsigned vMode : 2; - unsigned useDFraction : 1; - unsigned texXprEn : 1; - unsigned clrBlendAlphaSel : 2; - unsigned clrArg1CopyAlpha : 1; - unsigned clrArg2CopyAlpha : 1; - unsigned clrArg1Invert : 1; - unsigned clrArg2Invert : 1; - unsigned alphaBlendAlphaSel : 2; - unsigned alphaArg1Invert : 1; - unsigned alphaArg2Invert : 1; - }ni; - uint32_t ui; -} savageRegTexCtrl_s4; -typedef union -{ - struct - { - unsigned filterMode : 2; - unsigned mipmapDisable : 1; - unsigned dBias : 9; - unsigned uWrapEn : 1; - unsigned vWrapEn : 1; - unsigned wrapMode : 2; - unsigned texEn : 1; - unsigned useDFraction : 1; - unsigned reserved1 : 1; - /* Color Compare Alpha Blend Control - 0 - reduce dest alpha to 0 or 1 - 1 - blend with destination - The Utah-Driver doesn't know how to use it and sets it to 0. */ - unsigned CCA : 1; - unsigned texXprEn : 1; - unsigned reserved2 : 11; - }ni; - uint32_t ui; -} savageRegTexCtrl_s3d; - -/* This reg exists only on Savage4. */ -typedef union -{ - struct - { - unsigned colorArg1Sel : 2; - unsigned colorArg2Sel : 3; - unsigned colorInvAlphaEn : 1; - unsigned colorInvArg2En : 1; - unsigned colorPremodSel : 1; - unsigned colorMod1Sel : 1; - unsigned colorMod2Sel : 2; - unsigned colorAddSel : 2; - unsigned colorDoBlend : 1; - unsigned colorDo2sCompl : 1; - unsigned colorAddBiasEn : 1; - unsigned alphaArg1Sel : 2; - unsigned alphaArg2Sel : 3; - unsigned alphaMod1Sel : 1; - unsigned alphaMod2Sel : 2; - unsigned alphaAdd0Sel : 1; - unsigned alphaDoBlend : 1; - unsigned alphaDo2sCompl : 1; - unsigned colorStageClamp : 1; - unsigned alphaStageClamp : 1; - unsigned colorDoDiffMul : 1; - unsigned LeftShiftVal : 2; - }ni; - uint32_t ui; -} savageRegTexBlendCtrl; - -/* This reg exists only on Savage4. */ -typedef union -{ - struct - { - unsigned blue : 8; - unsigned green : 8; - unsigned red : 8; - unsigned alpha : 8; - }ni; - uint32_t ui; -} savageRegTexBlendColor; - -/******************************** - Tiled Surface Registers -**********************************/ - -typedef union -{ - struct - { - unsigned frmBufOffset : 13; - unsigned reserved : 12; - unsigned widthInTile : 6; - unsigned bitPerPixel : 1; - }ni; - uint32_t ui; -} savageRegTiledSurface; - -/******************************** - Draw/Shading Control Registers -**********************************/ - -/* This reg exists only on Savage4. */ -typedef union -{ - struct - { - unsigned scissorXStart : 11; - unsigned dPerfAccelEn : 1; - unsigned scissorYStart : 12; - unsigned alphaRefVal : 8; - }ni; - uint32_t ui; -} savageRegDrawCtrl0; - -/* This reg exists only on Savage4. */ -typedef union -{ - struct - { - unsigned scissorXEnd : 11; - unsigned xyOffsetEn : 1; - unsigned scissorYEnd : 12; - unsigned ditherEn : 1; - unsigned nonNormTexCoord : 1; - unsigned cullMode : 2; - unsigned alphaTestCmpFunc : 3; - unsigned alphaTestEn : 1; - }ni; - uint32_t ui; -} savageRegDrawCtrl1; - -/* This reg exists only on Savage4. */ -typedef union -{ - struct - { - unsigned dstAlphaMode : 3; - - /** - * This bit enables \c GL_FUNC_SUBTRACT. Like most DirectX oriented - * hardware, there's no way to do \c GL_FUNC_REVERSE_SUBTRACT. - * - * \todo - * Add support for \c GL_FUNC_SUBTRACT! - */ - unsigned dstMinusSrc : 1; - unsigned srcAlphaMode : 3; - unsigned binaryFinalAlpha : 1; - unsigned dstAlphaModeHighBit : 1; - unsigned srcAlphaModeHighBit : 1; - unsigned reserved1 : 15; - unsigned wrZafterAlphaTst : 1; - unsigned drawUpdateEn : 1; - unsigned zUpdateEn : 1; - unsigned flatShadeEn : 1; - unsigned specShadeEn : 1; - unsigned flushPdDestWrites : 1; - unsigned flushPdZbufWrites : 1; - }ni; - uint32_t ui; -} savageRegDrawLocalCtrl; - -/* This reg exists only on Savage3D. */ -typedef union -{ - struct - { - unsigned ditherEn : 1; - unsigned xyOffsetEn : 1; - unsigned cullMode : 2; - unsigned vertexCountReset : 1; - unsigned flatShadeEn : 1; - unsigned specShadeEn : 1; - unsigned dstAlphaMode : 3; - unsigned srcAlphaMode : 3; - unsigned reserved1 : 1; - unsigned alphaTestCmpFunc : 3; - unsigned alphaTestEn : 1; - unsigned alphaRefVal : 8; - unsigned texBlendCtrl : 3; - unsigned flushPdDestWrites : 1; - unsigned flushPdZbufWrites : 1; - - /** - * Disable perspective correct interpolation for vertex color, vertex - * fog, and vertex alpha. For OpenGL, this should \b always be zero. - */ - unsigned interpMode : 1; - }ni; - uint32_t ui; -} savageRegDrawCtrl; - -#define SAVAGETBC_DECAL_S3D 0 -#define SAVAGETBC_MODULATE_S3D 1 -#define SAVAGETBC_DECALALPHA_S3D 2 -#define SAVAGETBC_MODULATEALPHA_S3D 3 -#define SAVAGETBC_4_S3D 4 -#define SAVAGETBC_5_S3D 5 -#define SAVAGETBC_COPY_S3D 6 -#define SAVAGETBC_7_S3D 7 - -/* This reg exists only on Savage3D. */ -typedef union -{ - struct - { - unsigned scissorXStart : 11; - unsigned reserved1 : 5; - unsigned scissorYStart : 11; - unsigned reserved2 : 5; - } ni; - uint32_t ui; -} savageRegScissorsStart; - -/* This reg exists only on Savage3D. */ -typedef union -{ - struct - { - unsigned scissorXEnd : 11; - unsigned reserved1 : 5; - unsigned scissorYEnd : 11; - unsigned reserved2 : 5; - } ni; - uint32_t ui; -} savageRegScissorsEnd; - -/******************************** - Address Registers -**********************************/ - -/* I havn't found a Savage3D equivalent of this reg in the Utah-driver. - * But Tim Roberts claims that the Savage3D supports DMA vertex and - * command buffers. */ -typedef union -{ - struct - { - unsigned isSys : 1; - unsigned isAGP : 1; - unsigned reserved : 1; - unsigned addr : 29; /*quad word aligned*/ - }ni; - uint32_t ui; -} savageRegVertBufAddr; - -/* I havn't found a Savage3D equivalent of this reg in the Utah-driver. - * But Tim Roberts claims that the Savage3D supports DMA vertex and - * command buffers. */ -typedef union -{ - struct - { - unsigned isSys : 1; - unsigned isAGP : 1; - unsigned reserved : 1; - unsigned addr : 29; /*4-quad word aligned*/ - }ni; - uint32_t ui; -} savageRegDMABufAddr; - -/******************************** - H/W Debug Registers -**********************************/ -/* The layout of this reg is the same on Savage4 and Savage3D. */ -typedef union -{ - struct - { - unsigned y01 : 1; - unsigned y12 : 1; - unsigned y20 : 1; - unsigned u01 : 1; - unsigned u12 : 1; - unsigned u20 : 1; - unsigned v01 : 1; - unsigned v12 : 1; - unsigned v20 : 1; - unsigned cullEn : 1; - unsigned cullOrient : 1; - unsigned loadNewTex : 1; - unsigned loadNewPal : 1; - unsigned doDSetup : 1; - unsigned reserved : 17; - unsigned kickOff : 1; - }ni; - uint32_t ui; -} savageRegFlag; - -/******************************** - Z Buffer Registers -- Global -**********************************/ - -/* The layout of this reg differs between Savage4 and Savage3D. */ -typedef union -{ - struct - { - unsigned zCmpFunc : 3; - unsigned reserved1 : 2; - unsigned zBufEn : 1; - unsigned reserved2 : 1; - unsigned zExpOffset : 8; - unsigned reserved3 : 1; - unsigned stencilRefVal : 8; - unsigned autoZEnable : 1; - unsigned frameID : 1; - unsigned reserved4 : 4; - unsigned floatZEn : 1; - unsigned wToZEn : 1; - }ni; - uint32_t ui; -} savageRegZBufCtrl_s4; -typedef union -{ - struct { - unsigned zCmpFunc : 3; - unsigned drawUpdateEn : 1; - unsigned zUpdateEn : 1; - unsigned zBufEn : 1; - - /** - * We suspect that, in conjunction with - * \c savageRegZBufOffset::zDepthSelect, these 2 bits are actually - * \c stencilUpdateEn and \c stencilBufEn. If not, then some of - * the bits in \c reserved2 may fulfill that purpose. - */ - unsigned reserved1 : 2; - - unsigned zExpOffset : 8; - unsigned wrZafterAlphaTst : 1; - unsigned reserved2 : 15; - }ni; - uint32_t ui; -} savageRegZBufCtrl_s3d; - -/* The layout of this reg on Savage4 and Savage3D is very similar. */ -typedef union -{ - struct - { - /* In the Utah-Driver the offset is defined as 13-bit, 2k-aligned. */ - unsigned offset : 14; - unsigned reserved : 11; /* 12-bits in Utah-driver */ - unsigned zBufWidthInTiles : 6; - - /** - * 0 selects 16-bit depth buffer. On Savage4 hardware, 1 selects - * 24-bit depth buffer (with 8-bits for stencil). Though it has never - * been tried, we suspect that on Savage3D hardware, 1 selects 15-bit - * depth buffer (with 1-bit for stencil). - */ - unsigned zDepthSelect : 1; - }ni; - uint32_t ui; -} savageRegZBufOffset; - -/* The layout of this reg is the same on Savage4 and Savage3D. */ -typedef union -{ - struct - { - unsigned rLow : 6; - unsigned reserved1 : 2; - unsigned rHigh : 6; - unsigned reserved2 : 2; - unsigned wLow : 6; - unsigned reserved3 : 2; - unsigned wHigh : 6; - unsigned reserved4 : 2; - }ni; - uint32_t ui; -} savageRegZWatermarks; - -/******************************** - Fog Registers -- Global -**********************************/ -/* The layout of this reg is the same on Savage4 and Savage3D. */ -typedef union -{ - struct - { - unsigned fogClr : 24; - unsigned expShift : 3; - unsigned reserved : 1; - unsigned fogEn : 1; - unsigned fogMode : 1; - unsigned fogEndShift : 2; - }ni; - uint32_t ui; -} savageRegFogCtrl; - -/*not in spec, but tempo for pp and driver*/ -typedef union -{ - struct - { - unsigned fogDensity : 16; - unsigned fogStart : 16; - }ni; - uint32_t ui; -} savageRegFogParam; - -/************************************** - Destination Buffer Registers -- Global -***************************************/ - -/* The layout of this reg on Savage4 and Savage3D are very similar. */ -typedef union -{ - struct - { - unsigned dstWidthInTile : 7; - unsigned reserved : 1; - /* In the Utah-Driver the offset is defined as 13-bit, 2k-aligned. */ - unsigned offset : 14; - unsigned reserved1 : 7; - /* antiAliasMode does not exist in the Utah-driver. But it includes the - * high bit of this in the destPixFmt. However, only values 0 and 2 - * are used as dstPixFmt, so antiAliasMode is effectively always 0 - * in the Utah-driver. In other words, treat as reserved on Savage3D.*/ - unsigned antiAliasMode : 2; - unsigned dstPixFmt : 1; - }ni; - uint32_t ui; -} savageRegDestCtrl; - -/* The layout of this reg on Savage4 and Savage3D are very similar. */ -typedef union -{ - struct - { - unsigned destReadLow : 6; - unsigned destReadHigh : 6; - unsigned destWriteLow : 6; - unsigned destWriteHigh : 6; - unsigned texRead : 4; - unsigned reserved4 : 2; - /* The Utah-driver calls this pixel FIFO length: - * 00 - 240, 01 - 180, 10 - 120, 11 - 60 - * However, it is not used in either driver. */ - unsigned destFlush : 2; - }ni; - uint32_t ui; -} savageRegDestTexWatermarks; - -/* Savage4/Twister/ProSavage register BCI addresses */ -#define SAVAGE_DRAWLOCALCTRL_S4 0x1e -#define SAVAGE_TEXPALADDR_S4 0x1f -#define SAVAGE_TEXCTRL0_S4 0x20 -#define SAVAGE_TEXCTRL1_S4 0x21 -#define SAVAGE_TEXADDR0_S4 0x22 -#define SAVAGE_TEXADDR1_S4 0x23 -#define SAVAGE_TEXBLEND0_S4 0x24 -#define SAVAGE_TEXBLEND1_S4 0x25 -#define SAVAGE_TEXXPRCLR_S4 0x26 /* never used */ -#define SAVAGE_TEXDESCR_S4 0x27 -#define SAVAGE_FOGTABLE_S4 0x28 -#define SAVAGE_FOGCTRL_S4 0x30 -#define SAVAGE_STENCILCTRL_S4 0x31 -#define SAVAGE_ZBUFCTRL_S4 0x32 -#define SAVAGE_ZBUFOFF_S4 0x33 -#define SAVAGE_DESTCTRL_S4 0x34 -#define SAVAGE_DRAWCTRLGLOBAL0_S4 0x35 -#define SAVAGE_DRAWCTRLGLOBAL1_S4 0x36 -#define SAVAGE_ZWATERMARK_S4 0x37 -#define SAVAGE_DESTTEXRWWATERMARK_S4 0x38 -#define SAVAGE_TEXBLENDCOLOR_S4 0x39 -/* Savage3D/MX/IC register BCI addresses */ -#define SAVAGE_TEXPALADDR_S3D 0x18 -#define SAVAGE_TEXXPRCLR_S3D 0x19 /* never used */ -#define SAVAGE_TEXADDR_S3D 0x1A -#define SAVAGE_TEXDESCR_S3D 0x1B -#define SAVAGE_TEXCTRL_S3D 0x1C -#define SAVAGE_FOGTABLE_S3D 0x20 -#define SAVAGE_FOGCTRL_S3D 0x30 -#define SAVAGE_DRAWCTRL_S3D 0x31 -#define SAVAGE_ZBUFCTRL_S3D 0x32 -#define SAVAGE_ZBUFOFF_S3D 0x33 -#define SAVAGE_DESTCTRL_S3D 0x34 -#define SAVAGE_SCSTART_S3D 0x35 -#define SAVAGE_SCEND_S3D 0x36 -#define SAVAGE_ZWATERMARK_S3D 0x37 -#define SAVAGE_DESTTEXRWWATERMARK_S3D 0x38 - -#define SAVAGE_FIRST_REG 0x18 -#define SAVAGE_NR_REGS 34 -typedef struct savage_registers_s4_t { - uint32_t unused1[6]; /* 0x18-0x1d */ - savageRegDrawLocalCtrl drawLocalCtrl; /* 0x1e */ - savageRegTexPalAddr texPalAddr; /* 0x1f */ - savageRegTexCtrl_s4 texCtrl[2]; /* 0x20, 0x21 */ - savageRegTexAddr texAddr[2]; /* 0x22, 0x23 */ - savageRegTexBlendCtrl texBlendCtrl[2]; /* 0x24, 0x25 */ - savageRegTexXprClr texXprClr; /* 0x26 */ - savageRegTexDescr_s4 texDescr; /* 0x27 */ - uint8_t fogTable[32]; /* 0x28-0x2f (8dwords) */ - savageRegFogCtrl fogCtrl; /* 0x30 */ - savageRegStencilCtrl stencilCtrl; /* 0x31 */ - savageRegZBufCtrl_s4 zBufCtrl; /* 0x32 */ - savageRegZBufOffset zBufOffset; /* 0x33 */ - savageRegDestCtrl destCtrl; /* 0x34 */ - savageRegDrawCtrl0 drawCtrl0; /* 0x35 */ - savageRegDrawCtrl1 drawCtrl1; /* 0x36 */ - savageRegZWatermarks zWatermarks; /* 0x37 */ - savageRegDestTexWatermarks destTexWatermarks; /* 0x38 */ - savageRegTexBlendColor texBlendColor; /* 0x39 */ -} savageRegistersS4; -typedef struct savage_registers_s3d_t { - savageRegTexPalAddr texPalAddr; /* 0x18 */ - savageRegTexXprClr texXprClr; /* 0x19 */ - savageRegTexAddr texAddr; /* 0x1a */ - savageRegTexDescr_s3d texDescr; /* 0x1b */ - savageRegTexCtrl_s3d texCtrl; /* 0x1c */ - uint32_t unused1[3]; /* 0x1d-0x1f */ - uint8_t fogTable[64]; /* 0x20-0x2f (16dwords) */ - savageRegFogCtrl fogCtrl; /* 0x30 */ - savageRegDrawCtrl drawCtrl; /* 0x31 */ - savageRegZBufCtrl_s3d zBufCtrl; /* 0x32 */ - savageRegZBufOffset zBufOffset; /* 0x33 */ - savageRegDestCtrl destCtrl; /* 0x34 */ - savageRegScissorsStart scissorsStart; /* 0x35 */ - savageRegScissorsEnd scissorsEnd; /* 0x36 */ - savageRegZWatermarks zWatermarks; /* 0x37 */ - savageRegDestTexWatermarks destTexWatermarks; /* 0x38 */ - uint32_t unused2; /* 0x39 */ -} savageRegistersS3D; -typedef union savage_registers_t { - savageRegistersS4 s4; - savageRegistersS3D s3d; - uint32_t ui[SAVAGE_NR_REGS]; -} savageRegisters; - - -#define DV_PF_555 (0x1<<8) -#define DV_PF_565 (0x2<<8) -#define DV_PF_8888 (0x4<<8) - -#define SAVAGEPACKCOLORA4L4(l,a) \ - ((l >> 4) | (a & 0xf0)) - -#define SAVAGEPACKCOLOR4444(r,g,b,a) \ - ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4)) - -#define SAVAGEPACKCOLOR1555(r,g,b,a) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define SAVAGEPACKCOLOR8888(r,g,b,a) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define SAVAGEPACKCOLOR565(r,g,b) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - - -#endif diff --git a/src/mesa/drivers/dri/savage/savage_bci.h b/src/mesa/drivers/dri/savage/savage_bci.h deleted file mode 100644 index 33cfac32c71..00000000000 --- a/src/mesa/drivers/dri/savage/savage_bci.h +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SAVAGE_BCI_H -#define SAVAGE_BCI_H -/*********************** - 3D and 2D command -************************/ - -typedef enum { - AMO_BurstCmdData= 0x01010000, - AMO_3DReg= 0x01048500, - AMO_MotionCompReg= 0x01048900, - AMO_VideoEngUnit= 0x01048A00, - AMO_CmdBufAddr= 0x01048c14, - AMO_TiledSurfReg0= 0x01048C40, - AMO_TiledSurfReg1= 0x01048C44, - AMO_TiledSurfReg2= 0x01048C48, - AMO_TiledSurfReg3= 0x01048C4C, - AMO_TiledSurfReg4= 0x01048C50, - AMO_TiledSurfReg5= 0x01048C54, - AMO_TiledSurfReg6= 0x01048C58, - AMO_TiledSurfReg7= 0x01048C5C, - AMO_LPBModeReg= 0x0100FF00, - AMO_LPBFifoSat= 0x0100FF04, - AMO_LPBIntFlag= 0x0100FF08, - AMO_LPBFmBufA0= 0x0100FF0C, - AMO_LPBFmBufA1= 0x0100FF10, - AMO_LPBRdWtAdr= 0x0100FF14, - AMO_LPBRdWtDat= 0x0100FF18, - AMO_LPBIOPort = 0x0100FF1C, - AMO_LPBSerPort= 0x0100FF20, - AMO_LPBVidInWinSz= 0x0100FF24, - AMO_LPBVidDatOffs= 0x0100FF28, - AMO_LPBHorScalCtrl= 0x0100FF2C, - AMO_LPBVerDeciCtrl= 0x0100FF30, - AMO_LPBLnStride= 0x0100FF34, - AMO_LPBFmBufAddr2= 0x0100FF38, - AMO_LPBVidCapVDCtrl=0x0100FF3C, - - AMO_LPBVidCapFdStAd=0x0100FF60, - AMO_LPBVidCapFdMdAd=0x0100FF64, - AMO_LPBVidCapFdBtAd=0x0100FF68, - AMO_LPBVidCapFdSize=0x0100FF6C, - AMO_LPBBilinDecim1= 0x0100FF70, - AMO_LPBBilinDecim2= 0x0100FF74, - AMO_LPBBilinDecim3= 0x0100FF78, - AMO_LPBDspVEUHorSRR=0x0100FF7C, - AMO_LPBDspVEUVerSRR=0x0100FF80, - AMO_LPBDspVeuDnScDR=0x0100FF84, - AMO_LPB_VEUERPReg= 0x0100FF88, - AMO_LPB_VBISelReg= 0x0100FF8C, - AMO_LPB_VBIBasAdReg=0x0100FF90, - AMO_LPB_DatOffsReg= 0x0100FF94, - AMO_LPB_VBIVerDcReg=0x0100FF98, - AMO_LPB_VBICtrlReg= 0x0100FF9C, - AMO_LPB_VIPXferCtrl=0x0100FFA0, - AMO_LPB_FIFOWtMark= 0x0100FFA4, - AMO_LPB_FIFOCount= 0x0100FFA8, - AMO_LPBFdSkipPat= 0x0100FFAC, - AMO_LPBCapVEUHorSRR=0x0100FFB0, - AMO_LPBCapVEUVerSRR=0x0100FFB4, - AMO_LPBCapVeuDnScDR=0x0100FFB8 - -}AddressMapOffset; -/*more to add*/ - - -typedef enum { - CMD_DrawPrim=0x10, /*10000*/ - CMD_DrawIdxPrim=0x11, /*10001*/ - CMD_SetRegister=0x12, /*10010*/ - CMD_UpdateShadowStat=0x13 , /*10011*/ - CMD_PageFlip=0x14, /* 10100*/ - CMD_BusMasterImgXfer=0x15, /* 10101*/ - CMD_ScaledImgXfer=0x16, /* 10110*/ - CMD_Macroblock=0x17, /*10111*/ - CMD_Wait= 0x18, /*11000*/ - CMD_2D_NOP=0x08, /* 01000*/ - CMD_2D_RCT=0x09, /*01001 rectangular fill*/ - CMD_2D_SCNL=0x0a, /* 01010 scan line*/ - CMD_2D_LIN=0x0b, /*01011 line*/ - CMD_2D_SMTXT=0x0c, /*01100*/ - CMD_2D_BPTXT=0x0d, /*01101*/ - CMD_InitFlag=0x1f /*11111, for S/W initialization control*/ -}Command; - - -typedef enum { - VRR_List, - VRR_Strip, - VRR_Fan, - VRR_QuadList -}VertexReplaceRule; - -/*********************** - Destination -************************/ - -typedef enum { - DFT_RGB565 = 0, - DFT_XRGB8888 -}DestinationFmt; - - -/************************* - Z Buffer / Alpha test -*************************/ - -typedef enum { - CF_Never, - CF_Less, - CF_Equal, - CF_LessEqual, - CF_Greater, - CF_NotEqual, - CF_GreaterEqual, - CF_Always -}ZCmpFunc; /* same for Alpha test and Stencil test compare function */ - -typedef ZCmpFunc ACmpFunc; - -typedef enum { - ZDS_16i, /* .16 fixed*/ - ZDS_32f /* 1.8.15 float*/ -}ZDepthSelect; - - -/********************************** - BCI Register Addressing Index -***********************************/ -typedef enum { - - CRI_VTX0_X = 0x00, - CRI_VTX0_Y = 0x01, - CRI_VTX0_W = 0x02, - CRI_VTX0_DIFFU= 0x03, - CRI_VTX0_SPECU= 0x04, - CRI_VTX0_U = 0x05, - CRI_VTX0_V = 0x06, - CRI_VTX0_U2 = 0x07, - CRI_VTX0_V2 = 0x08, - CRI_VTX1_X = 0x09, - CRI_VTX1_Y = 0x0a, - CRI_VTX1_W = 0x0b, - CRI_VTX1_DIFFU= 0x0c, - CRI_VTX1_SPECU= 0x0d, - CRI_VTX1_U = 0x0e, - CRI_VTX1_V = 0x0f, - CRI_VTX1_U2 = 0x10, - CRI_VTX1_V2 = 0x11, - CRI_VTX2_X = 0x12, - CRI_VTX2_Y = 0x13, - CRI_VTX2_W = 0x14, - CRI_VTX2_DIFFU= 0x15, - CRI_VTX2_SPECU= 0x16, - CRI_VTX2_U = 0x17, - CRI_VTX2_V = 0x18, - CRI_VTX2_U2 = 0x19, - CRI_VTX2_V2 = 0x1a, - - CRI_ZPixelOffset = 0x1d, - CRI_DrawCtrlLocal = 0x1e, - CRI_TexPalAddr = 0x1f, - CRI_TexCtrl0 = 0x20, - CRI_TexCtrl1 = 0x21, - CRI_TexAddr0 = 0x22, - CRI_TexAddr1 = 0x23, - CRI_TexBlendCtrl0 = 0x24, - CRI_TexBlendCtrl1 = 0x25, - CRI_TexXprClr = 0x26, - CRI_TexDescr = 0x27, - - CRI_FogTable00= 0x28, - CRI_FogTable04= 0x29, - CRI_FogTable08= 0x2a, - CRI_FogTable12= 0x2b, - CRI_FogTable16= 0x2c, - CRI_FogTable20= 0x2d, - CRI_FogTable24= 0x2e, - CRI_FogTable28= 0x2f, - CRI_FogCtrl= 0x30, - CRI_StencilCtrl= 0x31, - CRI_ZBufCtrl= 0x32, - CRI_ZBufOffset= 0x33, - CRI_DstCtrl= 0x34, - CRI_DrawCtrlGlobal0= 0x35, - CRI_DrawCtrlGlobal1= 0x36, - CRI_ZRW_WTMK = 0x37, - CRI_DST_WTMK = 0x38, - CRI_TexBlendColor= 0x39, - - CRI_VertBufAddr= 0x3e, - /* new in ms1*/ - CRI_MauFrameAddr0 = 0x40, - CRI_MauFrameAddr1 = 0x41, - CRI_MauFrameAddr2 = 0x42, - CRI_MauFrameAddr3 = 0x43, - CRI_FrameDesc = 0x44, - CRI_IDCT9bitEn = 0x45, - CRI_MV0 = 0x46, - CRI_MV1 = 0x47, - CRI_MV2 = 0x48, - CRI_MV3 = 0x49, - CRI_MacroDescr = 0x4a, /*kickoff?*/ - - CRI_MeuCtrl = 0x50, - CRI_SrcYAddr = 0x51, - CRI_DestAddr = 0x52, - CRI_FmtrSrcDimen = 0x53, - CRI_FmtrDestDimen = 0x54, - CRI_SrcCbAddr = 0x55, - CRI_SrcCrAddr = 0x56, - CRI_SrcCrCbStride = 0x57, - - CRI_BCI_Power= 0x5f, - - CRI_PSCtrl=0xA0, - CRI_SSClrKeyCtrl=0xA1, - CRI_SSCtrl=0xA4, - CRI_SSChromUpBound=0xA5, - CRI_SSHoriScaleCtrl=0xA6, - CRI_SSClrAdj=0xA7, - CRI_SSBlendCtrl=0xA8, - CRI_PSFBAddr0=0xB0, - CRI_PSFBAddr1=0xB1, - CRI_PSStride=0xB2, - CRI_DB_LPB_Support=0xB3, - CRI_SSFBAddr0=0xB4, - CRI_SSFBAddr1=0xB5, - CRI_SSStride=0xB6, - CRI_SSOpaqueCtrl=0xB7, - CRI_SSVertScaleCtrl=0xB8, - CRI_SSVertInitValue=0xB9, - CRI_SSSrcLineCnt=0xBA, - CRI_FIFO_RAS_Ctrl=0xBB, - CRI_PSWinStartCoord=0xBC, - CRI_PSWinSize=0xBD, - CRI_SSWinStartCoord=0xBE, - CRI_SSWinSize=0xBF, - CRI_PSFIFOMon0=0xC0, - CRI_SSFIFOMon0=0xC1, - CRI_PSFIFOMon1=0xC2, - CRI_SSFIFOMon1=0xC3, - CRI_PSFBSize=0xC4, - CRI_SSFBSize=0xC5, - CRI_SSFBAddr2=0xC6, - /* 2D register starts at D0*/ - CRI_CurrXY=0xD0, - CRI_DstXYorStep=0xD1 , - CRI_LineErr=0xD2 , - CRI_DrawCmd=0xD3, /*kick off for image xfer*/ - CRI_ShortStrkVecXfer=0xD4, - CRI_BackClr=0xD5, - CRI_ForeClr=0xD6, - CRI_BitPlaneWtMask=0xD7, - CRI_BitPlaneRdMask=0xD8, - CRI_ClrCmp=0xD9 , - CRI_BackAndForeMix=0xDA , - CRI_TopLeftSciss=0xDB , - CRI_BotRightSciss=0xDC , - CRI_PixOrMultiCtrl=0xDD , - CRI_MultiCtrlOrRdSelct=0xDE , - CRI_MinorOrMajorAxisCnt=0xDF , - CRI_GlobalBmpDesc1=0xE0 , - CRI_GlobalBmpDesc2=0xE1 , - CRI_BurstPriBmpDesc1=0xE2 , - CRI_BurstPriBmpDesc2=0xE3 , - CRI_BurstSecBmpDesc1=0xE4 , - CRI_BurstSecBmpDesc2=0xE5, - CRI_ImageDataPort=0xF8 - -}CtrlRegIdx; - -/*********************** - Fog Mode -************************/ -typedef enum -{ - FGM_Z_FOG, /*Table*/ - FGM_V_FOG /*Vertex*/ -} FogMode; - -/*********************** - Texture -************************/ -typedef enum -{ - TAM_Wrap, - TAM_Clamp, - TAM_Mirror -} TexAddressModel; - -typedef enum -{ - TFT_S3TC4Bit, - TFT_Pal8Bit565, - TFT_Pal8Bit1555, - TFT_ARGB8888, - TFT_ARGB1555, - TFT_ARGB4444, - TFT_RGB565, - TFT_Pal8Bit4444, - TFT_S3TC4A4Bit, /*like S3TC4Bit but with 4 bit alpha*/ - TFT_S3TC4CA4Bit, /*like S3TC4Bit, but with 4 bit compressed alpha*/ - TFT_S3TCL4, - TFT_S3TCA4L4, - TFT_L8, - TFT_A4L4, - TFT_I8, - TFT_A8 -} TexFmt; - -typedef enum -{ - TPS_64, - TPS_128, - TPS_192, - TPS_256 -} TexPaletteSize; - -#define MAX_MIPMAP_LOD_BIAS 255 -#define MIN_MIPMAP_LOD_BIAS -255 - -typedef enum -{ - TFM_Point, /*1 TPP*/ - TFM_Bilin, /*2 TPP*/ - TFM_Reserved, - TFM_Trilin /*16 TPP*/ -} TexFilterMode; - - -#define TBC_Decal 0x00850410 -#define TBC_Modul 0x00850011 -#define TBC_DecalAlpha 0x00852A04 -#define TBC_ModulAlpha 0x00110011 -#define TBC_Copy 0x00840410 -#define TBC_CopyAlpha 0x00900405 -#define TBC_NoTexMap 0x00850405 -#define TBC_Blend0 0x00810004 -#define TBC_Blend1 0x00870e02 -#define TBC_BlendAlpha0 0x00040004 -#define TBC_BlendAlpha1 TBC_Blend1 -#define TBC_BlendInt0 0x00040004 -#define TBC_BlendInt1 0x01c20e02 -#define TBC_AddAlpha 0x19910c11 -#define TBC_Add 0x18110c11 - -#define TBC_Decal1 0x00870410 -#define TBC_Modul1 0x00870013 -#define TBC_DecalAlpha1 0x00832A00 -#define TBC_ModulAlpha1 0x00130013 -#define TBC_NoTexMap1 0x00870407 -#define TBC_Copy1 0x00870400 -#define TBC_CopyAlpha1 0x00900400 -#define TBC_AddAlpha1 0x19930c13 -#define TBC_Add1 0x18130c13 - -/* - * derived from TexBlendCtrl - */ - -typedef enum -{ - TBC_UseSrc, - TBC_UseTex, - TBC_TexTimesSrc, - TBC_BlendTexWithSrc -} TexBlendCtrlMode; - -/*********************** - Draw Control -************************/ -typedef enum -{ - BCM_Reserved, - BCM_None, - BCM_CW, - BCM_CCW -} BackfaceCullingMode; - -typedef enum -{ - SAM_Zero, - SAM_One, - SAM_DstClr, - SAM_1DstClr, - SAM_SrcAlpha, - SAM_1SrcAlpha, - SAM_DstAlpha, - SAM_1DstAlpha -} SrcAlphaBlendMode; - -/* -1 from state*/ -typedef enum -{ - DAM_Zero, - DAM_One, - DAM_SrcClr, - DAM_1SrcClr, - DAM_SrcAlpha, - DAM_1SrcAlpha, - DAM_DstAlpha, - DAM_1DstAlpha -} DstAlphaBlendMode; - -/* - * stencil control - */ - -typedef enum -{ - STENCIL_Keep, - STENCIL_Zero, - STENCIL_Equal, - STENCIL_IncClamp, - STENCIL_DecClamp, - STENCIL_Invert, - STENCIL_Inc, - STENCIL_Dec -} StencilOp; - -/*************************************************************** -*** Bitfield Structures for Programming Interface ************** -***************************************************************/ - -/************************** - Command Header Entry -**************************/ - -typedef struct { /*for DrawIndexPrimitive command, vert0Idx is meaningful.*/ - unsigned int vert0Idx:16; - unsigned int vertCnt:8; - unsigned int cont:1; - unsigned int type:2; /*00=list, 01=strip, 10=fan, 11=reserved*/ - unsigned int cmd:5; -}Reg_DrawIndexPrimitive; - -typedef struct { /*for DrawIndexPrimitive command, vert0Idx is meaningful.*/ - unsigned int noW:1; - unsigned int noCd:1; - unsigned int noCs:1; - unsigned int noU:1; - unsigned int noV:1; - unsigned int noU2:1; - unsigned int noV2:1; - - unsigned int reserved:9; - unsigned int vertCnt:8; - unsigned int cont:1; - unsigned int type:2; /* 00=list, 01=strip, 10=fan, 11=reserved*/ - unsigned int cmd:5; -}Reg_DrawPrimitive; - - -typedef struct { - unsigned int startRegIdx:8; - unsigned int reserved:8; - unsigned int regCnt:8; - unsigned int resvered1:1; - unsigned int lowEn:1; - unsigned int highEn:1; - unsigned int cmd:5; -}Reg_SetRegister; - -typedef struct { - unsigned int reserved1:22; - unsigned int isPrimary:1; - unsigned int MIU_SYNC:1; - unsigned int reserved2:3; - unsigned int cmd:5; -}Reg_QueuedPageFlip; - -typedef struct { - unsigned int reserved1:22; - unsigned int DIR:1; - unsigned int CTG:1; /*set to 0*/ - unsigned int BPP:1; - unsigned int reserved2:1; - unsigned int cmd:5; -}Reg_MasterImgXfer; - -typedef struct { - unsigned int PD:4; /*PM=mono, PS=descriptor specified*/ - unsigned int PT:1; - unsigned int SD:4; - unsigned int ST:1; - unsigned int DD:3; - unsigned int DC:2; /*DC=destination clip*/ - unsigned int CS:1; /*cs=color specified*/ - unsigned int MIX3:8; - unsigned int XP:1; - unsigned int YP:1; - unsigned int LP:1; - unsigned int cmd:5; -}Reg_2D; - -typedef struct { - unsigned int CodedBlkPattern:6; - unsigned int DCT_Type:1; - unsigned int MB_Type:2; - unsigned int MotionType:2; - unsigned int MB_Row:6; - unsigned int MB_Column:6; - unsigned int mv3:1; - unsigned int mv2:1; - unsigned int mv1:1; - unsigned int mv0:1; - unsigned int cmd:5; -}Reg_MacroBlock; - -typedef struct { - unsigned int scanLnCnt:11; - unsigned int clkCnt:5; - unsigned int e3d:1; - unsigned int e2d:1; - unsigned int mau:1; - unsigned int veu:1; - unsigned int meuMit:1; - unsigned int meuSit:1; - unsigned int meuVx:1; - unsigned int meuMau:1; - unsigned int pageFlip:1; - unsigned int scanLn:1; - unsigned int clk:1; - unsigned int cmd:5; -}Reg_Wait; - -typedef struct{ - unsigned int reserved:27; - unsigned int cmd:5; -}Reg_ScaledImgXfer ; - -typedef struct{ - unsigned int eventTag:16; - unsigned int reserved2:6; - unsigned int ET:1; - unsigned int INT:1; - unsigned int reserved1:3; - unsigned int cmd:5; -}Reg_UpdtShadowStat; - -typedef union { - Reg_DrawPrimitive vert; - Reg_DrawIndexPrimitive vertIdx; - Reg_SetRegister set; - Reg_QueuedPageFlip pageFlip; - Reg_MasterImgXfer masterImgXfer; - Reg_ScaledImgXfer scaledImgXfer; - Reg_UpdtShadowStat updtShadow; - Reg_MacroBlock macroBlk; - Reg_2D cmd2D; - Reg_Wait wait; -}CmdHeaderUnion; - - -/*frank 2001/11/14 add BCI write macros*/ -/* Registers not used in the X server - */ - -#define SAVAGE_NOP_ID 0x2094 -#define SAVAGE_NOP_ID_MASK ((1<<22)-1) - - -/* 3D instructions - */ - -/* Draw Primitive Control */ - - -#define SAVAGE_HW_NO_Z (1<<0) -#define SAVAGE_HW_NO_W (1<<1) -#define SAVAGE_HW_NO_CD (1<<2) -#define SAVAGE_HW_NO_CS (1<<3) -#define SAVAGE_HW_NO_U0 (1<<4) -#define SAVAGE_HW_NO_V0 (1<<5) -#define SAVAGE_HW_NO_UV0 ((1<<4) | (1<<5)) -#define SAVAGE_HW_NO_U1 (1<<6) -#define SAVAGE_HW_NO_V1 (1<<7) -#define SAVAGE_HW_NO_UV1 ((1<<6) | (1<<7)) -#define SAVAGE_HW_SKIPFLAGS 0x000000ff - -#endif - - - - - - diff --git a/src/mesa/drivers/dri/savage/savage_init.h b/src/mesa/drivers/dri/savage/savage_init.h deleted file mode 100644 index bfd3077d70c..00000000000 --- a/src/mesa/drivers/dri/savage/savage_init.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SAVAGE_INIT_H_ -#define _SAVAGE_INIT_H_ - -#include <sys/time.h> -#include "dri_util.h" -#include "main/mtypes.h" - -#include "xmlconfig.h" - -typedef struct { - drm_handle_t handle; - drmSize size; - char *map; -} savageRegion, *savageRegionPtr; - -typedef struct { - int chipset; - int width; - int height; - int mem; - - int cpp; /* for front and back buffers */ - int zpp; - - int agpMode; - - unsigned int bufferSize; - -#if 0 - int bitsPerPixel; -#endif - unsigned int frontFormat; - unsigned int frontOffset; - unsigned int backOffset; - unsigned int depthOffset; - - unsigned int aperturePitch; - - unsigned int textureOffset[SAVAGE_NR_TEX_HEAPS]; - unsigned int textureSize[SAVAGE_NR_TEX_HEAPS]; - unsigned int logTextureGranularity[SAVAGE_NR_TEX_HEAPS]; - drmAddress texVirtual[SAVAGE_NR_TEX_HEAPS]; - - __DRIscreen *driScrnPriv; - - savageRegion aperture; - savageRegion agpTextures; - - drmBufMapPtr bufs; - - unsigned int sarea_priv_offset; - - /* Configuration cache with default values for all contexts */ - driOptionCache optionCache; -} savageScreenPrivate; - - -#include "savagecontext.h" - -extern void savageGetLock( savageContextPtr imesa, GLuint flags ); -extern void savageXMesaSetClipRects(savageContextPtr imesa); - - -#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 LOCK_HARDWARE( imesa ) \ - do { \ - char __ret=0; \ - DRM_CAS(imesa->driHwLock, imesa->hHWContext, \ - (DRM_LOCK_HELD|imesa->hHWContext), __ret); \ - if (__ret) \ - savageGetLock( imesa, 0 ); \ - } while (0) - - - -/* 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 ); \ - savageRegetLockQuiescent( imesa ); \ -} while(0) - -/* The following definitions are copied from savage_regs.h in the XFree86 - * driver. They are unlikely to change. If they do we need to keep them in - * sync. */ - -#define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) - -#define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) \ - || (chip==S3_PROSAVAGE) \ - || (chip==S3_TWISTER) \ - || (chip==S3_PROSAVAGEDDR)) - -#define S3_SAVAGE_MOBILE_SERIES(chip) ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE)) - -#define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000)) - -#define S3_MOBILE_TWISTER_SERIES(chip) ((chip==S3_TWISTER) \ - ||(chip==S3_PROSAVAGEDDR)) - -/* Chip tags. These are used to group the adapters into - * related families. - */ - -enum S3CHIPTAGS { - S3_UNKNOWN = 0, - S3_SAVAGE3D, - S3_SAVAGE_MX, - S3_SAVAGE4, - S3_PROSAVAGE, - S3_TWISTER, - S3_PROSAVAGEDDR, - S3_SUPERSAVAGE, - S3_SAVAGE2000, - S3_LAST -}; - -#endif diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c deleted file mode 100644 index 681ed9aae34..00000000000 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ /dev/null @@ -1,1013 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include <stdio.h> - -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/simple_list.h" - -#include "utils.h" - -#include "main/extensions.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "vbo/vbo.h" - -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" -#include "drivers/common/meta.h" - -#include "savagedd.h" -#include "savagestate.h" -#include "savagetex.h" -#include "savagespan.h" -#include "savagetris.h" -#include "savageioctl.h" - -#include "savage_dri.h" - -#include "drirenderbuffer.h" -#include "texmem.h" - -#define need_GL_EXT_secondary_color -#include "main/remap_helper.h" - -#include "xmlpool.h" - -/* Driver-specific options - */ -#define SAVAGE_ENABLE_VDMA(def) \ -DRI_CONF_OPT_BEGIN(enable_vdma,bool,def) \ - DRI_CONF_DESC(en,"Use DMA for vertex transfers") \ - DRI_CONF_DESC(de,"Benutze DMA für Vertextransfers") \ -DRI_CONF_OPT_END -#define SAVAGE_ENABLE_FASTPATH(def) \ -DRI_CONF_OPT_BEGIN(enable_fastpath,bool,def) \ - DRI_CONF_DESC(en,"Use fast path for unclipped primitives") \ - DRI_CONF_DESC(de,"Schneller Codepfad für ungeschnittene Polygone") \ -DRI_CONF_OPT_END -#define SAVAGE_SYNC_FRAMES(def) \ -DRI_CONF_OPT_BEGIN(sync_frames,bool,def) \ - DRI_CONF_DESC(en,"Synchronize with graphics hardware after each frame") \ - DRI_CONF_DESC(de,"Synchronisiere nach jedem Frame mit Grafikhardware") \ -DRI_CONF_OPT_END - -/* Configuration - */ -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_QUALITY - DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) - DRI_CONF_FLOAT_DEPTH(false) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_PERFORMANCE - SAVAGE_ENABLE_VDMA(true) - SAVAGE_ENABLE_FASTPATH(true) - SAVAGE_SYNC_FRAMES(false) - DRI_CONF_MAX_TEXTURE_UNITS(2,1,2) - DRI_CONF_TEXTURE_HEAPS(DRI_CONF_TEXTURE_HEAPS_ALL) - DRI_CONF_FORCE_S3TC_ENABLE(false) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) - DRI_CONF_SECTION_END -DRI_CONF_END; -static const GLuint __driNConfigOptions = 10; - - -static const struct dri_debug_control debug_control[] = -{ - { "fall", DEBUG_FALLBACKS }, - { "api", DEBUG_VERBOSE_API }, - { "tex", DEBUG_VERBOSE_TEX }, - { "verb", DEBUG_VERBOSE_MSG }, - { "dma", DEBUG_DMA }, - { "state", DEBUG_STATE }, - { NULL, 0 } -}; -#ifndef SAVAGE_DEBUG -int SAVAGE_DEBUG = 0; -#endif - - -/*For time caculating test*/ -#if defined(DEBUG_TIME) && DEBUG_TIME -struct timeval tv_s,tv_f; -unsigned long time_sum=0; -struct timeval tv_s1,tv_f1; -#endif - -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_EXT_texture_lod_bias", NULL }, - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { NULL, NULL } -}; - -static const struct dri_extension s4_extensions[] = -{ - { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - { NULL, NULL } -}; - -extern struct tnl_pipeline_stage _savage_texnorm_stage; -extern struct tnl_pipeline_stage _savage_render_stage; - -static const struct tnl_pipeline_stage *savage_pipeline[] = { - - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_savage_texnorm_stage, - &_savage_render_stage, - &_tnl_render_stage, - 0, -}; - - -PUBLIC const __DRIextension *savageScreenExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - &driReadDrawableExtension, -}; - -static GLboolean -savageInitDriver(__DRIscreen *sPriv) -{ - savageScreenPrivate *savageScreen; - SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv; - - if (sPriv->devPrivSize != sizeof(SAVAGEDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(SAVAGEDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - savageScreen = (savageScreenPrivate *)malloc(sizeof(savageScreenPrivate)); - if (!savageScreen) - return GL_FALSE; - - savageScreen->driScrnPriv = sPriv; - sPriv->private = (void *)savageScreen; - - savageScreen->chipset=gDRIPriv->chipset; - savageScreen->width=gDRIPriv->width; - savageScreen->height=gDRIPriv->height; - savageScreen->mem=gDRIPriv->mem; - savageScreen->cpp=gDRIPriv->cpp; - savageScreen->zpp=gDRIPriv->zpp; - - savageScreen->agpMode=gDRIPriv->agpMode; - - savageScreen->bufferSize=gDRIPriv->bufferSize; - - if (gDRIPriv->cpp == 4) - savageScreen->frontFormat = DV_PF_8888; - else - savageScreen->frontFormat = DV_PF_565; - savageScreen->frontOffset=gDRIPriv->frontOffset; - savageScreen->backOffset = gDRIPriv->backOffset; - savageScreen->depthOffset=gDRIPriv->depthOffset; - - savageScreen->textureOffset[SAVAGE_CARD_HEAP] = - gDRIPriv->textureOffset; - savageScreen->textureSize[SAVAGE_CARD_HEAP] = - gDRIPriv->textureSize; - savageScreen->logTextureGranularity[SAVAGE_CARD_HEAP] = - gDRIPriv->logTextureGranularity; - - savageScreen->textureOffset[SAVAGE_AGP_HEAP] = - gDRIPriv->agpTextureHandle; - savageScreen->textureSize[SAVAGE_AGP_HEAP] = - gDRIPriv->agpTextureSize; - savageScreen->logTextureGranularity[SAVAGE_AGP_HEAP] = - gDRIPriv->logAgpTextureGranularity; - - savageScreen->agpTextures.handle = gDRIPriv->agpTextureHandle; - savageScreen->agpTextures.size = gDRIPriv->agpTextureSize; - if (gDRIPriv->agpTextureSize) { - if (drmMap(sPriv->fd, - savageScreen->agpTextures.handle, - savageScreen->agpTextures.size, - (drmAddress *)&(savageScreen->agpTextures.map)) != 0) { - free(savageScreen); - sPriv->private = NULL; - return GL_FALSE; - } - } else - savageScreen->agpTextures.map = NULL; - - savageScreen->texVirtual[SAVAGE_CARD_HEAP] = - (drmAddress)(((GLubyte *)sPriv->pFB)+gDRIPriv->textureOffset); - savageScreen->texVirtual[SAVAGE_AGP_HEAP] = - (drmAddress)(savageScreen->agpTextures.map); - - savageScreen->aperture.handle = gDRIPriv->apertureHandle; - savageScreen->aperture.size = gDRIPriv->apertureSize; - savageScreen->aperturePitch = gDRIPriv->aperturePitch; - if (drmMap(sPriv->fd, - savageScreen->aperture.handle, - savageScreen->aperture.size, - (drmAddress *)&savageScreen->aperture.map) != 0) - { - free(savageScreen); - sPriv->private = NULL; - return GL_FALSE; - } - - savageScreen->bufs = drmMapBufs(sPriv->fd); - - savageScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&savageScreen->optionCache, - __driConfigOptions, __driNConfigOptions); - - sPriv->extensions = savageScreenExtensions; - -#if 0 - savageDDFastPathInit(); - savageDDTrifuncInit(); - savageDDSetupInit(); -#endif - return GL_TRUE; -} - -/* Accessed by dlsym from dri_mesa_init.c - */ -static void -savageDestroyScreen(__DRIscreen *sPriv) -{ - savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private; - - if (savageScreen->bufs) - drmUnmapBufs(savageScreen->bufs); - - /* free all option information */ - driDestroyOptionInfo (&savageScreen->optionCache); - - free(savageScreen); - sPriv->private = NULL; -} - -static GLboolean -savageCreateContext( gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - struct gl_context *ctx, *shareCtx; - savageContextPtr imesa; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - struct dd_function_table functions; - savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private; - drm_savage_sarea_t *saPriv=(drm_savage_sarea_t *)(((char*)sPriv->pSAREA)+ - savageScreen->sarea_priv_offset); - int textureSize[SAVAGE_NR_TEX_HEAPS]; - int i; - imesa = (savageContextPtr)calloc(1, sizeof(savageContext)); - if (!imesa) { - return GL_FALSE; - } - - /* Init default driver functions then plug in savage-specific texture - * functions that are needed as early as during context creation. */ - _mesa_init_driver_functions( &functions ); - savageDDInitTextureFuncs( &functions ); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((savageContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - ctx = _mesa_create_context(api, mesaVis, shareCtx, &functions, imesa); - if (!ctx) { - free(imesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = imesa; - - imesa->cmdBuf.size = SAVAGE_CMDBUF_SIZE; - imesa->cmdBuf.base = imesa->cmdBuf.write = - malloc(SAVAGE_CMDBUF_SIZE * sizeof(drm_savage_cmd_header_t)); - if (!imesa->cmdBuf.base) - return GL_FALSE; - - /* Parse configuration files */ - driParseConfigFiles (&imesa->optionCache, &savageScreen->optionCache, - sPriv->myNum, "savage"); - - imesa->float_depth = driQueryOptionb(&imesa->optionCache, "float_depth") && - savageScreen->chipset >= S3_SAVAGE4; - imesa->no_rast = driQueryOptionb(&imesa->optionCache, "no_rast"); - -#if 0 - 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; -#endif - - ctx->Const.MaxDrawBuffers = 1; - - /* Dri stuff - */ - imesa->hHWContext = driContextPriv->hHWContext; - imesa->driFd = sPriv->fd; - imesa->driHwLock = &sPriv->pSAREA->lock; - - imesa->savageScreen = savageScreen; - imesa->driScreen = sPriv; - imesa->sarea = saPriv; - imesa->glBuffer = NULL; - - /* DMA buffer */ - - for(i=0;i<5;i++) - { - imesa->apertureBase[i] = (GLubyte *)savageScreen->aperture.map + - 0x01000000 * i; - } - - imesa->aperturePitch = savageScreen->aperturePitch; - - /* change texHeap initialize to support two kind of texture heap*/ - /* here is some parts of initialization, others in InitDriver() */ - - (void) memset( imesa->textureHeaps, 0, sizeof( imesa->textureHeaps ) ); - make_empty_list( & imesa->swapped ); - - textureSize[SAVAGE_CARD_HEAP] = savageScreen->textureSize[SAVAGE_CARD_HEAP]; - textureSize[SAVAGE_AGP_HEAP] = savageScreen->textureSize[SAVAGE_AGP_HEAP]; - imesa->lastTexHeap = savageScreen->texVirtual[SAVAGE_AGP_HEAP] ? 2 : 1; - switch(driQueryOptioni (&imesa->optionCache, "texture_heaps")) { - case DRI_CONF_TEXTURE_HEAPS_CARD: /* only use card memory, if available */ - if (textureSize[SAVAGE_CARD_HEAP]) - imesa->lastTexHeap = 1; - break; - case DRI_CONF_TEXTURE_HEAPS_GART: /* only use gart memory, if available */ - if (imesa->lastTexHeap == 2 && textureSize[SAVAGE_AGP_HEAP]) - textureSize[SAVAGE_CARD_HEAP] = 0; - break; - /*default: Nothing to do, use all available memory. */ - } - - for (i = 0; i < imesa->lastTexHeap; i++) { - imesa->textureHeaps[i] = driCreateTextureHeap( - i, imesa, - textureSize[i], - 11, /* 2^11 = 2k alignment */ - SAVAGE_NR_TEX_REGIONS, - (drmTextureRegionPtr)imesa->sarea->texList[i], - &imesa->sarea->texAge[i], - &imesa->swapped, - sizeof( savageTexObj ), - (destroy_texture_object_t *) savageDestroyTexObj ); - /* If textureSize[i] == 0 textureHeaps[i] is NULL. This can happen - * if there is not enough card memory for a card texture heap. */ - if (imesa->textureHeaps[i]) - driSetTextureSwapCounterLocation( imesa->textureHeaps[i], - & imesa->c_textureSwaps ); - } - imesa->texture_depth = driQueryOptioni (&imesa->optionCache, - "texture_depth"); - if (imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB) - imesa->texture_depth = ( savageScreen->cpp == 4 ) ? - DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16; - - if (savageScreen->chipset >= S3_SAVAGE4) - ctx->Const.MaxTextureUnits = 2; - else - ctx->Const.MaxTextureUnits = 1; - if (driQueryOptioni(&imesa->optionCache, "texture_units") < - ctx->Const.MaxTextureUnits) - ctx->Const.MaxTextureUnits = - driQueryOptioni(&imesa->optionCache, "texture_units"); - ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; - ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; - - driCalculateMaxTextureLevels( imesa->textureHeaps, - imesa->lastTexHeap, - & ctx->Const, - 4, - 11, /* max 2D texture size is 2048x2048 */ - 0, /* 3D textures unsupported. */ - 0, /* cube textures unsupported. */ - 0, /* texture rectangles unsupported. */ - 12, - GL_FALSE, - 0 ); - if (ctx->Const.MaxTextureLevels <= 6) { /*spec requires at least 64x64*/ - __driUtilMessage("Not enough texture memory. " - "Falling back to indirect rendering."); - free(imesa); - return GL_FALSE; - } - - imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24; - imesa->depth_scale = (imesa->savageScreen->zpp == 2) ? - (1.0F/0xffff):(1.0F/0xffffff); - - imesa->bufferSize = savageScreen->bufferSize; - imesa->dmaVtxBuf.total = 0; - imesa->dmaVtxBuf.used = 0; - imesa->dmaVtxBuf.flushed = 0; - - imesa->clientVtxBuf.total = imesa->bufferSize / 4; - imesa->clientVtxBuf.used = 0; - imesa->clientVtxBuf.flushed = 0; - imesa->clientVtxBuf.buf = (uint32_t *)malloc(imesa->bufferSize); - - imesa->vtxBuf = &imesa->clientVtxBuf; - - imesa->firstElt = -1; - - /* Uninitialized vertex format. Force setting the vertex state in - * savageRenderStart. - */ - imesa->vertex_size = 0; - - /* Utah stuff - */ - imesa->new_state = ~0; - imesa->new_gl_state = ~0; - imesa->RenderIndex = ~0; - imesa->dirty = ~0; - imesa->lostContext = GL_TRUE; - imesa->CurrentTexObj[0] = 0; - imesa->CurrentTexObj[1] = 0; - - _mesa_meta_init( ctx ); - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, savage_pipeline ); - - imesa->enable_fastpath = driQueryOptionb(&imesa->optionCache, - "enable_fastpath"); - /* DRM versions before 2.1.3 would only render triangle lists. ELTS - * support was added in 2.2.0. */ - if (imesa->enable_fastpath && sPriv->drm_version.minor < 2) { - fprintf (stderr, - "*** Disabling fast path because your DRM version is buggy " - "or doesn't\n*** support ELTS. You need at least Savage DRM " - "version 2.2.\n"); - imesa->enable_fastpath = GL_FALSE; - } - - if (!savageScreen->bufs || savageScreen->chipset == S3_SUPERSAVAGE) - imesa->enable_vdma = GL_FALSE; - else - imesa->enable_vdma = driQueryOptionb(&imesa->optionCache, "enable_vdma"); - - imesa->sync_frames = driQueryOptionb(&imesa->optionCache, "sync_frames"); - - /* Configure swrast to match hardware characteristics: - */ - _tnl_allow_pixel_fog( ctx, GL_FALSE ); - _tnl_allow_vertex_fog( ctx, GL_TRUE ); - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - - ctx->DriverCtx = (void *) imesa; - imesa->glCtx = ctx; - -#ifndef SAVAGE_DEBUG - SAVAGE_DEBUG = driParseDebugString( getenv( "SAVAGE_DEBUG" ), - debug_control ); -#endif - - driInitExtensions( ctx, card_extensions, GL_TRUE ); - if (savageScreen->chipset >= S3_SAVAGE4) - driInitExtensions( ctx, s4_extensions, GL_FALSE ); - if (ctx->Mesa_DXTn || - driQueryOptionb (&imesa->optionCache, "force_s3tc_enable")) { - _mesa_enable_extension( ctx, "GL_S3_s3tc" ); - if (savageScreen->chipset >= S3_SAVAGE4) - /* This extension needs DXT3 and DTX5 support in hardware. - * Not available on Savage3D/MX/IX. */ - _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" ); - } - - savageDDInitStateFuncs( ctx ); - savageDDInitSpanFuncs( ctx ); - savageDDInitDriverFuncs( ctx ); - savageDDInitIoctlFuncs( ctx ); - savageInitTriFuncs( ctx ); - - savageDDInitState( imesa ); - - driContextPriv->driverPrivate = (void *) imesa; - - return GL_TRUE; -} - -static void -savageDestroyContext(__DRIcontext *driContextPriv) -{ - savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate; - GLuint i; - - assert (imesa); /* should never be NULL */ - if (imesa) { - savageFlushVertices(imesa); - savageReleaseIndexedVerts(imesa); - savageFlushCmdBuf(imesa, GL_TRUE); /* release DMA buffer */ - WAIT_IDLE_EMPTY(imesa); - - for (i = 0; i < imesa->lastTexHeap; i++) - driDestroyTextureHeap(imesa->textureHeaps[i]); - - free(imesa->cmdBuf.base); - free(imesa->clientVtxBuf.buf); - - _mesa_meta_free( imesa->glCtx ); - - _swsetup_DestroyContext(imesa->glCtx ); - _tnl_DestroyContext( imesa->glCtx ); - _vbo_DestroyContext( imesa->glCtx ); - _swrast_DestroyContext( imesa->glCtx ); - - /* free the Mesa context */ - imesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(imesa->glCtx); - - /* no longer use vertex_dma_buf*/ - free(imesa); - } -} - - -static GLboolean -savageCreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap) -{ - savageScreenPrivate *screen = (savageScreenPrivate *) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24; - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - /* - * XXX: this value needs to be set according to the config file - * setting. But we don't get that until we create a rendering - * context!!!! - */ - GLboolean float_depth = GL_FALSE; - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - (GLubyte *) screen->aperture.map - + 0x01000000 * TARGET_FRONT, - screen->cpp, - screen->frontOffset, screen->aperturePitch, - driDrawPriv); - savageSetSpanFunctions(frontRb, mesaVis, float_depth); - assert(frontRb->Base.Data); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - (GLubyte *) screen->aperture.map - + 0x01000000 * TARGET_BACK, - screen->cpp, - screen->backOffset, screen->aperturePitch, - driDrawPriv); - savageSetSpanFunctions(backRb, mesaVis, float_depth); - assert(backRb->Base.Data); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, - (GLubyte *) screen->aperture.map - + 0x01000000 * TARGET_DEPTH, - screen->zpp, - screen->depthOffset, screen->aperturePitch, - driDrawPriv); - savageSetSpanFunctions(depthRb, mesaVis, float_depth); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_S8_Z24, - (GLubyte *) screen->aperture.map - + 0x01000000 * TARGET_DEPTH, - screen->zpp, - screen->depthOffset, screen->aperturePitch, - driDrawPriv); - savageSetSpanFunctions(depthRb, mesaVis, float_depth); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0 && !swStencil) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(MESA_FORMAT_S8, - (GLubyte *) screen->aperture.map - + 0x01000000 * TARGET_DEPTH, - screen->zpp, - screen->depthOffset, screen->aperturePitch, - driDrawPriv); - savageSetSpanFunctions(stencilRb, mesaVis, float_depth); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - swStencil, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - -static void -savageDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -#if 0 -void XMesaSwapBuffers(__DRIdrawable *driDrawPriv) -{ - /* XXX should do swap according to the buffer, not the context! */ - savageContextPtr imesa = savageCtx; - - FLUSH_VB( imesa->glCtx, "swap buffers" ); - savageSwapBuffers(imesa); -} -#endif - - -void savageXMesaSetClipRects(savageContextPtr imesa) -{ - __DRIdrawable *dPriv = imesa->driDrawable; - - if ((dPriv->numBackClipRects == 0) - || (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)) { - 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; - } - - savageCalcViewport( imesa->glCtx ); -} - - -static void savageXMesaWindowMoved( savageContextPtr imesa ) -{ - __DRIdrawable *const drawable = imesa->driDrawable; - __DRIdrawable *const readable = imesa->driReadable; - - if (0) - fprintf(stderr, "savageXMesaWindowMoved\n\n"); - - savageXMesaSetClipRects(imesa); - - driUpdateFramebufferSize(imesa->glCtx, drawable); - if (drawable != readable) { - driUpdateFramebufferSize(imesa->glCtx, readable); - } -} - - -static GLboolean -savageUnbindContext(__DRIcontext *driContextPriv) -{ - savageContextPtr savage = (savageContextPtr) driContextPriv->driverPrivate; - if (savage) - savage->dirty = ~0; - - return GL_TRUE; -} - -#if 0 -static GLboolean -savageOpenFullScreen(__DRIcontext *driContextPriv) -{ - - - - if (driContextPriv) { - savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate; - imesa->IsFullScreen = GL_TRUE; - imesa->backup_frontOffset = imesa->savageScreen->frontOffset; - imesa->backup_backOffset = imesa->savageScreen->backOffset; - imesa->backup_frontBitmapDesc = imesa->savageScreen->frontBitmapDesc; - imesa->savageScreen->frontBitmapDesc = imesa->savageScreen->backBitmapDesc; - imesa->toggle = TARGET_BACK; - } - - return GL_TRUE; -} - -static GLboolean -savageCloseFullScreen(__DRIcontext *driContextPriv) -{ - - if (driContextPriv) { - savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate; - WAIT_IDLE_EMPTY(imesa); - imesa->IsFullScreen = GL_FALSE; - imesa->savageScreen->frontOffset = imesa->backup_frontOffset; - imesa->savageScreen->backOffset = imesa->backup_backOffset; - imesa->savageScreen->frontBitmapDesc = imesa->backup_frontBitmapDesc; - } - return GL_TRUE; -} -#endif - -static GLboolean -savageMakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv) -{ - if (driContextPriv) { - savageContextPtr imesa - = (savageContextPtr) driContextPriv->driverPrivate; - struct gl_framebuffer *drawBuffer - = (struct gl_framebuffer *) driDrawPriv->driverPrivate; - struct gl_framebuffer *readBuffer - = (struct gl_framebuffer *) driReadPriv->driverPrivate; - driRenderbuffer *frontRb = (driRenderbuffer *) - drawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; - driRenderbuffer *backRb = (driRenderbuffer *) - drawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer; - - assert(frontRb->Base.Data); - if (imesa->glCtx->Visual.doubleBufferMode) { - assert(backRb->Base.Data); - } - - imesa->driReadable = driReadPriv; - imesa->driDrawable = driDrawPriv; - imesa->dirty = ~0; - - _mesa_make_current(imesa->glCtx, drawBuffer, readBuffer); - - savageXMesaWindowMoved( imesa ); - } - else - { - _mesa_make_current(NULL, NULL, NULL); - } - return GL_TRUE; -} - - -void savageGetLock( savageContextPtr imesa, GLuint flags ) -{ - __DRIdrawable *const drawable = imesa->driDrawable; - __DRIdrawable *const readable = imesa->driReadable; - __DRIscreen *sPriv = imesa->driScreen; - drm_savage_sarea_t *sarea = imesa->sarea; - int me = imesa->hHWContext; - int stamp = drawable->lastStamp; - int heap; - unsigned int timestamp = 0; - - - - /* 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: - */ - DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable); - if (drawable != readable) { - DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable); - } - - - /* 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 |= (SAVAGE_UPLOAD_LOCAL | - SAVAGE_UPLOAD_GLOBAL | - SAVAGE_UPLOAD_FOGTBL | - SAVAGE_UPLOAD_TEX0 | - SAVAGE_UPLOAD_TEX1 | - SAVAGE_UPLOAD_TEXGLOBAL); - imesa->lostContext = GL_TRUE; - sarea->ctxOwner = me; - } - - for (heap = 0; heap < imesa->lastTexHeap; ++heap) { - /* If a heap was changed, update its timestamp. Do this before - * DRI_AGE_TEXTURES updates the local_age. */ - if (imesa->textureHeaps[heap] && - imesa->textureHeaps[heap]->global_age[0] > - imesa->textureHeaps[heap]->local_age) { - if (timestamp == 0) - timestamp = savageEmitEventLocked(imesa, 0); - imesa->textureHeaps[heap]->timestamp = timestamp; - } - DRI_AGE_TEXTURES( imesa->textureHeaps[heap] ); - } - - if (drawable->lastStamp != stamp) { - driUpdateFramebufferSize(imesa->glCtx, drawable); - savageXMesaWindowMoved( imesa ); - } -} - -static const __DRIconfig ** -savageFillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - struct gl_config * m; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - int i; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - * - * FK: What about drivers that don't use page flipping? Could they - * just expose GLX_SWAP_COPY_OML? - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGR; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const __DRIconfig **) configs; -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -savageInitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { 2, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 2, 1, 0 }; - SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions2( "Savage", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) - return NULL; - - if (!savageInitDriver(psp)) - return NULL; - - return savageFillInModes( psp, - dri_priv->cpp*8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); -} - -const struct __DriverAPIRec driDriverAPI = { - savageInitScreen, - savageDestroyScreen, - savageCreateContext, - savageDestroyContext, - savageCreateBuffer, - savageDestroyBuffer, - savageSwapBuffers, - savageMakeCurrent, - savageUnbindContext -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/savage/savagecontext.h b/src/mesa/drivers/dri/savage/savagecontext.h deleted file mode 100644 index 75bec62fa84..00000000000 --- a/src/mesa/drivers/dri/savage/savagecontext.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef SAVAGECONTEXT_INC -#define SAVAGECONTEXT_INC - -typedef struct savage_context_t savageContext; -typedef struct savage_context_t *savageContextPtr; -typedef struct savage_texture_object_t *savageTextureObjectPtr; - -#include "dri_util.h" -#include "main/mtypes.h" -#include "xf86drm.h" -#include "drm.h" -#include "savage_drm.h" -#include "savage_init.h" -#include "savage_3d_reg.h" -#include "main/mm.h" -#include "tnl/t_vertex.h" - -#include "texmem.h" - -#include "xmlconfig.h" - -/* Reasons to fallback on all primitives. - */ -#define SAVAGE_FALLBACK_TEXTURE 0x1 -#define SAVAGE_FALLBACK_DRAW_BUFFER 0x2 -#define SAVAGE_FALLBACK_READ_BUFFER 0x4 -#define SAVAGE_FALLBACK_COLORMASK 0x8 -#define SAVAGE_FALLBACK_SPECULAR 0x10 -#define SAVAGE_FALLBACK_LOGICOP 0x20 -/*frank 2001/11/12 add the stencil fallbak*/ -#define SAVAGE_FALLBACK_STENCIL 0x40 -#define SAVAGE_FALLBACK_RENDERMODE 0x80 -#define SAVAGE_FALLBACK_BLEND_EQ 0x100 -#define SAVAGE_FALLBACK_NORAST 0x200 -#define SAVAGE_FALLBACK_PROJ_TEXTURE 0x400 - - -#define HW_CULL 1 - -/* for savagectx.new_state - manage GL->driver state changes - */ -#define SAVAGE_NEW_TEXTURE 0x1 -#define SAVAGE_NEW_CULL 0x2 - -/* What needs to be changed for the current vertex dma buffer? - * This will go away! - */ -#define SAVAGE_UPLOAD_LOCAL 0x1 /* DrawLocalCtrl (S4) or - DrawCtrl and ZBufCtrl (S3D) */ -#define SAVAGE_UPLOAD_TEX0 0x2 /* texture unit 0 */ -#define SAVAGE_UPLOAD_TEX1 0x4 /* texture unit 1 (S4 only) */ -#define SAVAGE_UPLOAD_FOGTBL 0x8 /* fog table */ -#define SAVAGE_UPLOAD_GLOBAL 0x10 /* most global regs */ -#define SAVAGE_UPLOAD_TEXGLOBAL 0x20 /* TexBlendColor (S4 only) */ - -/*define the max numer of vertex in vertex buf*/ -#define SAVAGE_MAX_VERTEXS 0x10000 - -/* Don't make it too big. We don't want to buffer up a whole frame - * that would force the application to wait later. */ -#define SAVAGE_CMDBUF_SIZE 1024 - -/* Use the templated vertex formats: - */ -#define TAG(x) savage##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -typedef void (*savage_tri_func)( savageContextPtr, savageVertex *, - savageVertex *, savageVertex * ); -typedef void (*savage_line_func)( savageContextPtr, - savageVertex *, savageVertex * ); -typedef void (*savage_point_func)( savageContextPtr, savageVertex * ); - - -/************************************************************** - **************** enums for chip IDs ************************ - **************************************************************/ - -#define CHIP_S3GX3MS1NB 0x8A25 -#define CHIP_S3GX3MS1NBK 0x8A26 -#define CHIP_S3TWISTER 0x8D01 -#define CHIP_S3TWISTERK 0x8D02 -#define CHIP_S3TWISTER_P4M 0x8D04 -#define CHIP_S3PARAMOUNT128 0x8C22 /*SuperSavage 128/MX*/ -#define CHIP_S3TRISTAR128SDR 0x8C2A /*SuperSavage 128/IX*/ -#define CHIP_S3TRISTAR64SDRM7 0x8C2C /*SuperSavage/IX M7 Package*/ -#define CHIP_S3TRISTAR64SDR 0x8C2E /*SuperSavage/IX*/ -#define CHIP_S3TRISTAR64CDDR 0x8C2F /*SuperSavage/IXC DDR*/ - -#define IS_SAVAGE(imesa) (imesa->savageScreen->deviceID == CHIP_S3GX3MS1NB || \ - imesa->savageScreen->deviceID == CHIP_S3GX3MS1NBK || \ - imesa->savageScreen->deviceID == CHIP_S3TWISTER || \ - imesa->savageScreen->deviceID == CHIP_S3TWISTERK || \ - imesa->savageScreen->deviceID == CHIP_S3TWISTER_P4M || \ - imesa->savageScreen->deviceID == CHIP_S3PARAMOUNT128 || \ - imesa->savageScreen->deviceID == CHIP_S3TRISTAR128SDR || \ - imesa->savageScreen->deviceID == CHIP_S3TRISTAR64SDRM7 || \ - imesa->savageScreen->deviceID == CHIP_S3TRISTAR64SDR || \ - imesa->savageScreen->deviceID == CHIP_S3TRISTAR64CDDR ) - - -struct savage_vtxbuf_t { - GLuint total, used, flushed; /* in 32 bit units */ - GLuint idx; /* for DMA buffers */ - uint32_t *buf; -}; - -struct savage_cmdbuf_t { - GLuint size; /* size in qwords */ - drm_savage_cmd_header_t *base; /* initial state starts here */ - drm_savage_cmd_header_t *start; /* drawing/state commands start here */ - drm_savage_cmd_header_t *write; /* append stuff here */ -}; - -struct savage_elt_t { - GLuint n; /* number of elts currently allocated */ - drm_savage_cmd_header_t *cmd; /* the indexed drawing command */ -}; - - -struct savage_context_t { - GLint refcount; - - struct gl_context *glCtx; - - int lastTexHeap; - driTexHeap *textureHeaps[SAVAGE_NR_TEX_HEAPS]; - driTextureObject swapped; - - driTextureObject *CurrentTexObj[2]; - - /* Hardware state - */ - - savageRegisters regs, oldRegs, globalRegMask; - - /* Manage our own state */ - GLuint new_state; - GLuint new_gl_state; - GLboolean ptexHack; - - /* Command buffer */ - struct savage_cmdbuf_t cmdBuf; - - /* Elt book-keeping */ - struct savage_elt_t elts; - GLint firstElt; - - /* Vertex buffers */ - struct savage_vtxbuf_t dmaVtxBuf, clientVtxBuf; - struct savage_vtxbuf_t *vtxBuf; - - /* aperture base */ - GLubyte *apertureBase[5]; - GLuint aperturePitch; - /* Manage hardware state */ - GLuint dirty; - GLboolean lostContext; - GLuint bTexEn1; - /* One of the few bits of hardware state that can't be calculated - * completely on the fly: - */ - GLuint LcsCullMode; - GLuint texEnvColor; - - /* Vertex state - */ - GLuint vertex_size; - struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; - GLuint vertex_attr_count; - char *verts; /* points to tnl->clipspace.vertex_buf */ - - /* Rasterization state - */ - GLuint SetupNewInputs; - GLuint SetupIndex; - GLuint RenderIndex; - - GLuint hw_primitive; - GLenum raster_primitive; - GLenum render_primitive; - - GLuint skip; - GLubyte HwPrim; - GLuint HwVertexSize; - - /* Fallback rasterization functions - */ - savage_point_func draw_point; - savage_line_func draw_line; - savage_tri_func draw_tri; - - /* Funny mesa mirrors - */ - GLuint MonoColor; - GLuint ClearColor; - GLfloat depth_scale; - GLfloat hw_viewport[16]; - /* DRI stuff */ - GLuint bufferSize; - - struct gl_framebuffer *glBuffer; - - /* Two flags to keep track of fallbacks. */ - GLuint Fallback; - - GLuint needClip; - - /* These refer to the current draw (front vs. back) buffer: - */ - int drawX; /* origin of drawable in draw buffer */ - int drawY; - GLuint numClipRects; /* cliprects for that buffer */ - GLint currentClip; - drm_clip_rect_t *pClipRects; - - /* use this bit to support single/double buffer */ - GLuint IsDouble; - /* use this to indicate Fullscreen mode */ - GLuint IsFullScreen; /* FIXME - open/close fullscreen is gone, is this needed? */ - GLuint backup_frontOffset; - GLuint backup_backOffset; - GLuint backup_frontBitmapDesc; - GLuint toggle; - GLuint backup_streamFIFO; - GLuint NotFirstFrame; - - GLboolean inSwap; - GLuint lastSwap; - GLuint ctxAge; - GLuint dirtyAge; - GLuint any_contend; /* throttle me harder */ - - /* Scissor state needs to be mirrored so buffered commands can be - * emitted with the old scissor state when scissor state changes. - */ - struct { - GLboolean enabled; - GLint x, y; - GLsizei w, h; - } scissor; - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - GLuint driFd; - - __DRIdrawable *driDrawable; - __DRIdrawable *driReadable; - - __DRIscreen *driScreen; - savageScreenPrivate *savageScreen; - drm_savage_sarea_t *sarea; - - GLboolean hw_stencil; - - /* Performance counters - */ - GLuint c_textureSwaps; - - /* Configuration cache - */ - driOptionCache optionCache; - GLint texture_depth; - GLboolean no_rast; - GLboolean float_depth; - GLboolean enable_fastpath; - GLboolean enable_vdma; - GLboolean sync_frames; -}; - -#define SAVAGE_CONTEXT(ctx) ((savageContextPtr)(ctx->DriverCtx)) - -/* To remove all debugging, make sure SAVAGE_DEBUG is defined as a - * preprocessor symbol, and equal to zero. - */ -#ifndef SAVAGE_DEBUG -extern int SAVAGE_DEBUG; -#endif - -#define DEBUG_FALLBACKS 0x001 -#define DEBUG_VERBOSE_API 0x002 -#define DEBUG_VERBOSE_TEX 0x004 -#define DEBUG_VERBOSE_MSG 0x008 -#define DEBUG_DMA 0x010 -#define DEBUG_STATE 0x020 - -#define TARGET_FRONT 0x0 -#define TARGET_BACK 0x1 -#define TARGET_DEPTH 0x2 - -#define SUBPIXEL_X -0.5 -#define SUBPIXEL_Y -0.375 - -#endif diff --git a/src/mesa/drivers/dri/savage/savagedd.c b/src/mesa/drivers/dri/savage/savagedd.c deleted file mode 100644 index c7f58835054..00000000000 --- a/src/mesa/drivers/dri/savage/savagedd.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include "main/mtypes.h" -#include "main/framebuffer.h" - -#include <stdio.h> - -#include "main/mm.h" - -#include "savagedd.h" -#include "savagestate.h" -#include "savagetex.h" -#include "savagecontext.h" - -#include "utils.h" - - -/*************************************** - * Mesa's Driver Functions - ***************************************/ - - -static const GLubyte *savageDDGetString( struct gl_context *ctx, GLenum name ) -{ - static char *cardNames[S3_LAST] = { - "Unknown", - "Savage3D", - "Savage/MX/IX", - "Savage4", - "ProSavage", - "Twister", - "ProSavageDDR", - "SuperSavage", - "Savage2000" - }; - static char buffer[128]; - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - savageScreenPrivate *screen = imesa->savageScreen; - enum S3CHIPTAGS chipset = screen->chipset; - unsigned offset; - - if (chipset < S3_SAVAGE3D || chipset >= S3_LAST) - chipset = S3_UNKNOWN; /* should not happen */ - - switch (name) { - case GL_VENDOR: - return (GLubyte *)"S3 Graphics Inc."; - case GL_RENDERER: - offset = driGetRendererString( buffer, cardNames[chipset], - screen->agpMode ); - return (GLubyte *)buffer; - default: - return 0; - } -} -#if 0 -static GLint savageGetParameteri(const struct gl_context *ctx, GLint param) -{ - switch (param) { - case DD_HAVE_HARDWARE_FOG: - return 1; - default: - return 0; - } -} -#endif - - -void savageDDInitDriverFuncs( struct gl_context *ctx ) -{ - ctx->Driver.GetString = savageDDGetString; -} diff --git a/src/mesa/drivers/dri/savage/savagedd.h b/src/mesa/drivers/dri/savage/savagedd.h deleted file mode 100644 index c5261412999..00000000000 --- a/src/mesa/drivers/dri/savage/savagedd.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SAVAGEDD_INC -#define SAVAGEDD_INC - -#include "main/context.h" - -void savageDDInitDriverFuncs( struct gl_context *ctx ); -#endif diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c deleted file mode 100644 index 46bbb653b81..00000000000 --- a/src/mesa/drivers/dri/savage/savageioctl.c +++ /dev/null @@ -1,662 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> - -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/dd.h" -#include "main/context.h" -#include "main/colormac.h" -#include "main/mm.h" -#include "swrast/swrast.h" - -#include "savagecontext.h" -#include "savageioctl.h" -#include "savagestate.h" -#include "savagespan.h" - -#include "drm.h" -#include <sys/timeb.h> - -#define DEPTH_SCALE_16 ((1<<16)-1) -#define DEPTH_SCALE_24 ((1<<24)-1) - - -void savageGetDMABuffer( savageContextPtr imesa ) -{ - int idx = 0; - int size = 0; - drmDMAReq dma; - int retcode; - drmBufPtr buf; - - assert (imesa->savageScreen->bufs); - - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf(stderr, "Getting dma buffer\n"); - - dma.context = imesa->hHWContext; - dma.send_count = 0; - dma.send_list = NULL; - dma.send_sizes = NULL; - dma.flags = 0; - dma.request_count = 1; - dma.request_size = imesa->bufferSize; - dma.request_list = &idx; - dma.request_sizes = &size; - dma.granted_count = 0; - - - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n", - dma.context, dma.request_count, - dma.request_size); - - while (1) { - retcode = drmDMA(imesa->driFd, &dma); - - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf(stderr, "retcode %d sz %d idx %d count %d\n", - retcode, - dma.request_sizes[0], - dma.request_list[0], - dma.granted_count); - - if (retcode == 0 && - dma.request_sizes[0] && - dma.granted_count) - break; - - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf(stderr, "\n\nflush"); - } - - buf = &(imesa->savageScreen->bufs->list[idx]); - - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf(stderr, - "drmDMA (get) returns size[0] 0x%x idx[0] %d\n" - "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n", - dma.request_sizes[0], dma.request_list[0], - buf->idx, buf->total, - buf->used, buf->address); - - imesa->dmaVtxBuf.total = buf->total / 4; - imesa->dmaVtxBuf.used = 0; - imesa->dmaVtxBuf.flushed = 0; - imesa->dmaVtxBuf.idx = buf->idx; - imesa->dmaVtxBuf.buf = (uint32_t *)buf->address; - - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf(stderr, "finished getbuffer\n"); -} - -#if 0 -/* Still keeping this around because it demonstrates page flipping and - * automatic z-clear. */ -static void savage_BCI_clear(struct gl_context *ctx, drm_savage_clear_t *pclear) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - int nbox = imesa->sarea->nbox; - drm_clip_rect_t *pbox = imesa->sarea->boxes; - int i; - - - if (nbox > SAVAGE_NR_SAREA_CLIPRECTS) - nbox = SAVAGE_NR_SAREA_CLIPRECTS; - - for (i = 0 ; i < nbox ; i++, pbox++) { - unsigned int x = pbox->x1; - unsigned int y = pbox->y1; - unsigned int width = pbox->x2 - x; - unsigned int height = pbox->y2 - y; - uint32_t *bciptr; - - if (pbox->x1 > pbox->x2 || - pbox->y1 > pbox->y2 || - pbox->x2 > imesa->savageScreen->width || - pbox->y2 > imesa->savageScreen->height) - continue; - - if ( pclear->flags & SAVAGE_FRONT ) { - bciptr = savageDMAAlloc (imesa, 8); - WRITE_CMD((bciptr) , 0x4BCC8C00,uint32_t); - WRITE_CMD((bciptr) , imesa->savageScreen->frontOffset,uint32_t); - WRITE_CMD((bciptr) , imesa->savageScreen->frontBitmapDesc,uint32_t); - WRITE_CMD((bciptr) , pclear->clear_color,uint32_t); - WRITE_CMD((bciptr) , (y <<16) | x,uint32_t); - WRITE_CMD((bciptr) , (height << 16) | width,uint32_t); - savageDMACommit (imesa, bciptr); - } - if ( pclear->flags & SAVAGE_BACK ) { - bciptr = savageDMAAlloc (imesa, 8); - WRITE_CMD((bciptr) , 0x4BCC8C00,uint32_t); - WRITE_CMD((bciptr) , imesa->savageScreen->backOffset,uint32_t); - WRITE_CMD((bciptr) , imesa->savageScreen->backBitmapDesc,uint32_t); - WRITE_CMD((bciptr) , pclear->clear_color,uint32_t); - WRITE_CMD((bciptr) , (y <<16) | x,uint32_t); - WRITE_CMD((bciptr) , (height << 16) | width,uint32_t); - savageDMACommit (imesa, bciptr); - } - - if ( pclear->flags & (SAVAGE_DEPTH |SAVAGE_STENCIL) ) { - uint32_t writeMask = 0x0; - if(imesa->hw_stencil) - { - if(pclear->flags & SAVAGE_STENCIL) - { - - writeMask |= 0xFF000000; - } - if(pclear->flags & SAVAGE_DEPTH) - { - writeMask |= 0x00FFFFFF; - } - } - if(imesa->IsFullScreen && imesa->NotFirstFrame && - imesa->savageScreen->chipset >= S3_SAVAGE4) - { - imesa->regs.s4.zBufCtrl.ni.autoZEnable = GL_TRUE; - imesa->regs.s4.zBufCtrl.ni.frameID = - ~imesa->regs.s4.zBufCtrl.ni.frameID; - - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; - } - else - { - if(imesa->IsFullScreen) - imesa->NotFirstFrame = GL_TRUE; - - if(imesa->hw_stencil) - { - bciptr = savageDMAAlloc (imesa, 10); - if(writeMask != 0xFFFFFFFF) - { - WRITE_CMD((bciptr) , 0x960100D7,uint32_t); - WRITE_CMD((bciptr) , writeMask,uint32_t); - } - } - else - { - bciptr = savageDMAAlloc (imesa, 6); - } - - WRITE_CMD((bciptr) , 0x4BCC8C00,uint32_t); - WRITE_CMD((bciptr) , imesa->savageScreen->depthOffset,uint32_t); - WRITE_CMD((bciptr) , imesa->savageScreen->depthBitmapDesc,uint32_t); - WRITE_CMD((bciptr) , pclear->clear_depth,uint32_t); - WRITE_CMD((bciptr) , (y <<16) | x,uint32_t); - WRITE_CMD((bciptr) , (height << 16) | width,uint32_t); - if(imesa->hw_stencil) - { - if(writeMask != 0xFFFFFFFF) - { - WRITE_CMD((bciptr) , 0x960100D7,uint32_t); - WRITE_CMD((bciptr) , 0xFFFFFFFF,uint32_t); - } - } - savageDMACommit (imesa, bciptr); - } - } - } - /* FK: Make sure that the clear stuff is emitted. Otherwise a - software fallback may get overwritten by a delayed clear. */ - savageDMAFlush (imesa); -} - -static void savage_BCI_swap(savageContextPtr imesa) -{ - int nbox = imesa->sarea->nbox; - drm_clip_rect_t *pbox = imesa->sarea->boxes; - int i; - volatile uint32_t *bciptr; - - if (nbox > SAVAGE_NR_SAREA_CLIPRECTS) - nbox = SAVAGE_NR_SAREA_CLIPRECTS; - savageDMAFlush (imesa); - - if(imesa->IsFullScreen) - { /* full screen*/ - unsigned int tmp0; - tmp0 = imesa->savageScreen->frontOffset; - imesa->savageScreen->frontOffset = imesa->savageScreen->backOffset; - imesa->savageScreen->backOffset = tmp0; - - if(imesa->toggle == TARGET_BACK) - imesa->toggle = TARGET_FRONT; - else - imesa->toggle = TARGET_BACK; - - driFlipRenderbuffers(imesa->glCtx->DrawBuffer, - imesa->toggle != TARGET_FRONT); - - imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11; - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; - bciptr = SAVAGE_GET_BCI_POINTER(imesa,3); - *(bciptr) = 0x960100B0; - *(bciptr) = (imesa->savageScreen->frontOffset); - *(bciptr) = 0xA0000000; - } - - else - { /* Use bitblt copy from back to front buffer*/ - - for (i = 0 ; i < nbox; i++, pbox++) - { - unsigned int w = pbox->x2 - pbox->x1; - unsigned int h = pbox->y2 - pbox->y1; - - if (pbox->x1 > pbox->x2 || - pbox->y1 > pbox->y2 || - pbox->x2 > imesa->savageScreen->width || - pbox->y2 > imesa->savageScreen->height) - continue; - - bciptr = SAVAGE_GET_BCI_POINTER(imesa,6); - - *(bciptr) = 0x4BCC00C0; - - *(bciptr) = imesa->savageScreen->backOffset; - *(bciptr) = imesa->savageScreen->backBitmapDesc; - *(bciptr) = (pbox->y1 <<16) | pbox->x1; /*x0, y0*/ - *(bciptr) = (pbox->y1 <<16) | pbox->x1; - *(bciptr) = (h << 16) | w; - } - - } -} -#endif - - -static GLboolean intersect_rect( drm_clip_rect_t *out, - const drm_clip_rect_t *a, - const drm_clip_rect_t *b ) -{ - *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; - - return ((out->x1 < out->x2) && (out->y1 < out->y2)); -} - - -static GLuint savageIntersectClipRects(drm_clip_rect_t *dest, - const drm_clip_rect_t *src, - GLuint nsrc, - const drm_clip_rect_t *clip) -{ - GLuint i, ndest; - - for (i = 0, ndest = 0; i < nsrc; ++i, ++src) { - if (intersect_rect(dest, src, clip)) { - dest++; - ndest++; - } - } - - return ndest; -} - - -static void savageDDClear( struct gl_context *ctx, GLbitfield mask ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - GLuint colorMask, depthMask, clearColor, clearDepth, flags; - GLint cx = ctx->DrawBuffer->_Xmin; - GLint cy = ctx->DrawBuffer->_Ymin; - GLint cw = ctx->DrawBuffer->_Xmax - cx; - GLint ch = ctx->DrawBuffer->_Ymax - cy; - - /* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */ - (void) ch; - (void) cw; - - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "%s\n", __FUNCTION__); - - clearColor = imesa->ClearColor; - if (imesa->float_depth) { - if (imesa->savageScreen->zpp == 2) - clearDepth = savageEncodeFloat16(1.0 - ctx->Depth.Clear); - else - clearDepth = savageEncodeFloat24(1.0 - ctx->Depth.Clear); - } else { - if (imesa->savageScreen->zpp == 2) - clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_16); - else - clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_24); - } - - colorMask = 0; - depthMask = 0; - switch (imesa->savageScreen->cpp) { - case 2: - colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0][0], - ctx->Color.ColorMask[0][1], - ctx->Color.ColorMask[0][2]); - break; - case 4: - colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[0][3], - ctx->Color.ColorMask[0][2], - ctx->Color.ColorMask[0][1], - ctx->Color.ColorMask[0][0]); - break; - } - - flags = 0; - - if (mask & BUFFER_BIT_FRONT_LEFT) { - flags |= SAVAGE_FRONT; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if (mask & BUFFER_BIT_BACK_LEFT) { - flags |= SAVAGE_BACK; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if ((mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask) { - flags |= SAVAGE_DEPTH; - depthMask |= - (imesa->savageScreen->zpp == 2) ? 0xffffffff : 0x00ffffff; - mask &= ~BUFFER_BIT_DEPTH; - } - - if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil) - { - flags |= SAVAGE_DEPTH; - depthMask |= 0xff000000; - mask &= ~BUFFER_BIT_STENCIL; - } - - savageFlushVertices(imesa); - - if (flags) { - GLboolean depthCleared = GL_FALSE; - if (flags & (SAVAGE_FRONT|SAVAGE_BACK)) { - drm_savage_cmd_header_t *cmd; - cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t)); - cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR; - if ((flags & SAVAGE_DEPTH) && - clearDepth == clearColor && depthMask == colorMask) { - cmd[0].clear0.flags = flags; - depthCleared = GL_TRUE; - } else - cmd[0].clear0.flags = flags & (SAVAGE_FRONT|SAVAGE_BACK); - cmd[1].clear1.mask = colorMask; - cmd[1].clear1.value = clearColor; - } - - if ((flags & SAVAGE_DEPTH) && !depthCleared) { - drm_savage_cmd_header_t *cmd; - cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t)); - cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR; - cmd[0].clear0.flags = SAVAGE_DEPTH; - cmd[1].clear1.mask = depthMask; - cmd[1].clear1.value = clearDepth; - } - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - -/* - * Copy the back buffer to the front buffer. - */ -void savageSwapBuffers( __DRIdrawable *dPriv ) -{ - savageContextPtr imesa; - - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "%s\n================================\n", __FUNCTION__); - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - imesa = (savageContextPtr) dPriv->driContextPriv->driverPrivate; - if (imesa->IsDouble) - _mesa_notifySwapBuffers( imesa->glCtx ); - - FLUSH_BATCH(imesa); - - if (imesa->sync_frames) - imesa->lastSwap = savageEmitEvent( imesa, 0 ); - - if (imesa->lastSwap != 0) - savageWaitEvent( imesa, imesa->lastSwap ); - - { - drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, 0); - cmd->cmd.cmd = SAVAGE_CMD_SWAP; - imesa->inSwap = GL_TRUE; /* ignore scissors in savageFlushCmdBuf */ - savageFlushCmdBuf(imesa, GL_FALSE); - imesa->inSwap = GL_FALSE; - } - - if (!imesa->sync_frames) - /* don't sync, but limit the lag to one frame. */ - imesa->lastSwap = savageEmitEvent( imesa, 0 ); -} - -unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags ) -{ - drm_savage_event_emit_t event; - int ret; - event.count = 0; - event.flags = flags; - ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_EMIT, - &event, sizeof(event) ); - if (ret) { - fprintf (stderr, "emit event returned %d\n", ret); - exit (1); - } - return event.count; -} -unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags ) -{ - unsigned int ret; - LOCK_HARDWARE( imesa ); - ret = savageEmitEventLocked( imesa, flags ); - UNLOCK_HARDWARE( imesa ); - return ret; -} - - -void savageWaitEvent( savageContextPtr imesa, unsigned int count ) -{ - drm_savage_event_wait_t event; - int ret; - event.count = count; - event.flags = 0; - ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_WAIT, - &event, sizeof(event) ); - if (ret) { - fprintf (stderr, "wait event returned %d\n", ret); - exit (1); - } -} - - -void savageFlushVertices( savageContextPtr imesa ) -{ - struct savage_vtxbuf_t *buffer = imesa->vtxBuf; - - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "%s\n", __FUNCTION__); - - if (!buffer->total) - return; - - if (buffer->used > buffer->flushed) { - drm_savage_cmd_header_t *cmd; - /* State must be updated "per primitive" because hardware - * culling must be disabled for unfilled primitives, points - * and lines. */ - savageEmitChangedState (imesa); - cmd = savageAllocCmdBuf(imesa, 0); - cmd->prim.cmd = buffer == &imesa->dmaVtxBuf ? - SAVAGE_CMD_DMA_PRIM : SAVAGE_CMD_VB_PRIM; - cmd->prim.prim = imesa->HwPrim; - cmd->prim.skip = imesa->skip; - cmd->prim.start = buffer->flushed / imesa->HwVertexSize; - cmd->prim.count = buffer->used / imesa->HwVertexSize - cmd->prim.start; - buffer->flushed = buffer->used; - } -} - -void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard ) -{ - __DRIdrawable *dPriv = imesa->driDrawable; - - if (!imesa->dmaVtxBuf.total) - discard = GL_FALSE; - - /* complete indexed drawing commands */ - savageFlushElts(imesa); - - if (imesa->cmdBuf.write != imesa->cmdBuf.start || discard) { - drm_savage_cmdbuf_t cmdbuf; - drm_savage_cmd_header_t *start; - int ret; - - /* If we lost the context we must restore the initial state (at - * the start of the command buffer). */ - if (imesa->lostContext) { - start = imesa->cmdBuf.base; - imesa->lostContext = GL_FALSE; - } else - start = imesa->cmdBuf.start; - - if ((SAVAGE_DEBUG & DEBUG_DMA) && discard) - fprintf (stderr, "Discarding DMA buffer, used=%u\n", - imesa->dmaVtxBuf.used); - - cmdbuf.dma_idx = imesa->dmaVtxBuf.idx; - cmdbuf.discard = discard; - cmdbuf.vb_addr = imesa->clientVtxBuf.buf; - cmdbuf.vb_size = imesa->clientVtxBuf.total*4; - cmdbuf.vb_stride = imesa->HwVertexSize; - cmdbuf.cmd_addr = start; - cmdbuf.size = (imesa->cmdBuf.write - start); - if (!imesa->inSwap && imesa->scissor.enabled) { - drm_clip_rect_t *box = dPriv->pClipRects, *ibox; - drm_clip_rect_t scissor; - GLuint nbox = dPriv->numClipRects, nibox; - /* transform and clip scissor to viewport */ - scissor.x1 = MAX2(imesa->scissor.x, 0) + dPriv->x; - scissor.y1 = MAX2(dPriv->h - imesa->scissor.y - imesa->scissor.h, - 0) + dPriv->y; - scissor.x2 = MIN2(imesa->scissor.x + imesa->scissor.w, - dPriv->w) + dPriv->x; - scissor.y2 = MIN2(dPriv->h - imesa->scissor.y, - dPriv->h) + dPriv->y; - /* intersect cliprects with scissor */ - ibox = malloc(dPriv->numClipRects*sizeof(drm_clip_rect_t)); - if (!ibox) { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } - nibox = savageIntersectClipRects(ibox, box, nbox, &scissor); - cmdbuf.nbox = nibox; - cmdbuf.box_addr = ibox; - } else { - cmdbuf.nbox = dPriv->numClipRects; - cmdbuf.box_addr = dPriv->pClipRects; - } - - ret = drmCommandWrite( imesa->driFd, DRM_SAVAGE_BCI_CMDBUF, - &cmdbuf, sizeof(cmdbuf) ); - if (ret) { - fprintf (stderr, "cmdbuf ioctl returned %d\n", ret); - exit(1); - } - - if (cmdbuf.box_addr != dPriv->pClipRects) { - free(cmdbuf.box_addr); - } - - /* Save the current state at the start of the command buffer. That - * state will only be emitted, if the context was lost since the - * last command buffer. */ - imesa->cmdBuf.write = imesa->cmdBuf.base; - savageEmitOldState(imesa); - imesa->cmdBuf.start = imesa->cmdBuf.write; - } - - if (discard) { - assert (!savageHaveIndexedVerts(imesa)); - imesa->dmaVtxBuf.total = 0; - imesa->dmaVtxBuf.used = 0; - imesa->dmaVtxBuf.flushed = 0; - } - if (!savageHaveIndexedVerts(imesa)) { - imesa->clientVtxBuf.used = 0; - imesa->clientVtxBuf.flushed = 0; - } -} - - -void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard ) -{ - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "%s\n", __FUNCTION__); - LOCK_HARDWARE(imesa); - savageFlushCmdBufLocked (imesa, discard); - UNLOCK_HARDWARE(imesa); -} - - -static void savageDDFlush( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "%s\n", __FUNCTION__); - savageFlushVertices (imesa); - savageFlushCmdBuf(imesa, GL_FALSE); -} - -static void savageDDFinish( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "%s\n", __FUNCTION__); - savageFlushVertices (imesa); - savageFlushCmdBuf(imesa, GL_FALSE); - WAIT_IDLE_EMPTY(imesa); -} - -void savageDDInitIoctlFuncs( struct gl_context *ctx ) -{ - ctx->Driver.Clear = savageDDClear; - ctx->Driver.Flush = savageDDFlush; - ctx->Driver.Finish = savageDDFinish; -} diff --git a/src/mesa/drivers/dri/savage/savageioctl.h b/src/mesa/drivers/dri/savage/savageioctl.h deleted file mode 100644 index 7d34825c296..00000000000 --- a/src/mesa/drivers/dri/savage/savageioctl.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SAVAGE_IOCTL_H -#define SAVAGE_IOCTL_H - -#include "savagecontext.h" - -void savageFlushVertices( savageContextPtr mmesa ); - -unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags ); -unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags ); -void savageWaitEvent( savageContextPtr imesa, unsigned int event); - -void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard ); -void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard ); - -void savageDDInitIoctlFuncs( struct gl_context *ctx ); - -void savageSwapBuffers( __DRIdrawable *dPriv ); - -#define WAIT_IDLE_EMPTY(imesa) do { \ - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \ - fprintf (stderr, "WAIT_IDLE_EMPTY in %s\n", __FUNCTION__); \ - savageWaitEvent(imesa, \ - savageEmitEvent(imesa, SAVAGE_WAIT_2D|SAVAGE_WAIT_3D)); \ -} while (0) - -#define WAIT_IDLE_EMPTY_LOCKED(imesa) do { \ - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \ - fprintf (stderr, "WAIT_IDLE_EMPTY_LOCKED in %s\n", __FUNCTION__); \ - savageWaitEvent(imesa, savageEmitEventLocked( \ - imesa, SAVAGE_WAIT_2D|SAVAGE_WAIT_3D)); \ -} while (0) - -#define FLUSH_BATCH(imesa) do { \ - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \ - fprintf (stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \ - savageFlushVertices(imesa); \ - savageFlushCmdBuf(imesa, GL_FALSE); \ -} while (0) - -extern void savageGetDMABuffer( savageContextPtr imesa ); - -static INLINE -void savageReleaseIndexedVerts( savageContextPtr imesa ) -{ - imesa->firstElt = -1; -} - -static INLINE -GLboolean savageHaveIndexedVerts( savageContextPtr imesa ) -{ - return (imesa->firstElt != -1); -} - -static INLINE -uint32_t *savageAllocVtxBuf( savageContextPtr imesa, GLuint words ) -{ - struct savage_vtxbuf_t *buffer = imesa->vtxBuf; - uint32_t *head; - - if (buffer == &imesa->dmaVtxBuf) { - if (!buffer->total) { - LOCK_HARDWARE(imesa); - savageGetDMABuffer(imesa); - UNLOCK_HARDWARE(imesa); - } else if (buffer->used + words > buffer->total) { - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "... flushing DMA buffer in %s\n", - __FUNCTION__); - savageReleaseIndexedVerts(imesa); - savageFlushVertices(imesa); - LOCK_HARDWARE(imesa); - savageFlushCmdBufLocked(imesa, GL_TRUE); /* discard DMA buffer */ - savageGetDMABuffer(imesa); - UNLOCK_HARDWARE(imesa); - } - } else if (buffer->used + words > buffer->total) { - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "... flushing client vertex buffer in %s\n", - __FUNCTION__); - savageReleaseIndexedVerts(imesa); - savageFlushVertices(imesa); - LOCK_HARDWARE(imesa); - savageFlushCmdBufLocked(imesa, GL_FALSE); /* free clientVtxBuf */ - UNLOCK_HARDWARE(imesa); - } - - head = &buffer->buf[buffer->used]; - - buffer->used += words; - return head; -} - -static INLINE -uint32_t *savageAllocIndexedVerts( savageContextPtr imesa, GLuint n ) -{ - uint32_t *ret; - savageFlushVertices(imesa); - ret = savageAllocVtxBuf(imesa, n*imesa->HwVertexSize); - imesa->firstElt = imesa->vtxBuf->flushed / imesa->HwVertexSize; - imesa->vtxBuf->flushed = imesa->vtxBuf->used; - return ret; -} - -/* Flush Elts: - * - Complete the drawing command with the correct number of indices. - * - Actually allocate entries for the indices in the command buffer. - * (This allocation must succeed without wrapping the cmd buffer!) - */ -static INLINE -void savageFlushElts( savageContextPtr imesa ) -{ - if (imesa->elts.cmd) { - GLuint qwords = (imesa->elts.n + 3) >> 2; - assert(imesa->cmdBuf.write - imesa->cmdBuf.base + qwords - <= imesa->cmdBuf.size); - imesa->cmdBuf.write += qwords; - - imesa->elts.cmd->idx.count = imesa->elts.n; - imesa->elts.cmd = NULL; - } -} - -/* Allocate a command buffer entry with <bytes> bytes of arguments: - * - implies savageFlushElts - */ -static INLINE -drm_savage_cmd_header_t *savageAllocCmdBuf( savageContextPtr imesa, GLuint bytes ) -{ - drm_savage_cmd_header_t *ret; - GLuint qwords = ((bytes + 7) >> 3) + 1; /* round up */ - assert (qwords < imesa->cmdBuf.size); - - savageFlushElts(imesa); - - if (imesa->cmdBuf.write - imesa->cmdBuf.base + qwords > imesa->cmdBuf.size) - savageFlushCmdBuf(imesa, GL_FALSE); - - ret = (drm_savage_cmd_header_t *)imesa->cmdBuf.write; - imesa->cmdBuf.write += qwords; - return ret; -} - -/* Allocate Elts: - * - if it doesn't fit, flush the cmd buffer first - * - allocates the drawing command on the cmd buffer if there is no - * incomplete indexed drawing command yet - * - increments the number of elts. Final allocation is done in savageFlushElts - */ -static INLINE -uint16_t *savageAllocElts( savageContextPtr imesa, GLuint n ) -{ - uint16_t *ret; - GLuint qwords; - assert (savageHaveIndexedVerts(imesa)); - - if (imesa->elts.cmd) - qwords = (imesa->elts.n + n + 3) >> 2; - else - qwords = ((n + 3) >> 2) + 1; - if (imesa->cmdBuf.write - imesa->cmdBuf.base + qwords > imesa->cmdBuf.size) - savageFlushCmdBuf(imesa, GL_FALSE); /* implies savageFlushElts */ - - if (!imesa->elts.cmd) { - savageFlushVertices(imesa); - imesa->elts.cmd = savageAllocCmdBuf(imesa, 0); - imesa->elts.cmd->idx.cmd = (imesa->vtxBuf == &imesa->dmaVtxBuf) ? - SAVAGE_CMD_DMA_IDX : SAVAGE_CMD_VB_IDX; - imesa->elts.cmd->idx.prim = imesa->HwPrim; - imesa->elts.cmd->idx.skip = imesa->skip; - imesa->elts.n = 0; - } - - ret = (uint16_t *)(imesa->elts.cmd+1) + imesa->elts.n; - imesa->elts.n += n; - return ret; -} - -#endif diff --git a/src/mesa/drivers/dri/savage/savagerender.c b/src/mesa/drivers/dri/savage/savagerender.c deleted file mode 100644 index 6687dc5f466..00000000000 --- a/src/mesa/drivers/dri/savage/savagerender.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright 2005 Felix Kuehling - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * 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 "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "math/m_xform.h" - -#include "tnl/t_context.h" - -#include "savagecontext.h" -#include "savagestate.h" -#include "savageioctl.h" - -/* - * Standard render tab for Savage4 and smooth shading on Savage3D - */ -#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 1 - -#define LOCAL_VARS savageContextPtr imesa = SAVAGE_CONTEXT(ctx) -#define INIT( prim ) do { \ - if (0) fprintf(stderr, "%s\n", __FUNCTION__); \ - savageFlushVertices(imesa); \ - switch (prim) { \ - case GL_TRIANGLES: imesa->HwPrim = SAVAGE_PRIM_TRILIST; break; \ - case GL_TRIANGLE_STRIP: imesa->HwPrim = SAVAGE_PRIM_TRISTRIP; break; \ - case GL_TRIANGLE_FAN: imesa->HwPrim = SAVAGE_PRIM_TRIFAN; break; \ - } \ -} while (0) -#define FLUSH() savageFlushElts(imesa), savageFlushVertices(imesa) - -#define GET_CURRENT_VB_MAX_VERTS() \ - ((imesa->bufferSize/4 - imesa->vtxBuf->used) / imesa->HwVertexSize) -#define GET_SUBSEQUENT_VB_MAX_VERTS() \ - (imesa->bufferSize/4 / imesa->HwVertexSize) - -#define ALLOC_VERTS( nr ) \ - savageAllocVtxBuf( imesa, (nr) * imesa->HwVertexSize ) -#define EMIT_VERTS( ctx, j, nr, buf ) \ - _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) - -#define ELTS_VARS( buf ) GLushort *dest = buf, firstElt = imesa->firstElt -#define ELT_INIT( prim ) INIT(prim) - -/* (size - used - 1 qword for drawing command) * 4 elts per qword */ -#define GET_CURRENT_VB_MAX_ELTS() \ - ((imesa->cmdBuf.size - (imesa->cmdBuf.write - imesa->cmdBuf.base) - 1)*4) -/* (size - space for initial state - 1 qword for drawing command) * 4 elts - * imesa is not defined in validate_render :( */ -#define GET_SUBSEQUENT_VB_MAX_ELTS() \ - ((SAVAGE_CONTEXT(ctx)->cmdBuf.size - \ - (SAVAGE_CONTEXT(ctx)->cmdBuf.start - \ - SAVAGE_CONTEXT(ctx)->cmdBuf.base) - 1)*4) - -#define ALLOC_ELTS(nr) savageAllocElts(imesa, nr) -#define EMIT_ELT(offset, x) do { \ - (dest)[offset] = (GLushort) ((x)+firstElt); \ -} while (0) -#define EMIT_TWO_ELTS(offset, x, y) do { \ - *(GLuint *)(dest + offset) = (((y)+firstElt) << 16) | \ - ((x)+firstElt); \ -} while (0) - -#define INCR_ELTS( nr ) dest += nr -#define ELTPTR dest -#define RELEASE_ELT_VERTS() \ - savageReleaseIndexedVerts(imesa) - -#define EMIT_INDEXED_VERTS( ctx, start, count ) do { \ - GLuint *buf = savageAllocIndexedVerts(imesa, count-start); \ - EMIT_VERTS(ctx, start, count-start, buf); \ -} while (0) - -#define TAG(x) savage_##x -#include "tnl_dd/t_dd_dmatmp.h" - -/* - * On Savage3D triangle fans and strips are broken with flat - * shading. With triangles it wants the color for flat shading in the - * first vertex! So we make another template instance which uses - * triangles only (with reordered vertices: SAVAGE_PRIM_TRILIST_201). - * The reordering is done by the DRM. - */ -#undef HAVE_TRI_STRIPS -#undef HAVE_TRI_FANS -#define HAVE_TRI_STRIPS 0 -#define HAVE_TRI_FANS 0 - -#undef INIT -#define INIT( prim ) do { \ - if (0) fprintf(stderr, "%s\n", __FUNCTION__); \ - savageFlushVertices(imesa); \ - imesa->HwPrim = SAVAGE_PRIM_TRILIST_201; \ -} while(0) - -#undef TAG -#define TAG(x) savage_flat_##x##_s3d -#include "tnl_dd/t_dd_dmatmp.h" - - -/**********************************************************************/ -/* Render pipeline stage */ -/**********************************************************************/ - -static GLboolean savage_run_render( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - tnl_render_func *tab, *tab_elts; - GLboolean valid; - GLuint i; - - if (savageHaveIndexedVerts(imesa)) - savageReleaseIndexedVerts(imesa); - - if (imesa->savageScreen->chipset < S3_SAVAGE4 && - (ctx->_TriangleCaps & DD_FLATSHADE)) { - tab = savage_flat_render_tab_verts_s3d; - tab_elts = savage_flat_render_tab_elts_s3d; - valid = savage_flat_validate_render_s3d( ctx, VB ); - } else { - tab = savage_render_tab_verts; - tab_elts = savage_render_tab_elts; - valid = savage_validate_render( ctx, VB ); - } - - /* Don't handle clipping or vertex manipulations. - */ - if (imesa->RenderIndex != 0 || !valid) { - return GL_TRUE; - } - - tnl->Driver.Render.Start( ctx ); - /* Check RenderIndex again. The ptexHack is detected late in RenderStart. - * Also check for ptex fallbacks detected late. - */ - if (imesa->RenderIndex != 0 || imesa->Fallback != 0) { - return GL_TRUE; - } - - /* setup for hardware culling */ - imesa->raster_primitive = GL_TRIANGLES; - imesa->new_state |= SAVAGE_NEW_CULL; - - /* update and emit state */ - savageDDUpdateHwState(ctx); - savageEmitChangedState(imesa); - - if (VB->Elts) { - tab = tab_elts; - if (!savageHaveIndexedVerts(imesa)) { - if (VB->Count > GET_SUBSEQUENT_VB_MAX_VERTS()) - return GL_TRUE; - EMIT_INDEXED_VERTS(ctx, 0, VB->Count); - } - } - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { - GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - - if (length) - tab[prim & PRIM_MODE_MASK]( ctx, start, start+length, prim); - } - - tnl->Driver.Render.Finish( ctx ); - - return GL_FALSE; /* finished the pipe */ -} - -struct tnl_pipeline_stage _savage_render_stage = -{ - "savage render", - NULL, - NULL, - NULL, - NULL, - savage_run_render /* run */ -}; - - -/**********************************************************************/ -/* Pipeline stage for texture coordinate normalization */ -/**********************************************************************/ -struct texnorm_stage_data { - GLboolean active; - GLvector4f texcoord[MAX_TEXTURE_UNITS]; -}; - -#define TEXNORM_STAGE_DATA(stage) ((struct texnorm_stage_data *)stage->privatePtr) - - -static GLboolean run_texnorm_stage( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct texnorm_stage_data *store = TEXNORM_STAGE_DATA(stage); - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - if (imesa->Fallback || !store->active) - return GL_TRUE; - - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - const GLbitfield reallyEnabled = ctx->Texture.Unit[i]._ReallyEnabled; - if (reallyEnabled) { - const struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - const GLboolean normalizeS = (texObj->Sampler.WrapS == GL_REPEAT); - const GLboolean normalizeT = (reallyEnabled & TEXTURE_2D_BIT) && - (texObj->Sampler.WrapT == GL_REPEAT); - const GLfloat *in = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->data; - const GLint instride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->stride; - GLfloat (*out)[4] = store->texcoord[i].data; - GLint j; - - if (!ctx->Texture.Unit[i]._ReallyEnabled || - VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size == 4) - /* Never try to normalize homogenous tex coords! */ - continue; - - if (normalizeS && normalizeT) { - /* take first texcoords as rough estimate of mean value */ - GLfloat correctionS = -floor(in[0]+0.5); - GLfloat correctionT = -floor(in[1]+0.5); - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0] + correctionS; - out[j][1] = in[1] + correctionT; - in = (GLfloat *)((GLubyte *)in + instride); - } - } else if (normalizeS) { - /* take first texcoords as rough estimate of mean value */ - GLfloat correctionS = -floor(in[0]+0.5); - if (reallyEnabled & TEXTURE_2D_BIT) { - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0] + correctionS; - out[j][1] = in[1]; - in = (GLfloat *)((GLubyte *)in + instride); - } - } else { - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0] + correctionS; - in = (GLfloat *)((GLubyte *)in + instride); - } - } - } else if (normalizeT) { - /* take first texcoords as rough estimate of mean value */ - GLfloat correctionT = -floor(in[1]+0.5); - for (j = 0; j < VB->Count; ++j) { - out[j][0] = in[0]; - out[j][1] = in[1] + correctionT; - in = (GLfloat *)((GLubyte *)in + instride); - } - } - - if (normalizeS || normalizeT) - VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &store->texcoord[i]; - } - } - - return GL_TRUE; -} - -/* Called the first time stage->run() is invoked. - */ -static GLboolean alloc_texnorm_data( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct texnorm_stage_data *store; - GLuint i; - - stage->privatePtr = CALLOC(sizeof(*store)); - store = TEXNORM_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) - _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 ); - - return GL_TRUE; -} - -static void validate_texnorm( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct texnorm_stage_data *store = TEXNORM_STAGE_DATA(stage); - GLuint flags = 0; - - if (((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && - (ctx->Texture.Unit[0]._Current->Sampler.WrapS == GL_REPEAT)) || - ((ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_2D_BIT) && - (ctx->Texture.Unit[0]._Current->Sampler.WrapT == GL_REPEAT))) - flags |= VERT_BIT_TEX0; - - if (((ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && - (ctx->Texture.Unit[1]._Current->Sampler.WrapS == GL_REPEAT)) || - ((ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_2D_BIT) && - (ctx->Texture.Unit[1]._Current->Sampler.WrapT == GL_REPEAT))) - flags |= VERT_BIT_TEX1; - - store->active = (flags != 0); -} - -static void free_texnorm_data( struct tnl_pipeline_stage *stage ) -{ - struct texnorm_stage_data *store = TEXNORM_STAGE_DATA(stage); - GLuint i; - - if (store) { - for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) - if (store->texcoord[i].data) - _mesa_vector4f_free( &store->texcoord[i] ); - FREE( store ); - stage->privatePtr = 0; - } -} - -struct tnl_pipeline_stage _savage_texnorm_stage = -{ - "savage texture coordinate normalization stage", /* name */ - NULL, /* private data */ - alloc_texnorm_data, /* run -- initially set to init */ - free_texnorm_data, /* destructor */ - validate_texnorm, - run_texnorm_stage -}; diff --git a/src/mesa/drivers/dri/savage/savagespan.c b/src/mesa/drivers/dri/savage/savagespan.c deleted file mode 100644 index 8542f47fd92..00000000000 --- a/src/mesa/drivers/dri/savage/savagespan.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/mtypes.h" -#include "savagedd.h" -#include "savagespan.h" -#include "savageioctl.h" -#include "savage_3d_reg.h" -#include "swrast/swrast.h" - -#define DBG 0 - -#define LOCAL_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - __DRIdrawable *const dPriv = drb->dPriv; \ - GLuint cpp = drb->cpp; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - GLubyte *buf = drb->Base.Data + dPriv->x * cpp + dPriv->y * pitch; \ - GLuint p; \ - (void) p - -#define LOCAL_DEPTH_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - __DRIdrawable *const dPriv = drb->dPriv; \ - GLuint zpp = drb->cpp; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - GLubyte *buf = drb->Base.Data + dPriv->x * zpp + dPriv->y * pitch; - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define Y_FLIP(_y) (height - _y - 1) - -#define HW_LOCK() - -#define HW_UNLOCK() - -#define HW_WRITE_LOCK() - -#define HW_READ_LOCK() - - -/* 16 bit, 565 rgb color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_RGB -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 - -#define TAG(x) savage##x##_565 -#define TAG2(x,y) savage##x##_565##y -#include "spantmp2.h" - - -/* 32 bit, 8888 ARGB color spanline and pixel functions - */ -#define SPANTMP_PIXEL_FMT GL_BGRA -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV - -#define TAG(x) savage##x##_8888 -#define TAG2(x,y) savage##x##_8888##y -#include "spantmp2.h" - - -#undef HW_WRITE_LOCK -#define HW_WRITE_LOCK() -#undef HW_READ_LOCK -#define HW_READ_LOCK() - - - -/* 16 bit integer depthbuffer functions - * Depth range is reversed. See also savageCalcViewport. - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = 0xFFFF - d - -#define READ_DEPTH( d, _x, _y ) \ - d = 0xFFFF - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) - -#define TAG(x) savage##x##_z16 -#include "depthtmp.h" - - - - -/* 16 bit float depthbuffer functions - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = \ - savageEncodeFloat16( 1.0 - (GLfloat)d/65535.0 ) - -#define READ_DEPTH( d, _x, _y ) \ - d = 65535 - \ - savageDecodeFloat16( *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) ) * \ - 65535.0 - -#define TAG(x) savage##x##_z16f -#include "depthtmp.h" - - - - -/* 8-bit stencil /24-bit integer depth depthbuffer functions. - * Depth range is reversed. See also savageCalcViewport. - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) do { \ - GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \ - tmp &= 0xFF000000; \ - tmp |= 0x00FFFFFF - d; \ - *(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \ -} while(0) - -#define READ_DEPTH( d, _x, _y ) \ - d = 0x00FFFFFF - (*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF) - -#define TAG(x) savage##x##_s8_z24 -#include "depthtmp.h" - - - - -/* 24 bit float depthbuffer functions - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) do { \ - GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \ - tmp &= 0xFF000000; \ - tmp |= savageEncodeFloat24( 1.0 - (GLfloat)d/16777215.0 ); \ - *(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \ -} while(0) - -#define READ_DEPTH( d, _x, _y ) \ - d = 16777215 - savageDecodeFloat24( \ - *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF) \ - * 16777215.0 - -#define TAG(x) savage##x##_s8_z24f -#include "depthtmp.h" - - -#define WRITE_STENCIL( _x, _y, d ) do { \ - GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \ - tmp &= 0x00FFFFFF; \ - tmp |= (((GLuint)d)<<24) & 0xFF000000; \ - *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) = tmp; \ -} while(0) - -#define READ_STENCIL( d, _x, _y ) \ - d = (GLstencil)((*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0xFF000000) >> 24) - -#define TAG(x) savage##x##_s8_z24 -#include "stenciltmp.h" - - - -/* - * Wrappers around _swrast_Copy/Draw/ReadPixels that make sure all - * primitives are flushed and the hardware is idle before accessing - * the frame buffer. - */ -static void -savageCopyPixels( struct gl_context *ctx, - GLint srcx, GLint srcy, GLsizei width, GLsizei height, - GLint destx, GLint desty, - GLenum type ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); - _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type); -} -static void -savageDrawPixels( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - const GLvoid *pixels ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); - _swrast_DrawPixels(ctx, x, y, width, height, format, type, packing, pixels); -} -static void -savageReadPixels( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *pixels ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); - _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, pixels); -} - -/* - * Make sure the hardware is idle when span-rendering. - */ -static void savageSpanRenderStart( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); -} - - -void savageDDInitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = savageSpanRenderStart; - - /* XXX these should probably be plugged in elsewhere */ - ctx->Driver.CopyPixels = savageCopyPixels; - ctx->Driver.DrawPixels = savageDrawPixels; - ctx->Driver.ReadPixels = savageReadPixels; -} - - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -savageSetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis, - GLboolean float_depth) -{ - if (drb->Base.Format == MESA_FORMAT_RGB565) { - savageInitPointers_565(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_ARGB8888) { - savageInitPointers_8888(&drb->Base); - } - else if (drb->Base.Format == MESA_FORMAT_Z16) { - if (float_depth) { - savageInitDepthPointers_z16f(&drb->Base); - } - else { - savageInitDepthPointers_z16(&drb->Base); - } - } - else if (drb->Base.Format == MESA_FORMAT_S8_Z24) { - if (float_depth) { - savageInitDepthPointers_s8_z24f(&drb->Base); - } - else { - savageInitDepthPointers_s8_z24(&drb->Base); - } - } - else if (drb->Base.Format == MESA_FORMAT_S8) { - savageInitStencilPointers_s8_z24(&drb->Base); - } -} diff --git a/src/mesa/drivers/dri/savage/savagespan.h b/src/mesa/drivers/dri/savage/savagespan.h deleted file mode 100644 index 41d6f75cbbe..00000000000 --- a/src/mesa/drivers/dri/savage/savagespan.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _SAVAGE_SPAN_H -#define _SAVAGE_SPAN_H - -#include "drirenderbuffer.h" - - -extern void savageDDInitSpanFuncs( struct gl_context *ctx ); - -extern void -savageSetSpanFunctions(driRenderbuffer *rb, const struct gl_config *vis, - GLboolean float_depth); - - -/* - * Savage 16-bit float depth format with zExpOffset=16: - * 4 bit unsigned exponent, 12 bit mantissa - * - * The meaning of the mantissa is different from IEEE floatint point - * formats. The same number can't be encoded with different exponents. - * So no bits are wasted. - * - * exponent | range encoded by mantissa | accuracy or mantissa - * ---------+---------------------------+--------------------- - * 15 | 2^-1 .. 1 | 2^-13 - * 14 | 2^-2 .. 2^-1 | 2^-14 - * 13 | 2^-3 .. 2^-2 | 2^-15 - * ... | ... | - * 2 | 2^-14 .. 2^-13 | 2^-27 - * 1 | 2^-15 .. 2^-14 | 2^-27 - * 0 | 2^-16 .. 2^-15 | 2^-28 - * - * Note that there is no encoding for numbers < 2^-16. - */ -static INLINE GLuint savageEncodeFloat16( GLdouble x ) -{ - GLint r = (GLint)(x * 0x10000000); - GLint exp = 0; - if (r < 0x1000) - return 0; - while (r - 0x1000 > 0x0fff) { - r >>= 1; - exp++; - } - return exp > 0xf ? 0xffff : (r - 0x1000) | (exp << 12); -} -static INLINE GLdouble savageDecodeFloat16( GLuint x ) -{ - static const GLdouble pow2[16] = { - 1.0/(1<<28), 1.0/(1<<27), 1.0/(1<<26), 1.0/(1<<25), - 1.0/(1<<24), 1.0/(1<<23), 1.0/(1<<22), 1.0/(1<<21), - 1.0/(1<<20), 1.0/(1<<19), 1.0/(1<<18), 1.0/(1<<17), - 1.0/(1<<16), 1.0/(1<<15), 1.0/(1<<14), 1.0/(1<<13) - }; - static const GLdouble bias[16] = { - 1.0/(1<<16), 1.0/(1<<15), 1.0/(1<<14), 1.0/(1<<13), - 1.0/(1<<12), 1.0/(1<<11), 1.0/(1<<10), 1.0/(1<< 9), - 1.0/(1<< 8), 1.0/(1<< 7), 1.0/(1<< 6), 1.0/(1<< 5), - 1.0/(1<< 4), 1.0/(1<< 3), 1.0/(1<< 2), 1.0/(1<< 1) - }; - GLuint mant = x & 0x0fff; - GLuint exp = (x >> 12) & 0xf; - return bias[exp] + pow2[exp]*mant; -} - -/* - * Savage 24-bit float depth format with zExpOffset=32: - * 5 bit unsigned exponent, 19 bit mantissa - * - * Details analogous to the 16-bit format. - */ -static INLINE GLuint savageEncodeFloat24( GLdouble x ) -{ - int64_t r = (int64_t)(x * ((int64_t)1 << (19+32))); - GLint exp = 0; - if (r < 0x80000) - return 0; - while (r - 0x80000 > 0x7ffff) { - r >>= 1; - exp++; - } - return exp > 0x1f ? 0xffffff : (r - 0x80000) | (exp << 19); -} -#define _1 (int64_t)1 -static INLINE GLdouble savageDecodeFloat24( GLuint x ) -{ - static const GLdouble pow2[32] = { - 1.0/(_1<<51), 1.0/(_1<<50), 1.0/(_1<<49), 1.0/(_1<<48), - 1.0/(_1<<47), 1.0/(_1<<46), 1.0/(_1<<45), 1.0/(_1<<44), - 1.0/(_1<<43), 1.0/(_1<<42), 1.0/(_1<<41), 1.0/(_1<<40), - 1.0/(_1<<39), 1.0/(_1<<38), 1.0/(_1<<37), 1.0/(_1<<36), - 1.0/(_1<<35), 1.0/(_1<<34), 1.0/(_1<<33), 1.0/(_1<<32), - 1.0/(_1<<31), 1.0/(_1<<30), 1.0/(_1<<29), 1.0/(_1<<28), - 1.0/(_1<<27), 1.0/(_1<<26), 1.0/(_1<<25), 1.0/(_1<<24), - 1.0/(_1<<23), 1.0/(_1<<22), 1.0/(_1<<21), 1.0/(_1<<20) - }; - static const GLdouble bias[32] = { - 1.0/(_1<<32), 1.0/(_1<<31), 1.0/(_1<<30), 1.0/(_1<<29), - 1.0/(_1<<28), 1.0/(_1<<27), 1.0/(_1<<26), 1.0/(_1<<25), - 1.0/(_1<<24), 1.0/(_1<<23), 1.0/(_1<<22), 1.0/(_1<<21), - 1.0/(_1<<20), 1.0/(_1<<19), 1.0/(_1<<18), 1.0/(_1<<17), - 1.0/(_1<<16), 1.0/(_1<<15), 1.0/(_1<<14), 1.0/(_1<<13), - 1.0/(_1<<12), 1.0/(_1<<11), 1.0/(_1<<10), 1.0/(_1<< 9), - 1.0/(_1<< 8), 1.0/(_1<< 7), 1.0/(_1<< 6), 1.0/(_1<< 5), - 1.0/(_1<< 4), 1.0/(_1<< 3), 1.0/(_1<< 2), 1.0/(_1<< 1) - }; - GLuint mant = x & 0x7ffff; - GLuint exp = (x >> 19) & 0x1f; - return bias[exp] + pow2[exp]*mant; -} -#undef _1 - - -#endif diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c deleted file mode 100644 index 21ebf5dc2b2..00000000000 --- a/src/mesa/drivers/dri/savage/savagestate.c +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include <stdio.h> - -#include "main/mtypes.h" -#include "main/enums.h" -#include "main/macros.h" -#include "main/dd.h" -#include "main/mm.h" -#include "main/state.h" - -#include "savagedd.h" -#include "savagecontext.h" - -#include "savagestate.h" -#include "savagetex.h" -#include "savagetris.h" -#include "savageioctl.h" -#include "savage_bci.h" - -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "swrast_setup/swrast_setup.h" - -#include "xmlpool.h" - -/* Savage4, ProSavage[DDR], SuperSavage watermarks */ -#define S4_ZRLO 24 -#define S4_ZRHI 24 -#define S4_ZWLO 0 -#define S4_ZWHI 0 - -#define S4_DRLO 0 -#define S4_DRHI 0 -#define S4_DWLO 0 -#define S4_DWHI 0 - -#define S4_TR 15 - -/* Savage3D/MX/IX watermarks */ -#define S3D_ZRLO 8 -#define S3D_ZRHI 24 -#define S3D_ZWLO 0 -#define S3D_ZWHI 24 - -#define S3D_DRLO 0 -#define S3D_DRHI 0 -#define S3D_DWLO 0 -#define S3D_DWHI 0 - -#define S3D_TR 15 - -static void savageBlendFunc_s4(struct gl_context *); -static void savageBlendFunc_s3d(struct gl_context *); - -static INLINE GLuint savagePackColor(GLuint format, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a) -{ - switch (format) { - case DV_PF_8888: - return SAVAGEPACKCOLOR8888(r,g,b,a); - case DV_PF_565: - return SAVAGEPACKCOLOR565(r,g,b); - default: - - return 0; - } -} - - -static void savageDDAlphaFunc_s4(struct gl_context *ctx, GLenum func, GLfloat ref) -{ - savageBlendFunc_s4(ctx); -} -static void savageDDAlphaFunc_s3d(struct gl_context *ctx, GLenum func, GLfloat ref) -{ - savageBlendFunc_s3d(ctx); -} - -static void savageDDBlendEquationSeparate(struct gl_context *ctx, - GLenum modeRGB, GLenum modeA) -{ - assert( modeRGB == modeA ); - - /* BlendEquation sets ColorLogicOpEnabled in an unexpected - * manner. - */ - FALLBACK( ctx, SAVAGE_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - - /* Can only do blend addition, not min, max, subtract, etc. */ - FALLBACK( ctx, SAVAGE_FALLBACK_BLEND_EQ, - modeRGB != GL_FUNC_ADD); -} - - -static void savageBlendFunc_s4(struct gl_context *ctx) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - uint32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui; - uint32_t drawCtrl0 = imesa->regs.s4.drawCtrl0.ui; - uint32_t drawCtrl1 = imesa->regs.s4.drawCtrl1.ui; - - /* set up draw control register (including blending, alpha - * test, and shading model) - */ - - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_FALSE; - - /* - * blend modes - */ - if(ctx->Color.BlendEnabled){ - switch (ctx->Color.Blend[0].DstRGB) - { - case GL_ZERO: - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero; - break; - - case GL_ONE: - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_One; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_SRC_COLOR: - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_SrcClr; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_SRC_COLOR: - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_1SrcClr; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_SRC_ALPHA: - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_SrcAlpha; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_SRC_ALPHA: - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_1SrcAlpha; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_One; - } - else - { - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode= DAM_DstAlpha; - } - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero; - } - else - { - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode=DAM_1DstAlpha; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE; - } - break; - } - - switch (ctx->Color.Blend[0].SrcRGB) - { - case GL_ZERO: - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_Zero; - break; - - case GL_ONE: - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One; - break; - - case GL_DST_COLOR: - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_DstClr; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_DST_COLOR: - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_1DstClr; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_SRC_ALPHA: - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_SrcAlpha; - break; - - case GL_ONE_MINUS_SRC_ALPHA: - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_1SrcAlpha; - break; - - case GL_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One; - } - else - { - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode= SAM_DstAlpha; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE; - } - break; - - case GL_ONE_MINUS_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_Zero; - } - else - { - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode=SAM_1DstAlpha; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE; - } - break; - } - } - else - { - imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero; - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One; - } - - /* alpha test*/ - - if(ctx->Color.AlphaEnabled) - { - ACmpFunc a; - GLubyte alphaRef; - - CLAMPED_FLOAT_TO_UBYTE(alphaRef,ctx->Color.AlphaRef); - - switch(ctx->Color.AlphaFunc) { - case GL_NEVER: a = CF_Never; break; - case GL_ALWAYS: a = CF_Always; break; - case GL_LESS: a = CF_Less; break; - case GL_LEQUAL: a = CF_LessEqual; break; - case GL_EQUAL: a = CF_Equal; break; - case GL_GREATER: a = CF_Greater; break; - case GL_GEQUAL: a = CF_GreaterEqual; break; - case GL_NOTEQUAL: a = CF_NotEqual; break; - default:return; - } - - imesa->regs.s4.drawCtrl1.ni.alphaTestEn = GL_TRUE; - imesa->regs.s4.drawCtrl1.ni.alphaTestCmpFunc = a; - imesa->regs.s4.drawCtrl0.ni.alphaRefVal = alphaRef; - } - else - { - imesa->regs.s4.drawCtrl1.ni.alphaTestEn = GL_FALSE; - } - - /* Set/Reset Z-after-alpha*/ - - imesa->regs.s4.drawLocalCtrl.ni.wrZafterAlphaTst = - imesa->regs.s4.drawCtrl1.ni.alphaTestEn; - /*imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = - ~drawLocalCtrl.ni.wrZafterAlphaTst;*/ - - if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - if (drawCtrl0 != imesa->regs.s4.drawCtrl0.ui || - drawCtrl1 != imesa->regs.s4.drawCtrl1.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} -static void savageBlendFunc_s3d(struct gl_context *ctx) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - uint32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui; - uint32_t zBufCtrl = imesa->regs.s3d.zBufCtrl.ui; - - /* set up draw control register (including blending, alpha - * test, dithering, and shading model) - */ - - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = 0; - - /* - * blend modes - */ - if(ctx->Color.BlendEnabled){ - switch (ctx->Color.Blend[0].DstRGB) - { - case GL_ZERO: - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero; - break; - - case GL_ONE: - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_One; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_SRC_COLOR: - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_SrcClr; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_SRC_COLOR: - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_1SrcClr; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_SRC_ALPHA: - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_SrcAlpha; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_SRC_ALPHA: - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_1SrcAlpha; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_One; - } - else - { - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_DstAlpha; - } - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero; - } - else - { - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_1DstAlpha; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - } - break; - } - - switch (ctx->Color.Blend[0].SrcRGB) - { - case GL_ZERO: - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_Zero; - break; - - case GL_ONE: - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One; - break; - - case GL_DST_COLOR: - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_DstClr; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_ONE_MINUS_DST_COLOR: - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_1DstClr; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - break; - - case GL_SRC_ALPHA: - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_SrcAlpha; - break; - - case GL_ONE_MINUS_SRC_ALPHA: - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_1SrcAlpha; - break; - - case GL_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One; - } - else - { - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_DstAlpha; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - } - break; - - case GL_ONE_MINUS_DST_ALPHA: - if (imesa->glCtx->Visual.alphaBits == 0) - { - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_Zero; - } - else - { - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_1DstAlpha; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - } - break; - } - } - else - { - imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero; - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One; - } - - /* alpha test*/ - - if(ctx->Color.AlphaEnabled) - { - ACmpFunc a; - GLubyte alphaRef; - - CLAMPED_FLOAT_TO_UBYTE(alphaRef,ctx->Color.AlphaRef); - - switch(ctx->Color.AlphaFunc) { - case GL_NEVER: a = CF_Never; break; - case GL_ALWAYS: a = CF_Always; break; - case GL_LESS: a = CF_Less; break; - case GL_LEQUAL: a = CF_LessEqual; break; - case GL_EQUAL: a = CF_Equal; break; - case GL_GREATER: a = CF_Greater; break; - case GL_GEQUAL: a = CF_GreaterEqual; break; - case GL_NOTEQUAL: a = CF_NotEqual; break; - default:return; - } - - imesa->regs.s3d.drawCtrl.ni.alphaTestEn = GL_TRUE; - imesa->regs.s3d.drawCtrl.ni.alphaTestCmpFunc = a; - imesa->regs.s3d.drawCtrl.ni.alphaRefVal = alphaRef; - } - else - { - imesa->regs.s3d.drawCtrl.ni.alphaTestEn = GL_FALSE; - } - - /* Set/Reset Z-after-alpha*/ - - imesa->regs.s3d.zBufCtrl.ni.wrZafterAlphaTst = - imesa->regs.s3d.drawCtrl.ni.alphaTestEn; - - if (drawCtrl != imesa->regs.s3d.drawCtrl.ui || - zBufCtrl != imesa->regs.s3d.zBufCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; -} - -static void savageDDBlendFuncSeparate_s4( struct gl_context *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA ) -{ - assert (dfactorRGB == dfactorA && sfactorRGB == sfactorA); - savageBlendFunc_s4( ctx ); -} -static void savageDDBlendFuncSeparate_s3d( struct gl_context *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA ) -{ - assert (dfactorRGB == dfactorA && sfactorRGB == sfactorA); - savageBlendFunc_s3d( ctx ); -} - - - -static void savageDDDepthFunc_s4(struct gl_context *ctx, GLenum func) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - ZCmpFunc zmode; - uint32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui; - uint32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui; - uint32_t zWatermarks = imesa->regs.s4.zWatermarks.ui; /* FIXME: in DRM */ - - /* set up z-buffer control register (global) - * set up z-buffer offset register (global) - * set up z read/write watermarks register (global) - */ - - switch(func) { /* reversed (see savageCalcViewport) */ - case GL_NEVER: zmode = CF_Never; break; - case GL_ALWAYS: zmode = CF_Always; break; - case GL_LESS: zmode = CF_Greater; break; - case GL_LEQUAL: zmode = CF_GreaterEqual; break; - case GL_EQUAL: zmode = CF_Equal; break; - case GL_GREATER: zmode = CF_Less; break; - case GL_GEQUAL: zmode = CF_LessEqual; break; - case GL_NOTEQUAL: zmode = CF_NotEqual; break; - default:return; - } - if (ctx->Depth.Test) - { - - imesa->regs.s4.zBufCtrl.ni.zCmpFunc = zmode; - imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = ctx->Depth.Mask; - imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_TRUE; - imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE; - } - else if (imesa->glCtx->Stencil._Enabled && imesa->hw_stencil) - { - /* Need to keep Z on for Stencil. */ - imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always; - imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE; - imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE; - imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE; - } - else - { - - if (imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn == GL_FALSE) - { - imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always; - imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE; - } - else - - /* DRAWUPDATE_REQUIRES_Z_ENABLED*/ - { - imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_FALSE; - } - imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE; - imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE; - } - - if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - if (zBufCtrl != imesa->regs.s4.zBufCtrl.ui || - zWatermarks != imesa->regs.s4.zWatermarks.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} -static void savageDDDepthFunc_s3d(struct gl_context *ctx, GLenum func) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - ZCmpFunc zmode; - uint32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui; - uint32_t zBufCtrl = imesa->regs.s3d.zBufCtrl.ui; - uint32_t zWatermarks = imesa->regs.s3d.zWatermarks.ui; /* FIXME: in DRM */ - - /* set up z-buffer control register (global) - * set up z-buffer offset register (global) - * set up z read/write watermarks register (global) - */ - switch(func) { /* reversed (see savageCalcViewport) */ - case GL_NEVER: zmode = CF_Never; break; - case GL_ALWAYS: zmode = CF_Always; break; - case GL_LESS: zmode = CF_Greater; break; - case GL_LEQUAL: zmode = CF_GreaterEqual; break; - case GL_EQUAL: zmode = CF_Equal; break; - case GL_GREATER: zmode = CF_Less; break; - case GL_GEQUAL: zmode = CF_LessEqual; break; - case GL_NOTEQUAL: zmode = CF_NotEqual; break; - default:return; - } - if (ctx->Depth.Test) - { - imesa->regs.s3d.zBufCtrl.ni.zBufEn = GL_TRUE; - imesa->regs.s3d.zBufCtrl.ni.zCmpFunc = zmode; - imesa->regs.s3d.zBufCtrl.ni.zUpdateEn = ctx->Depth.Mask; - - imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE; - } - else - { - if (imesa->regs.s3d.zBufCtrl.ni.drawUpdateEn == GL_FALSE) { - imesa->regs.s3d.zBufCtrl.ni.zCmpFunc = CF_Always; - imesa->regs.s3d.zBufCtrl.ni.zBufEn = GL_TRUE; - } - else - - /* DRAWUPDATE_REQUIRES_Z_ENABLED*/ - { - imesa->regs.s3d.zBufCtrl.ni.zBufEn = GL_FALSE; - } - imesa->regs.s3d.zBufCtrl.ni.zUpdateEn = GL_FALSE; - imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_FALSE; - } - - if (drawCtrl != imesa->regs.s3d.drawCtrl.ui || - zBufCtrl != imesa->regs.s3d.zBufCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - if (zWatermarks != imesa->regs.s3d.zWatermarks.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} - -static void savageDDDepthMask_s4(struct gl_context *ctx, GLboolean flag) -{ - savageDDDepthFunc_s4(ctx,ctx->Depth.Func); -} -static void savageDDDepthMask_s3d(struct gl_context *ctx, GLboolean flag) -{ - savageDDDepthFunc_s3d(ctx,ctx->Depth.Func); -} - - - - -/* ============================================================= - * Hardware clipping - */ - - -static void savageDDScissor( struct gl_context *ctx, GLint x, GLint y, - GLsizei w, GLsizei h ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - - /* Emit buffered commands with old scissor state. */ - FLUSH_BATCH(imesa); - - /* Mirror scissors in private context. */ - imesa->scissor.enabled = ctx->Scissor.Enabled; - imesa->scissor.x = x; - imesa->scissor.y = y; - imesa->scissor.w = w; - imesa->scissor.h = h; -} - - - -static void savageDDDrawBuffer(struct gl_context *ctx, GLenum mode ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - uint32_t destCtrl = imesa->regs.s4.destCtrl.ui; - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - imesa->IsDouble = GL_FALSE; - imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11; - break; - case BUFFER_BACK_LEFT: - imesa->IsDouble = GL_TRUE; - imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11; - break; - default: - FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - imesa->NotFirstFrame = GL_FALSE; - savageXMesaSetClipRects(imesa); - FALLBACK(ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE); - - if (destCtrl != imesa->regs.s4.destCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} - -static void savageDDReadBuffer(struct gl_context *ctx, GLenum mode ) -{ - /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */ -} - -#if 0 -static void savageDDSetColor(struct gl_context *ctx, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - imesa->MonoColor = savagePackColor( imesa->savageScreen->frontFormat, r, g, b, a ); -} -#endif - -/* ============================================================= - * Window position and viewport transformation - */ - -void savageCalcViewport( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = imesa->hw_viewport; - - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX] + imesa->drawX + SUBPIXEL_X; - m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = - v[MAT_TY] + imesa->driDrawable->h + imesa->drawY + SUBPIXEL_Y; - /* Depth range is reversed (far: 0, near: 1) so that float depth - * compensates for loss of accuracy of far coordinates. */ - if (imesa->float_depth && imesa->savageScreen->zpp == 2) { - /* The Savage 16-bit floating point depth format can't encode - * numbers < 2^-16. Make sure all depth values stay greater - * than that. */ - m[MAT_SZ] = - v[MAT_SZ] * imesa->depth_scale * (65535.0/65536.0); - m[MAT_TZ] = 1.0 - v[MAT_TZ] * imesa->depth_scale * (65535.0/65536.0); - } else { - m[MAT_SZ] = - v[MAT_SZ] * imesa->depth_scale; - m[MAT_TZ] = 1.0 - v[MAT_TZ] * imesa->depth_scale; - } - - imesa->SetupNewInputs = ~0; -} - -static void savageViewport( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - savageCalcViewport( ctx ); -} - -static void savageDepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - savageCalcViewport( ctx ); -} - - -/* ============================================================= - * Miscellaneous - */ - -static void savageDDClearColor(struct gl_context *ctx, - const GLfloat color[4] ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - imesa->ClearColor = savagePackColor( imesa->savageScreen->frontFormat, - c[0], c[1], c[2], c[3] ); -} - -/* Fallback to swrast for select and feedback. - */ -static void savageRenderMode( struct gl_context *ctx, GLenum mode ) -{ - FALLBACK( ctx, SAVAGE_FALLBACK_RENDERMODE, (mode != GL_RENDER) ); -} - - -#if HW_CULL - -/* ============================================================= - * Culling - the savage isn't quite as clean here as the rest of - * its interfaces, but it's not bad. - */ -static void savageDDCullFaceFrontFace(struct gl_context *ctx, GLenum unused) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLuint cullMode=imesa->LcsCullMode; - switch (ctx->Polygon.CullFaceMode) - { - case GL_FRONT: - switch (ctx->Polygon.FrontFace) - { - case GL_CW: - cullMode = BCM_CW; - break; - case GL_CCW: - cullMode = BCM_CCW; - break; - } - break; - - case GL_BACK: - switch (ctx->Polygon.FrontFace) - { - case GL_CW: - cullMode = BCM_CCW; - break; - case GL_CCW: - cullMode = BCM_CW; - break; - } - break; - } - imesa->LcsCullMode = cullMode; - imesa->new_state |= SAVAGE_NEW_CULL; -} -#endif /* end #if HW_CULL */ - -static void savageUpdateCull( struct gl_context *ctx ) -{ -#if HW_CULL - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLuint cullMode; - if (ctx->Polygon.CullFlag && - imesa->raster_primitive >= GL_TRIANGLES && - ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) - cullMode = imesa->LcsCullMode; - else - cullMode = BCM_None; - if (imesa->savageScreen->chipset >= S3_SAVAGE4) { - if (imesa->regs.s4.drawCtrl1.ni.cullMode != cullMode) { - imesa->regs.s4.drawCtrl1.ni.cullMode = cullMode; - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; - } - } else { - if (imesa->regs.s3d.drawCtrl.ni.cullMode != cullMode) { - imesa->regs.s3d.drawCtrl.ni.cullMode = cullMode; - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - } - } -#endif /* end #if HW_CULL */ -} - - - -/* ============================================================= - * Color masks - */ - -/* Savage4 can disable draw updates when all channels are - * masked. Savage3D has a bit called drawUpdateEn, but it doesn't seem - * to have any effect. If only some channels are masked we need a - * software fallback on all chips. - */ -static void savageDDColorMask_s4(struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - GLboolean passAny, passAll; - - if (ctx->Visual.alphaBits) { - passAny = b || g || r || a; - passAll = r && g && b && a; - } else { - passAny = b || g || r; - passAll = r && g && b; - } - - if (passAny) { - if (!imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn) { - imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_TRUE; - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - } - FALLBACK (ctx, SAVAGE_FALLBACK_COLORMASK, !passAll); - } else if (imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn) { - imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_FALSE; - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - } -} -static void savageDDColorMask_s3d(struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - if (ctx->Visual.alphaBits) - FALLBACK (ctx, SAVAGE_FALLBACK_COLORMASK, !(r && g && b && a)); - else - FALLBACK (ctx, SAVAGE_FALLBACK_COLORMASK, !(r && g && b)); -} - -static void savageUpdateSpecular_s4(struct gl_context *ctx) { - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - uint32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui; - - if (_mesa_need_secondary_color(ctx)) { - imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_TRUE; - } else { - imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_FALSE; - } - - if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; -} - -static void savageUpdateSpecular_s3d(struct gl_context *ctx) { - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - uint32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui; - - if (_mesa_need_secondary_color(ctx)) { - imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_TRUE; - } else { - imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_FALSE; - } - - if (drawCtrl != imesa->regs.s3d.drawCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; -} - -static void savageDDLightModelfv_s4(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - savageUpdateSpecular_s4 (ctx); -} -static void savageDDLightModelfv_s3d(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - savageUpdateSpecular_s3d (ctx); -} - -static void savageDDShadeModel_s4(struct gl_context *ctx, GLuint mod) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - uint32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui; - - if (mod == GL_SMOOTH) - { - imesa->regs.s4.drawLocalCtrl.ni.flatShadeEn = GL_FALSE; - } - else - { - imesa->regs.s4.drawLocalCtrl.ni.flatShadeEn = GL_TRUE; - } - - if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; -} -static void savageDDShadeModel_s3d(struct gl_context *ctx, GLuint mod) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - uint32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui; - - if (mod == GL_SMOOTH) - { - imesa->regs.s3d.drawCtrl.ni.flatShadeEn = GL_FALSE; - } - else - { - imesa->regs.s3d.drawCtrl.ni.flatShadeEn = GL_TRUE; - } - - if (drawCtrl != imesa->regs.s3d.drawCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; -} - - -/* ============================================================= - * Fog - * The fogCtrl register has the same position and the same layout - * on savage3d and savage4. No need for two separate functions. - */ - -static void savageDDFogfv(struct gl_context *ctx, GLenum pname, const GLfloat *param) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLuint fogClr; - uint32_t fogCtrl = imesa->regs.s4.fogCtrl.ui; - - /*if ((ctx->Fog.Enabled) &&(pname == GL_FOG_COLOR))*/ - if (ctx->Fog.Enabled) - { - fogClr = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) | - ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) | - ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0)); - imesa->regs.s4.fogCtrl.ni.fogEn = GL_TRUE; - /*cheap fog*/ - imesa->regs.s4.fogCtrl.ni.fogMode = GL_TRUE; - imesa->regs.s4.fogCtrl.ni.fogClr = fogClr; - } - else - { - /*No fog*/ - - imesa->regs.s4.fogCtrl.ni.fogEn = 0; - imesa->regs.s4.fogCtrl.ni.fogMode = 0; - } - - if (fogCtrl != imesa->regs.s4.fogCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} - - -static void -savageDDStencilFuncSeparate(struct gl_context *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - unsigned a=0; - const uint32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui; - const uint32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui; - - imesa->regs.s4.zBufCtrl.ni.stencilRefVal = ctx->Stencil.Ref[0] & 0xff; - imesa->regs.s4.stencilCtrl.ni.readMask = ctx->Stencil.ValueMask[0] & 0xff; - - switch (ctx->Stencil.Function[0]) - { - case GL_NEVER: a = CF_Never; break; - case GL_ALWAYS: a = CF_Always; break; - case GL_LESS: a = CF_Less; break; - case GL_LEQUAL: a = CF_LessEqual; break; - case GL_EQUAL: a = CF_Equal; break; - case GL_GREATER: a = CF_Greater; break; - case GL_GEQUAL: a = CF_GreaterEqual; break; - case GL_NOTEQUAL: a = CF_NotEqual; break; - default: - break; - } - - imesa->regs.s4.stencilCtrl.ni.cmpFunc = a; - - if (zBufCtrl != imesa->regs.s4.zBufCtrl.ui || - stencilCtrl != imesa->regs.s4.stencilCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} - -static void -savageDDStencilMaskSeparate(struct gl_context *ctx, GLenum face, GLuint mask) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - - if (imesa->regs.s4.stencilCtrl.ni.writeMask != (ctx->Stencil.WriteMask[0] & 0xff)) { - imesa->regs.s4.stencilCtrl.ni.writeMask = (ctx->Stencil.WriteMask[0] & 0xff); - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; - } -} - -static unsigned get_stencil_op_value( GLenum op ) -{ - switch (op) - { - case GL_KEEP: return STENCIL_Keep; - case GL_ZERO: return STENCIL_Zero; - case GL_REPLACE: return STENCIL_Equal; - case GL_INCR: return STENCIL_IncClamp; - case GL_DECR: return STENCIL_DecClamp; - case GL_INVERT: return STENCIL_Invert; - case GL_INCR_WRAP: return STENCIL_Inc; - case GL_DECR_WRAP: return STENCIL_Dec; - } - - /* Should *never* get here. */ - return STENCIL_Keep; -} - -static void -savageDDStencilOpSeparate(struct gl_context *ctx, GLenum face, GLenum fail, - GLenum zfail, GLenum zpass) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - const uint32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui; - - imesa->regs.s4.stencilCtrl.ni.failOp = get_stencil_op_value( ctx->Stencil.FailFunc[0] ); - imesa->regs.s4.stencilCtrl.ni.passZfailOp = get_stencil_op_value( ctx->Stencil.ZFailFunc[0] ); - imesa->regs.s4.stencilCtrl.ni.passZpassOp = get_stencil_op_value( ctx->Stencil.ZPassFunc[0] ); - - if (stencilCtrl != imesa->regs.s4.stencilCtrl.ui) - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; -} - - -/* ============================================================= - */ - -static void savageDDEnable_s4(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - switch(cap) { - case GL_ALPHA_TEST: - /* we should consider the disable case*/ - savageBlendFunc_s4(ctx); - break; - case GL_BLEND: - /*add the savageBlendFunc 2001/11/25 - * if call no such function, then glDisable(GL_BLEND) will do noting, - *our chip has no disable bit - */ - savageBlendFunc_s4(ctx); - case GL_COLOR_LOGIC_OP: - /* Fall through: - * For some reason enable(GL_BLEND) affects ColorLogicOpEnabled. - */ - FALLBACK (ctx, SAVAGE_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - break; - case GL_DEPTH_TEST: - savageDDDepthFunc_s4(ctx,ctx->Depth.Func); - break; - case GL_SCISSOR_TEST: - savageDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); - break; - case GL_STENCIL_TEST: - if (!imesa->hw_stencil) - FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state); - else { - imesa->regs.s4.stencilCtrl.ni.stencilEn = state; - if (ctx->Stencil._Enabled && - imesa->regs.s4.zBufCtrl.ni.zBufEn != GL_TRUE) - { - /* Stencil buffer requires Z enabled. */ - imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always; - imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE; - imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE; - } - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL | SAVAGE_UPLOAD_LOCAL; - } - break; - case GL_FOG: - savageDDFogfv(ctx,0,0); - break; - case GL_CULL_FACE: -#if HW_CULL - if (state) - { - savageDDCullFaceFrontFace(ctx,0); - } - else - { - imesa->LcsCullMode = BCM_None; - imesa->new_state |= SAVAGE_NEW_CULL; - } -#endif - break; - case GL_DITHER: - if (state) - { - if ( ctx->Color.DitherFlag ) - { - imesa->regs.s4.drawCtrl1.ni.ditherEn=GL_TRUE; - } - } - if (!ctx->Color.DitherFlag ) - { - imesa->regs.s4.drawCtrl1.ni.ditherEn=GL_FALSE; - } - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; - break; - - case GL_LIGHTING: - savageUpdateSpecular_s4 (ctx); - break; - case GL_TEXTURE_1D: - case GL_TEXTURE_3D: - imesa->new_state |= SAVAGE_NEW_TEXTURE; - break; - case GL_TEXTURE_2D: - imesa->new_state |= SAVAGE_NEW_TEXTURE; - break; - default: - ; - } -} -static void savageDDEnable_s3d(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - switch(cap) { - case GL_ALPHA_TEST: - /* we should consider the disable case*/ - savageBlendFunc_s3d(ctx); - break; - case GL_BLEND: - /*add the savageBlendFunc 2001/11/25 - * if call no such function, then glDisable(GL_BLEND) will do noting, - *our chip has no disable bit - */ - savageBlendFunc_s3d(ctx); - case GL_COLOR_LOGIC_OP: - /* Fall through: - * For some reason enable(GL_BLEND) affects ColorLogicOpEnabled. - */ - FALLBACK (ctx, SAVAGE_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - break; - case GL_DEPTH_TEST: - savageDDDepthFunc_s3d(ctx,ctx->Depth.Func); - break; - case GL_SCISSOR_TEST: - savageDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); - break; - case GL_STENCIL_TEST: - FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state); - break; - case GL_FOG: - savageDDFogfv(ctx,0,0); - break; - case GL_CULL_FACE: -#if HW_CULL - if (state) - { - savageDDCullFaceFrontFace(ctx,0); - } - else - { - imesa->LcsCullMode = BCM_None; - imesa->new_state |= SAVAGE_NEW_CULL; - } -#endif - break; - case GL_DITHER: - if (state) - { - if ( ctx->Color.DitherFlag ) - { - imesa->regs.s3d.drawCtrl.ni.ditherEn=GL_TRUE; - } - } - if (!ctx->Color.DitherFlag ) - { - imesa->regs.s3d.drawCtrl.ni.ditherEn=GL_FALSE; - } - imesa->dirty |= SAVAGE_UPLOAD_LOCAL; - break; - - case GL_LIGHTING: - savageUpdateSpecular_s3d (ctx); - break; - case GL_TEXTURE_1D: - case GL_TEXTURE_3D: - imesa->new_state |= SAVAGE_NEW_TEXTURE; - break; - case GL_TEXTURE_2D: - imesa->new_state |= SAVAGE_NEW_TEXTURE; - break; - default: - ; - } -} - -void savageDDUpdateHwState( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - - if (imesa->new_state) { - savageFlushVertices(imesa); - if (imesa->new_state & SAVAGE_NEW_TEXTURE) { - savageUpdateTextureState( ctx ); - } - if ((imesa->new_state & SAVAGE_NEW_CULL)) { - savageUpdateCull(ctx); - } - imesa->new_state = 0; - } -} - - -static void savageDDPrintDirty( const char *msg, GLuint state ) -{ - fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s\n", - msg, - (unsigned int) state, - (state & SAVAGE_UPLOAD_LOCAL) ? "upload-local, " : "", - (state & SAVAGE_UPLOAD_TEX0) ? "upload-tex0, " : "", - (state & SAVAGE_UPLOAD_TEX1) ? "upload-tex1, " : "", - (state & SAVAGE_UPLOAD_FOGTBL) ? "upload-fogtbl, " : "", - (state & SAVAGE_UPLOAD_GLOBAL) ? "upload-global, " : "", - (state & SAVAGE_UPLOAD_TEXGLOBAL) ? "upload-texglobal, " : "" - ); -} - - -/** - * Check if global registers were changed - */ -static GLboolean savageGlobalRegChanged (savageContextPtr imesa, - GLuint first, GLuint last) { - GLuint i; - for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) { - if (((imesa->oldRegs.ui[i] ^ imesa->regs.ui[i]) & - imesa->globalRegMask.ui[i]) != 0) - return GL_TRUE; - } - return GL_FALSE; -} -static void savageEmitOldRegs (savageContextPtr imesa, - GLuint first, GLuint last, GLboolean global) { - GLuint n = last-first+1; - drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, n*4); - cmd->state.cmd = SAVAGE_CMD_STATE; - cmd->state.global = global; - cmd->state.count = n; - cmd->state.start = first; - memcpy(cmd+1, &imesa->oldRegs.ui[first-SAVAGE_FIRST_REG], n*4); -} -static void savageEmitContiguousRegs (savageContextPtr imesa, - GLuint first, GLuint last) { - GLuint i; - GLuint n = last-first+1; - drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, n*4); - cmd->state.cmd = SAVAGE_CMD_STATE; - cmd->state.global = savageGlobalRegChanged(imesa, first, last); - cmd->state.count = n; - cmd->state.start = first; - memcpy(cmd+1, &imesa->regs.ui[first-SAVAGE_FIRST_REG], n*4); - /* savageAllocCmdBuf may need to flush the cmd buffer and backup - * the current hardware state. It should see the "old" (current) - * state that has actually been emitted to the hardware. Therefore - * this update is done *after* savageAllocCmdBuf. */ - for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) - imesa->oldRegs.ui[i] = imesa->regs.ui[i]; - if (SAVAGE_DEBUG & DEBUG_STATE) - fprintf (stderr, "Emitting regs 0x%02x-0x%02x\n", first, last); -} -static void savageEmitChangedRegs (savageContextPtr imesa, - GLuint first, GLuint last) { - GLuint i, firstChanged; - firstChanged = SAVAGE_NR_REGS; - for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) { - if (imesa->oldRegs.ui[i] != imesa->regs.ui[i]) { - if (firstChanged == SAVAGE_NR_REGS) - firstChanged = i; - } else { - if (firstChanged != SAVAGE_NR_REGS) { - savageEmitContiguousRegs (imesa, firstChanged+SAVAGE_FIRST_REG, - i-1+SAVAGE_FIRST_REG); - firstChanged = SAVAGE_NR_REGS; - } - } - } - if (firstChanged != SAVAGE_NR_REGS) - savageEmitContiguousRegs (imesa, firstChanged+SAVAGE_FIRST_REG, - last); -} -static void savageEmitChangedRegChunk (savageContextPtr imesa, - GLuint first, GLuint last) { - GLuint i; - for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) { - if (imesa->oldRegs.ui[i] != imesa->regs.ui[i]) { - savageEmitContiguousRegs (imesa, first, last); - break; - } - } -} -static void savageUpdateRegister_s4(savageContextPtr imesa) -{ - /* In case the texture image was changed without changing the - * texture address as well, we need to force emitting the texture - * address in order to flush texture cashes. */ - if ((imesa->dirty & SAVAGE_UPLOAD_TEX0) && - imesa->oldRegs.s4.texAddr[0].ui == imesa->regs.s4.texAddr[0].ui) - imesa->oldRegs.s4.texAddr[0].ui = 0xffffffff; - if ((imesa->dirty & SAVAGE_UPLOAD_TEX1) && - imesa->oldRegs.s4.texAddr[1].ui == imesa->regs.s4.texAddr[1].ui) - imesa->oldRegs.s4.texAddr[1].ui = 0xffffffff; - - /* Fix up watermarks */ - if (imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites) { - imesa->regs.s4.destTexWatermarks.ni.destWriteLow = 0; - imesa->regs.s4.destTexWatermarks.ni.destFlush = 1; - } else - imesa->regs.s4.destTexWatermarks.ni.destWriteLow = S4_DWLO; - if (imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites) - imesa->regs.s4.zWatermarks.ni.wLow = 0; - else - imesa->regs.s4.zWatermarks.ni.wLow = S4_ZWLO; - - savageEmitChangedRegs (imesa, 0x1e, 0x39); - - imesa->dirty=0; -} -static void savageUpdateRegister_s3d(savageContextPtr imesa) -{ - /* In case the texture image was changed without changing the - * texture address as well, we need to force emitting the texture - * address in order to flush texture cashes. */ - if ((imesa->dirty & SAVAGE_UPLOAD_TEX0) && - imesa->oldRegs.s3d.texAddr.ui == imesa->regs.s3d.texAddr.ui) - imesa->oldRegs.s3d.texAddr.ui = 0xffffffff; - - /* Fix up watermarks */ - if (imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites) { - imesa->regs.s3d.destTexWatermarks.ni.destWriteLow = 0; - imesa->regs.s3d.destTexWatermarks.ni.destFlush = 1; - } else - imesa->regs.s3d.destTexWatermarks.ni.destWriteLow = S3D_DWLO; - if (imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites) - imesa->regs.s3d.zWatermarks.ni.wLow = 0; - else - imesa->regs.s3d.zWatermarks.ni.wLow = S3D_ZWLO; - - - /* the savage3d uses two contiguous ranges of BCI registers: - * 0x18-0x1c and 0x20-0x38. Some texture registers need to be - * emitted in one chunk or we get some funky rendering errors. */ - savageEmitChangedRegs (imesa, 0x18, 0x19); - savageEmitChangedRegChunk (imesa, 0x1a, 0x1c); - savageEmitChangedRegs (imesa, 0x20, 0x38); - - imesa->dirty=0; -} - - -void savageEmitOldState( savageContextPtr imesa ) -{ - assert(imesa->cmdBuf.write == imesa->cmdBuf.base); - if (imesa->savageScreen->chipset >= S3_SAVAGE4) { - savageEmitOldRegs (imesa, 0x1e, 0x39, GL_TRUE); - } else { - savageEmitOldRegs (imesa, 0x18, 0x1c, GL_TRUE); - savageEmitOldRegs (imesa, 0x20, 0x38, GL_FALSE); - } -} - - -/* Push the state into the sarea and/or texture memory. - */ -void savageEmitChangedState( savageContextPtr imesa ) -{ - if (SAVAGE_DEBUG & DEBUG_VERBOSE_API) - savageDDPrintDirty( "\n\n\nsavageEmitHwStateLocked", imesa->dirty ); - - if (imesa->dirty) - { - if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) - fprintf (stderr, "... emitting state\n"); - if (imesa->savageScreen->chipset >= S3_SAVAGE4) - savageUpdateRegister_s4(imesa); - else - savageUpdateRegister_s3d(imesa); - } - - imesa->dirty = 0; -} - - -static void savageDDInitState_s4( savageContextPtr imesa ) -{ -#if 1 - imesa->regs.s4.destCtrl.ui = 1<<7; -#endif - - imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Less; - imesa->regs.s4.zBufCtrl.ni.wToZEn = GL_TRUE; - if (imesa->float_depth) { - imesa->regs.s4.zBufCtrl.ni.zExpOffset = - imesa->savageScreen->zpp == 2 ? 16 : 32; - imesa->regs.s4.zBufCtrl.ni.floatZEn = GL_TRUE; - } else { - imesa->regs.s4.zBufCtrl.ni.zExpOffset = 0; - imesa->regs.s4.zBufCtrl.ni.floatZEn = GL_FALSE; - } - imesa->regs.s4.texBlendCtrl[0].ui = TBC_NoTexMap; - imesa->regs.s4.texBlendCtrl[1].ui = TBC_NoTexMap1; - imesa->regs.s4.drawCtrl0.ui = 0; -#if 0 - imesa->regs.s4.drawCtrl1.ni.xyOffsetEn = 1; -#endif - - /* Set DestTexWatermarks_31,30 to 01 always. - *Has no effect if dest. flush is disabled. - */ -#if 0 - imesa->regs.s4.zWatermarks.ui = 0x12000C04; - imesa->regs.s4.destTexWatermarks.ui = 0x40200400; -#else - /*imesa->regs.s4.zWatermarks.ui = 0x16001808;*/ - imesa->regs.s4.zWatermarks.ni.rLow = S4_ZRLO; - imesa->regs.s4.zWatermarks.ni.rHigh = S4_ZRHI; - imesa->regs.s4.zWatermarks.ni.wLow = S4_ZWLO; - imesa->regs.s4.zWatermarks.ni.wHigh = S4_ZWHI; - /*imesa->regs.s4.destTexWatermarks.ui = 0x4f000000;*/ - imesa->regs.s4.destTexWatermarks.ni.destReadLow = S4_DRLO; - imesa->regs.s4.destTexWatermarks.ni.destReadHigh = S4_DRHI; - imesa->regs.s4.destTexWatermarks.ni.destWriteLow = S4_DWLO; - imesa->regs.s4.destTexWatermarks.ni.destWriteHigh = S4_DWHI; - imesa->regs.s4.destTexWatermarks.ni.texRead = S4_TR; - imesa->regs.s4.destTexWatermarks.ni.destFlush = 1; -#endif - imesa->regs.s4.drawCtrl0.ni.dPerfAccelEn = GL_TRUE; - - /* clrCmpAlphaBlendCtrl is needed to get alphatest and - * alpha blending working properly - */ - - imesa->regs.s4.texCtrl[0].ni.dBias = 0x08; - imesa->regs.s4.texCtrl[1].ni.dBias = 0x08; - imesa->regs.s4.texCtrl[0].ni.texXprEn = GL_TRUE; - imesa->regs.s4.texCtrl[1].ni.texXprEn = GL_TRUE; - imesa->regs.s4.texCtrl[0].ni.dMax = 0x0f; - imesa->regs.s4.texCtrl[1].ni.dMax = 0x0f; - /* programm a valid tex address, in case texture state is emitted - * in wrong order. */ - if (imesa->lastTexHeap == 2 && imesa->savageScreen->textureSize[1]) { - /* AGP textures available */ - imesa->regs.s4.texAddr[0].ui = imesa->savageScreen->textureOffset[1]|3; - imesa->regs.s4.texAddr[1].ui = imesa->savageScreen->textureOffset[1]|3; - } else { - /* no AGP textures available, use local */ - imesa->regs.s4.texAddr[0].ui = imesa->savageScreen->textureOffset[0]|2; - imesa->regs.s4.texAddr[1].ui = imesa->savageScreen->textureOffset[0]|2; - } - imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_TRUE; - imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One; - imesa->regs.s4.drawLocalCtrl.ni.wrZafterAlphaTst = GL_FALSE; - imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites= GL_TRUE; - imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE; - - imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn= GL_TRUE; - imesa->regs.s4.drawCtrl1.ni.ditherEn = ( - driQueryOptioni(&imesa->optionCache, "color_reduction") == - DRI_CONF_COLOR_REDUCTION_DITHER) ? GL_TRUE : GL_FALSE; - imesa->regs.s4.drawCtrl1.ni.cullMode = BCM_None; - - imesa->regs.s4.zBufCtrl.ni.stencilRefVal = 0x00; - - imesa->regs.s4.stencilCtrl.ni.stencilEn = GL_FALSE; - imesa->regs.s4.stencilCtrl.ni.cmpFunc = CF_Always; - imesa->regs.s4.stencilCtrl.ni.failOp = STENCIL_Keep; - imesa->regs.s4.stencilCtrl.ni.passZfailOp = STENCIL_Keep; - imesa->regs.s4.stencilCtrl.ni.passZpassOp = STENCIL_Keep; - imesa->regs.s4.stencilCtrl.ni.writeMask = 0xff; - imesa->regs.s4.stencilCtrl.ni.readMask = 0xff; - - imesa->LcsCullMode=BCM_None; - imesa->regs.s4.texDescr.ni.palSize = TPS_256; - - /* clear the local registers in the global reg mask */ - imesa->globalRegMask.s4.drawLocalCtrl.ui = 0; - imesa->globalRegMask.s4.texPalAddr.ui = 0; - imesa->globalRegMask.s4.texCtrl[0].ui = 0; - imesa->globalRegMask.s4.texCtrl[1].ui = 0; - imesa->globalRegMask.s4.texAddr[0].ui = 0; - imesa->globalRegMask.s4.texAddr[1].ui = 0; - imesa->globalRegMask.s4.texBlendCtrl[0].ui = 0; - imesa->globalRegMask.s4.texBlendCtrl[1].ui = 0; - imesa->globalRegMask.s4.texXprClr.ui = 0; - imesa->globalRegMask.s4.texDescr.ui = 0; -} -static void savageDDInitState_s3d( savageContextPtr imesa ) -{ -#if 1 - imesa->regs.s3d.destCtrl.ui = 1<<7; -#endif - - imesa->regs.s3d.zBufCtrl.ni.zCmpFunc = CF_Less; -#if 0 - imesa->regs.s3d.drawCtrl.ni.xyOffsetEn = 1; -#endif - - /* Set DestTexWatermarks_31,30 to 01 always. - *Has no effect if dest. flush is disabled. - */ -#if 0 - imesa->regs.s3d.zWatermarks.ui = 0x12000C04; - imesa->regs.s3d.destTexWatermarks.ui = 0x40200400; -#else - /*imesa->regs.s3d.zWatermarks.ui = 0x16001808;*/ - imesa->regs.s3d.zWatermarks.ni.rLow = S3D_ZRLO; - imesa->regs.s3d.zWatermarks.ni.rHigh = S3D_ZRHI; - imesa->regs.s3d.zWatermarks.ni.wLow = S3D_ZWLO; - imesa->regs.s3d.zWatermarks.ni.wHigh = S3D_ZWHI; - /*imesa->regs.s3d.destTexWatermarks.ui = 0x4f000000;*/ - imesa->regs.s3d.destTexWatermarks.ni.destReadLow = S3D_DRLO; - imesa->regs.s3d.destTexWatermarks.ni.destReadHigh = S3D_DRHI; - imesa->regs.s3d.destTexWatermarks.ni.destWriteLow = S3D_DWLO; - imesa->regs.s3d.destTexWatermarks.ni.destWriteHigh = S3D_DWHI; - imesa->regs.s3d.destTexWatermarks.ni.texRead = S3D_TR; - imesa->regs.s3d.destTexWatermarks.ni.destFlush = 1; -#endif - - imesa->regs.s3d.texCtrl.ni.dBias = 0x08; - imesa->regs.s3d.texCtrl.ni.texXprEn = GL_TRUE; - /* texXprEn is needed to get alphatest and alpha blending working - * properly. However, this makes texels with color texXprClr - * completely transparent in some texture environment modes. I - * couldn't find a way to disable this. So choose an arbitrary and - * improbable color. (0 is a bad choice, makes all black texels - * transparent.) */ - imesa->regs.s3d.texXprClr.ui = 0x26ae26ae; - /* programm a valid tex address, in case texture state is emitted - * in wrong order. */ - if (imesa->lastTexHeap == 2 && imesa->savageScreen->textureSize[1]) { - /* AGP textures available */ - imesa->regs.s3d.texAddr.ui = imesa->savageScreen->textureOffset[1]|3; - } else { - /* no AGP textures available, use local */ - imesa->regs.s3d.texAddr.ui = imesa->savageScreen->textureOffset[0]|2; - } - - imesa->regs.s3d.zBufCtrl.ni.drawUpdateEn = GL_TRUE; - imesa->regs.s3d.zBufCtrl.ni.wrZafterAlphaTst = GL_FALSE; - imesa->regs.s3d.zBufCtrl.ni.zUpdateEn = GL_TRUE; - - imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One; - imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE; - imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE; - - imesa->regs.s3d.drawCtrl.ni.ditherEn = ( - driQueryOptioni(&imesa->optionCache, "color_reduction") == - DRI_CONF_COLOR_REDUCTION_DITHER) ? GL_TRUE : GL_FALSE; - imesa->regs.s3d.drawCtrl.ni.cullMode = BCM_None; - - imesa->LcsCullMode = BCM_None; - imesa->regs.s3d.texDescr.ni.palSize = TPS_256; - - /* clear the local registers in the global reg mask */ - imesa->globalRegMask.s3d.texPalAddr.ui = 0; - imesa->globalRegMask.s3d.texXprClr.ui = 0; - imesa->globalRegMask.s3d.texAddr.ui = 0; - imesa->globalRegMask.s3d.texDescr.ui = 0; - imesa->globalRegMask.s3d.texCtrl.ui = 0; - - imesa->globalRegMask.s3d.fogCtrl.ui = 0; - - /* drawCtrl is local with some exceptions */ - imesa->globalRegMask.s3d.drawCtrl.ui = 0; - imesa->globalRegMask.s3d.drawCtrl.ni.cullMode = 0x3; - imesa->globalRegMask.s3d.drawCtrl.ni.alphaTestCmpFunc = 0x7; - imesa->globalRegMask.s3d.drawCtrl.ni.alphaTestEn = 0x1; - imesa->globalRegMask.s3d.drawCtrl.ni.alphaRefVal = 0xff; - - /* zBufCtrl is local with some exceptions */ - imesa->globalRegMask.s3d.zBufCtrl.ui = 0; - imesa->globalRegMask.s3d.zBufCtrl.ni.zCmpFunc = 0x7; - imesa->globalRegMask.s3d.zBufCtrl.ni.zBufEn = 0x1; -} -void savageDDInitState( savageContextPtr imesa ) { - memset (imesa->regs.ui, 0, SAVAGE_NR_REGS*sizeof(uint32_t)); - memset (imesa->globalRegMask.ui, 0xff, SAVAGE_NR_REGS*sizeof(uint32_t)); - if (imesa->savageScreen->chipset >= S3_SAVAGE4) - savageDDInitState_s4 (imesa); - else - savageDDInitState_s3d (imesa); - - /*fprintf(stderr,"DBflag:%d\n",imesa->glCtx->Visual->DBflag);*/ - /* zbufoffset and destctrl have the same position and layout on - * savage4 and savage3d. */ - if (imesa->glCtx->Visual.doubleBufferMode) { - imesa->IsDouble = GL_TRUE; - imesa->toggle = TARGET_BACK; - imesa->regs.s4.destCtrl.ni.offset = - imesa->savageScreen->backOffset>>11; - } else { - imesa->IsDouble = GL_FALSE; - imesa->toggle = TARGET_FRONT; - imesa->regs.s4.destCtrl.ni.offset = - imesa->savageScreen->frontOffset>>11; - } - if(imesa->savageScreen->cpp == 2) { - imesa->regs.s4.destCtrl.ni.dstPixFmt = 0; - imesa->regs.s4.destCtrl.ni.dstWidthInTile = - (imesa->savageScreen->width+63)>>6; - } else { - imesa->regs.s4.destCtrl.ni.dstPixFmt = 1; - imesa->regs.s4.destCtrl.ni.dstWidthInTile = - (imesa->savageScreen->width+31)>>5; - } - imesa->NotFirstFrame = GL_FALSE; - - imesa->regs.s4.zBufOffset.ni.offset=imesa->savageScreen->depthOffset>>11; - if(imesa->savageScreen->zpp == 2) { - imesa->regs.s4.zBufOffset.ni.zBufWidthInTiles = - (imesa->savageScreen->width+63)>>6; - imesa->regs.s4.zBufOffset.ni.zDepthSelect = 0; - } else { - imesa->regs.s4.zBufOffset.ni.zBufWidthInTiles = - (imesa->savageScreen->width+31)>>5; - imesa->regs.s4.zBufOffset.ni.zDepthSelect = 1; - } - - memcpy (imesa->oldRegs.ui, imesa->regs.ui, SAVAGE_NR_REGS*sizeof(uint32_t)); - - /* Emit the initial state to the (empty) command buffer. */ - assert (imesa->cmdBuf.write == imesa->cmdBuf.base); - savageEmitOldState(imesa); - imesa->cmdBuf.start = imesa->cmdBuf.write; -} - - -#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\ - NEW_TEXTURE_MATRIX|\ - NEW_USER_CLIP|NEW_CLIENT_STATE)) - -static void savageDDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - SAVAGE_CONTEXT(ctx)->new_gl_state |= new_state; -} - - -void savageDDInitStateFuncs(struct gl_context *ctx) -{ - ctx->Driver.UpdateState = savageDDInvalidateState; - ctx->Driver.BlendEquationSeparate = savageDDBlendEquationSeparate; - ctx->Driver.Fogfv = savageDDFogfv; - ctx->Driver.Scissor = savageDDScissor; -#if HW_CULL - ctx->Driver.CullFace = savageDDCullFaceFrontFace; - ctx->Driver.FrontFace = savageDDCullFaceFrontFace; -#else - ctx->Driver.CullFace = 0; - ctx->Driver.FrontFace = 0; -#endif /* end #if HW_CULL */ - ctx->Driver.DrawBuffer = savageDDDrawBuffer; - ctx->Driver.ReadBuffer = savageDDReadBuffer; - ctx->Driver.ClearColor = savageDDClearColor; - - ctx->Driver.DepthRange = savageDepthRange; - ctx->Driver.Viewport = savageViewport; - ctx->Driver.RenderMode = savageRenderMode; - - if (SAVAGE_CONTEXT( ctx )->savageScreen->chipset >= S3_SAVAGE4) { - ctx->Driver.Enable = savageDDEnable_s4; - ctx->Driver.AlphaFunc = savageDDAlphaFunc_s4; - ctx->Driver.DepthFunc = savageDDDepthFunc_s4; - ctx->Driver.DepthMask = savageDDDepthMask_s4; - ctx->Driver.BlendFuncSeparate = savageDDBlendFuncSeparate_s4; - ctx->Driver.ColorMask = savageDDColorMask_s4; - ctx->Driver.ShadeModel = savageDDShadeModel_s4; - ctx->Driver.LightModelfv = savageDDLightModelfv_s4; - ctx->Driver.StencilFuncSeparate = savageDDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = savageDDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = savageDDStencilOpSeparate; - } else { - ctx->Driver.Enable = savageDDEnable_s3d; - ctx->Driver.AlphaFunc = savageDDAlphaFunc_s3d; - ctx->Driver.DepthFunc = savageDDDepthFunc_s3d; - ctx->Driver.DepthMask = savageDDDepthMask_s3d; - ctx->Driver.BlendFuncSeparate = savageDDBlendFuncSeparate_s3d; - ctx->Driver.ColorMask = savageDDColorMask_s3d; - ctx->Driver.ShadeModel = savageDDShadeModel_s3d; - ctx->Driver.LightModelfv = savageDDLightModelfv_s3d; - ctx->Driver.StencilFuncSeparate = NULL; - ctx->Driver.StencilMaskSeparate = NULL; - ctx->Driver.StencilOpSeparate = NULL; - } -} diff --git a/src/mesa/drivers/dri/savage/savagestate.h b/src/mesa/drivers/dri/savage/savagestate.h deleted file mode 100644 index dca4fd0c01d..00000000000 --- a/src/mesa/drivers/dri/savage/savagestate.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SAVAGE_STATE_H -#define _SAVAGE_STATE_H - -#include "savagecontext.h" - -void savageCalcViewport( struct gl_context *ctx ); -void savageEmitOldState( savageContextPtr imesa ); -void savageEmitChangedState( savageContextPtr imesa ); - -extern void savageDDUpdateHwState( struct gl_context *ctx ); -extern void savageDDInitState( savageContextPtr imesa ); -extern void savageDDInitStateFuncs( struct gl_context *ctx ); -extern void savageDDRenderStart(struct gl_context *ctx); -extern void savageDDRenderEnd(struct gl_context *ctx); - -#endif diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c deleted file mode 100644 index 9486c12c158..00000000000 --- a/src/mesa/drivers/dri/savage/savagetex.c +++ /dev/null @@ -1,2123 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include "main/context.h" -#include "main/mm.h" -#include "main/macros.h" -#include "main/texstore.h" -#include "main/texobj.h" -#include "main/colormac.h" -#include "main/simple_list.h" -#include "main/enums.h" - -#include "savagecontext.h" -#include "savagetex.h" -#include "savagetris.h" -#include "savageioctl.h" -#include "savage_bci.h" - -#include "xmlpool.h" - -#define TILE_INDEX_DXT1 0 -#define TILE_INDEX_8 1 -#define TILE_INDEX_16 2 -#define TILE_INDEX_DXTn 3 -#define TILE_INDEX_32 4 - -/* On Savage4 the texure LOD-bias needs an offset of ~ 0.3 to get - * somewhere close to software rendering. - */ -#define SAVAGE4_LOD_OFFSET 10 - -/* Tile info for S3TC formats counts in 4x4 blocks instead of texels. - * In DXT1 each block is encoded in 64 bits. In DXT3 and 5 each block is - * encoded in 128 bits. */ - -/* Size 1, 2 and 4 images are packed into the last subtile. Each image - * is repeated to fill a 4x4 pixel area. The figure below shows the - * layout of those 4x4 pixel areas in the 8x8 subtile. - * - * 4 2 - * x 1 - * - * Yuck! 8-bit texture formats use 4x8 subtiles. See below. - */ -static const savageTileInfo tileInfo_pro[5] = { - {16, 16, 16, 8, 1, 2, {0x18, 0x10}}, /* DXT1 */ - {64, 32, 16, 4, 4, 8, {0x30, 0x20}}, /* 8-bit */ - {64, 16, 8, 2, 8, 8, {0x48, 0x08}}, /* 16-bit */ - {16, 8, 16, 4, 1, 2, {0x30, 0x20}}, /* DXT3, DXT5 */ - {32, 16, 4, 2, 8, 8, {0x90, 0x10}}, /* 32-bit */ -}; - -/* Size 1, 2 and 4 images are packed into the last two subtiles. Each - * image is repeated to fill a 4x4 pixel area. The figures below show - * the layout of those 4x4 pixel areas in the two 4x8 subtiles. - * - * second last subtile: 4 last subtile: 2 - * x 1 - */ -static const savageTileInfo tileInfo_s3d_s4[5] = { - {16, 16, 16, 8, 1, 2, {0x18, 0x10}}, /* DXT1 */ - {64, 32, 16, 4, 4, 8, {0x30, 0x20}}, /* 8-bit */ - {64, 16, 16, 2, 4, 8, {0x60, 0x40}}, /* 16-bit */ - {16, 8, 16, 4, 1, 2, {0x30, 0x20}}, /* DXT3, DXT5 */ - {32, 16, 8, 2, 4, 8, {0xc0, 0x80}}, /* 32-bit */ -}; - -/** \brief Template for subtile uploads. - * \param h height in pixels - * \param w width in bytes - */ -#define SUBTILE_FUNC(w,h) \ -static INLINE GLubyte *savageUploadSubtile_##w##x##h \ -(GLubyte *dest, GLubyte *src, GLuint srcStride) \ -{ \ - GLuint y; \ - for (y = 0; y < h; ++y) { \ - memcpy (dest, src, w); \ - src += srcStride; \ - dest += w; \ - } \ - return dest; \ -} - -SUBTILE_FUNC(2, 8) /* 4 bits per pixel, 4 pixels wide */ -SUBTILE_FUNC(4, 8) -SUBTILE_FUNC(8, 8) -SUBTILE_FUNC(16, 8) -SUBTILE_FUNC(32, 8) /* 4 bytes per pixel, 8 pixels wide */ - -SUBTILE_FUNC(8, 2) /* DXT1 */ -SUBTILE_FUNC(16, 2) /* DXT3 and DXT5 */ - -/** \brief Upload a complete tile from src (srcStride) to dest - * - * \param tileInfo Pointer to tiling information - * \param wInSub Width of source/dest image in subtiles - * \param hInSub Height of source/dest image in subtiles - * \param bpp Bytes per pixel - * \param src Pointer to source data - * \param srcStride Byte stride of rows in the source data - * \param dest Pointer to destination - * - * Writes linearly to the destination memory in order to exploit write - * combining. - * - * For a complete tile wInSub and hInSub are set to the same values as - * in tileInfo. If the source image is smaller than a whole tile in - * one or both dimensions then they are set to the values of the - * source image. This only works as long as the source image is bigger - * than 8x8 pixels. - */ -static void savageUploadTile (const savageTileInfo *tileInfo, - GLuint wInSub, GLuint hInSub, GLuint bpp, - GLubyte *src, GLuint srcStride, GLubyte *dest) { - GLuint subStride = tileInfo->subWidth * bpp; - GLubyte *srcSRow = src, *srcSTile = src; - GLubyte *(*subtileFunc) (GLubyte *, GLubyte *, GLuint); - GLuint sx, sy; - switch (subStride) { - case 2: subtileFunc = savageUploadSubtile_2x8; break; - case 4: subtileFunc = savageUploadSubtile_4x8; break; - case 8: subtileFunc = tileInfo->subHeight == 8 ? - savageUploadSubtile_8x8 : savageUploadSubtile_8x2; break; - case 16: subtileFunc = tileInfo->subHeight == 8 ? - savageUploadSubtile_16x8 : savageUploadSubtile_16x2; break; - case 32: subtileFunc = savageUploadSubtile_32x8; break; - default: assert(0); - } - for (sy = 0; sy < hInSub; ++sy) { - srcSTile = srcSRow; - for (sx = 0; sx < wInSub; ++sx) { - src = srcSTile; - dest = subtileFunc (dest, src, srcStride); - srcSTile += subStride; - } - srcSRow += srcStride * tileInfo->subHeight; - } -} - -/** \brief Upload a image that is smaller than 8 pixels in either dimension. - * - * \param tileInfo Pointer to tiling information - * \param width Width of the image - * \param height Height of the image - * \param bpp Bytes per pixel - * \param src Pointer to source data - * \param dest Pointer to destination - * - * This function handles all the special cases that need to be taken - * care off. The caller may need to call this function multiple times - * with the destination offset in different ways since small texture - * images must be repeated in order to fill a whole tile (or 4x4 for - * the last 3 levels). - * - * FIXME: Repeating inside this function would be more efficient. - */ -static void savageUploadTiny (const savageTileInfo *tileInfo, - GLuint pixWidth, GLuint pixHeight, - GLuint width, GLuint height, GLuint bpp, - GLubyte *src, GLubyte *dest) { - GLuint size = MAX2(pixWidth, pixHeight); - - if (width > tileInfo->subWidth) { /* assert: height <= subtile height */ - GLuint wInSub = width / tileInfo->subWidth; - GLuint srcStride = width * bpp; - GLuint subStride = tileInfo->subWidth * bpp; - GLuint subSkip = (tileInfo->subHeight - height) * subStride; - GLubyte *srcSTile = src; - GLuint sx, y; - for (sx = 0; sx < wInSub; ++sx) { - src = srcSTile; - for (y = 0; y < height; ++y) { - memcpy (dest, src, subStride); - src += srcStride; - dest += subStride; - } - dest += subSkip; - srcSTile += subStride; - } - } else if (size > 4) { /* a tile or less wide, except the last 3 levels */ - GLuint srcStride = width * bpp; - GLuint subStride = tileInfo->subWidth * bpp; - /* if the subtile width is 4 we have to skip every other subtile */ - GLuint subSkip = tileInfo->subWidth <= 4 ? - subStride * tileInfo->subHeight : 0; - GLuint skipRemainder = tileInfo->subHeight - 1; - GLuint y; - for (y = 0; y < height; ++y) { - memcpy (dest, src, srcStride); - src += srcStride; - dest += subStride; - if ((y & skipRemainder) == skipRemainder) - dest += subSkip; - } - } else { /* the last 3 mipmap levels */ - GLuint offset = (size <= 2 ? tileInfo->tinyOffset[size-1] : 0); - GLuint subStride = tileInfo->subWidth * bpp; - GLuint y; - dest += offset; - for (y = 0; y < height; ++y) { - memcpy (dest, src, bpp*width); - src += width * bpp; - dest += subStride; - } - } -} - -/** \brief Upload an image from mesa's internal copy. - */ -static void savageUploadTexLevel( savageTexObjPtr t, int level ) -{ - const struct gl_texture_image *image = t->base.tObj->Image[0][level]; - const savageTileInfo *tileInfo = t->tileInfo; - GLuint pixWidth = image->Width2, pixHeight = image->Height2; - GLuint bpp = t->texelBytes; - GLuint width, height; - - /* FIXME: 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) - fprintf (stderr, "Not supported texture border %d.\n", - (int) image->Border); - - if (t->hwFormat == TFT_S3TC4A4Bit || t->hwFormat == TFT_S3TC4CA4Bit || - t->hwFormat == TFT_S3TC4Bit) { - width = (pixWidth+3) / 4; - height = (pixHeight+3) / 4; - } else { - width = pixWidth; - height = pixHeight; - } - - if (pixWidth >= 8 && pixHeight >= 8) { - GLuint *dirtyPtr = t->image[level].dirtyTiles; - GLuint dirtyMask = 1; - - if (width >= tileInfo->width && height >= tileInfo->height) { - GLuint wInTiles = width / tileInfo->width; - GLuint hInTiles = height / tileInfo->height; - GLubyte *srcTRow = image->Data, *src; - GLubyte *dest = (GLubyte *)(t->bufAddr + t->image[level].offset); - GLuint x, y; - for (y = 0; y < hInTiles; ++y) { - src = srcTRow; - for (x = 0; x < wInTiles; ++x) { - if (*dirtyPtr & dirtyMask) { - savageUploadTile (tileInfo, - tileInfo->wInSub, tileInfo->hInSub, - bpp, src, width * bpp, dest); - } - src += tileInfo->width * bpp; - dest += 2048; /* tile size is always 2k */ - if (dirtyMask == 1<<31) { - dirtyMask = 1; - dirtyPtr++; - } else - dirtyMask <<= 1; - } - srcTRow += width * tileInfo->height * bpp; - } - } else if (width >= tileInfo->width) { - GLuint wInTiles = width / tileInfo->width; - GLubyte *src = image->Data; - GLubyte *dest = (GLubyte *)(t->bufAddr + t->image[level].offset); - GLuint tileStride = tileInfo->width * bpp * height; - savageContextPtr imesa = (savageContextPtr)t->base.heap->driverContext; - GLuint x; - /* Savage3D-based chips seem so use a constant tile stride - * of 2048 for vertically incomplete tiles, but only if - * the color depth is 32bpp. Nobody said this was supposed - * to be logical! - */ - if (bpp == 4 && imesa->savageScreen->chipset < S3_SAVAGE4) - tileStride = 2048; - for (x = 0; x < wInTiles; ++x) { - if (*dirtyPtr & dirtyMask) { - savageUploadTile (tileInfo, - tileInfo->wInSub, - height / tileInfo->subHeight, - bpp, src, width * bpp, dest); - } - src += tileInfo->width * bpp; - dest += tileStride; - if (dirtyMask == 1<<31) { - dirtyMask = 1; - dirtyPtr++; - } else - dirtyMask <<= 1; - } - } else { - savageUploadTile (tileInfo, width / tileInfo->subWidth, - height / tileInfo->subHeight, bpp, - image->Data, width * bpp, - (GLubyte *)(t->bufAddr+t->image[level].offset)); - } - } else { - GLuint minHeight, minWidth, hRepeat, vRepeat, x, y; - if (t->hwFormat == TFT_S3TC4A4Bit || t->hwFormat == TFT_S3TC4CA4Bit || - t->hwFormat == TFT_S3TC4Bit) - minWidth = minHeight = 1; - else - minWidth = minHeight = 4; - if (width > minWidth || height > minHeight) { - minWidth = tileInfo->subWidth; - minHeight = tileInfo->subHeight; - } - hRepeat = width >= minWidth ? 1 : minWidth / width; - vRepeat = height >= minHeight ? 1 : minHeight / height; - for (y = 0; y < vRepeat; ++y) { - GLuint offset = y * tileInfo->subWidth*height * bpp; - for (x = 0; x < hRepeat; ++x) { - savageUploadTiny (tileInfo, pixWidth, pixHeight, - width, height, bpp, image->Data, - (GLubyte *)(t->bufAddr + - t->image[level].offset+offset)); - offset += width * bpp; - } - } - } -} - -/** \brief Compute the destination size of a texture image - */ -static GLuint savageTexImageSize (GLuint width, GLuint height, GLuint bpp) { - /* full subtiles */ - if (width >= 8 && height >= 8) - return width * height * bpp; - /* special case for the last three mipmap levels: the hardware computes - * the offset internally */ - else if (width <= 4 && height <= 4) - return 0; - /* partially filled sub tiles waste memory - * on Savage3D and Savage4 with subtile width 4 every other subtile is - * skipped if width < 8 so we can assume a uniform subtile width of 8 */ - else if (width >= 8) - return width * 8 * bpp; - else if (height >= 8) - return 8 * height * bpp; - else - return 64 * bpp; -} - -/** \brief Compute the destination size of a compressed texture image - */ -static GLuint savageCompressedTexImageSize (GLuint width, GLuint height, - GLuint bpp) { - width = (width+3) / 4; - height = (height+3) / 4; - /* full subtiles */ - if (width >= 2 && height >= 2) - return width * height * bpp; - /* special case for the last three mipmap levels: the hardware computes - * the offset internally */ - else if (width <= 1 && height <= 1) - return 0; - /* partially filled sub tiles waste memory - * on Savage3D and Savage4 with subtile width 4 every other subtile is - * skipped if width < 8 so we can assume a uniform subtile width of 8 */ - else if (width >= 2) - return width * 2 * bpp; - else if (height >= 2) - return 2 * height * bpp; - else - return 4 * bpp; -} - -/** \brief Compute the number of (partial) tiles of a texture image - */ -static GLuint savageTexImageTiles (GLuint width, GLuint height, - const savageTileInfo *tileInfo) -{ - return (width + tileInfo->width - 1) / tileInfo->width * - (height + tileInfo->height - 1) / tileInfo->height; -} - -/** \brief Mark dirty tiles - * - * Some care must be taken because tileInfo may not be set or not - * up-to-date. So we check if tileInfo is initialized and if the number - * of tiles in the bit vector matches the number of tiles computed from - * the current tileInfo. - */ -static void savageMarkDirtyTiles (savageTexObjPtr t, GLuint level, - GLuint totalWidth, GLuint totalHeight, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height) -{ - GLuint wInTiles, hInTiles; - GLuint x0, y0, x1, y1; - GLuint x, y; - if (!t->tileInfo) - return; - wInTiles = (totalWidth + t->tileInfo->width - 1) / t->tileInfo->width; - hInTiles = (totalHeight + t->tileInfo->height - 1) / t->tileInfo->height; - if (wInTiles * hInTiles != t->image[level].nTiles) - return; - - x0 = xoffset / t->tileInfo->width; - y0 = yoffset / t->tileInfo->height; - x1 = (xoffset + width - 1) / t->tileInfo->width; - y1 = (yoffset + height - 1) / t->tileInfo->height; - - for (y = y0; y <= y1; ++y) { - GLuint *ptr = t->image[level].dirtyTiles + (y * wInTiles + x0) / 32; - GLuint mask = 1 << (y * wInTiles + x0) % 32; - for (x = x0; x <= x1; ++x) { - *ptr |= mask; - if (mask == (1<<31)) { - ptr++; - mask = 1; - } else { - mask <<= 1; - } - } - } -} - -/** \brief Mark all tiles as dirty - */ -static void savageMarkAllTiles (savageTexObjPtr t, GLuint level) -{ - GLuint words = (t->image[level].nTiles + 31) / 32; - if (words) - memset(t->image[level].dirtyTiles, ~0, words*sizeof(GLuint)); -} - - -static void savageSetTexWrapping(savageTexObjPtr tex, GLenum s, GLenum t) -{ - tex->setup.sWrapMode = s; - tex->setup.tWrapMode = t; -} - -static void savageSetTexFilter(savageTexObjPtr t, GLenum minf, GLenum magf) -{ - t->setup.minFilter = minf; - t->setup.magFilter = magf; -} - - -/* Need a fallback ? - */ -static void savageSetTexBorderColor(savageTexObjPtr t, const GLfloat color[4]) -{ -/* t->Setup[SAVAGE_TEXREG_TEXBORDERCOL] = */ - /*t->setup.borderColor = SAVAGEPACKCOLOR8888(color[0],color[1],color[2],color[3]); */ -} - - - -static savageTexObjPtr -savageAllocTexObj( struct gl_texture_object *texObj ) -{ - savageTexObjPtr t; - - t = (savageTexObjPtr) calloc(1,sizeof(*t)); - texObj->DriverData = t; - if ( t != NULL ) { - GLuint i; - - /* Initialize non-image-dependent parts of the state: - */ - t->base.tObj = texObj; - t->base.dirty_images[0] = 0; - t->dirtySubImages = 0; - t->tileInfo = NULL; - - /* Initialize dirty tiles bit vectors - */ - for (i = 0; i < SAVAGE_TEX_MAXLEVELS; ++i) - t->image[i].nTiles = 0; - - /* FIXME Something here to set initial values for other parts of - * FIXME t->setup? - */ - - make_empty_list( &t->base ); - - savageSetTexWrapping(t,texObj->Sampler.WrapS,texObj->Sampler.WrapT); - savageSetTexFilter(t,texObj->Sampler.MinFilter,texObj->Sampler.MagFilter); - savageSetTexBorderColor(t,texObj->Sampler.BorderColor.f); - } - - return t; -} - -/* Mesa texture formats for alpha-images on Savage3D/IX/MX - * - * Promoting texture images to ARGB888 or ARGB4444 doesn't work - * because we can't tell the hardware to ignore the color components - * and only use the alpha component. So we define our own texture - * formats that promote to ARGB8888 or ARGB4444 and set the color - * components to white. This way we get the correct result. - */ - -#if 0 -/* Using MESA_FORMAT_RGBA8888 to store alpha-only textures should - * work but is space inefficient. - */ - -static GLboolean -_savage_texstore_a1114444(TEXSTORE_PARAMS); - -static GLboolean -_savage_texstore_a1118888(TEXSTORE_PARAMS); - -static struct gl_texture_format _savage_texformat_a1114444 = { - MESA_FORMAT_ARGB4444, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /* RedBits */ - 4, /* GreenBits */ - 4, /* BlueBits */ - 4, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* StencilBits */ - 2, /* TexelBytes */ - _savage_texstore_a1114444, /* StoreTexImageFunc */ - NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by - * savageDDInitTextureFuncs */ -}; -static struct gl_texture_format _savage_texformat_a1118888 = { - MESA_FORMAT_ARGB8888, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 8, /* RedBits */ - 8, /* GreenBits */ - 8, /* BlueBits */ - 8, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* StencilBits */ - 4, /* TexelBytes */ - _savage_texstore_a1118888, /* StoreTexImageFunc */ - NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by - * savageDDInitTextureFuncs */ -}; - - -static GLboolean -_savage_texstore_a1114444(TEXSTORE_PARAMS) -{ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseInternalFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - - ASSERT(dstFormat == &_savage_texformat_a1114444); - ASSERT(baseInternalFormat == GL_ALPHA); - - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUI = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[0]), - 255, 255, 255 ); - src += 1; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - - return GL_TRUE; -} - - -static GLboolean -_savage_texstore_a1118888(TEXSTORE_PARAMS) -{ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseInternalFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - - ASSERT(dstFormat == &_savage_texformat_a1118888); - ASSERT(baseInternalFormat == GL_ALPHA); - - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[0]), - 255, 255, 255 ); - src += 1; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - - return GL_TRUE; -} -#endif - - -/* Called by the _mesa_store_teximage[123]d() functions. */ -static gl_format -savageChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - const GLboolean do32bpt = - ( imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 ); - const GLboolean force16bpt = - ( imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 ); - const GLboolean isSavage4 = (imesa->savageScreen->chipset >= S3_SAVAGE4); - (void) format; - - switch ( internalFormat ) { - case 4: - case GL_RGBA: - case GL_COMPRESSED_RGBA: - switch ( type ) { - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555; - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return MESA_FORMAT_ARGB4444; - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return MESA_FORMAT_ARGB1555; - default: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - } - - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - switch ( type ) { - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return MESA_FORMAT_ARGB4444; - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return MESA_FORMAT_ARGB1555; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - return MESA_FORMAT_RGB565; - default: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - } - - case GL_RGBA8: - case GL_RGBA12: - case GL_RGBA16: - return !force16bpt ? - MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - - case GL_RGB10_A2: - return !force16bpt ? - MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555; - - case GL_RGBA4: - case GL_RGBA2: - return MESA_FORMAT_ARGB4444; - - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - - case GL_RGB5: - case GL_RGB4: - case GL_R3_G3_B2: - return MESA_FORMAT_RGB565; - - case GL_ALPHA: - case GL_COMPRESSED_ALPHA: -#if 0 - return isSavage4 ? MESA_FORMAT_a8 : ( - do32bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444); -#else - if (isSavage4) - return MESA_FORMAT_A8; - else if (do32bpt) - return MESA_FORMAT_ARGB8888; - else - return MESA_FORMAT_ARGB4444; -#endif - case GL_ALPHA4: -#if 0 - return isSavage4 ? MESA_FORMAT_a8 : &_savage_texformat_a1114444; -#else - if (isSavage4) - return MESA_FORMAT_A8; - else - return MESA_FORMAT_ARGB4444; -#endif - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: -#if 0 - return isSavage4 ? MESA_FORMAT_a8 : ( - !force16bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444); -#else - if (isSavage4) - return MESA_FORMAT_A8; - else if (force16bpt) - return MESA_FORMAT_ARGB4444; - else - return MESA_FORMAT_ARGB8888; -#endif - case 1: - case GL_LUMINANCE: - case GL_COMPRESSED_LUMINANCE: - /* no alpha, but use argb1555 in 16bit case to get pure grey values */ - return isSavage4 ? MESA_FORMAT_L8 : ( - do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555); - case GL_LUMINANCE4: - return isSavage4 ? MESA_FORMAT_L8 : MESA_FORMAT_ARGB1555; - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return isSavage4 ? MESA_FORMAT_L8 : ( - !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555); - - case 2: - case GL_LUMINANCE_ALPHA: - case GL_COMPRESSED_LUMINANCE_ALPHA: - /* Savage4 has a al44 texture format. But it's not supported by Mesa. */ - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - return MESA_FORMAT_ARGB4444; - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; -#if 0 - /* TFT_I8 produces garbage on ProSavageDDR and subsequent texture - * disable keeps rendering garbage. Disabled for now. */ - case GL_INTENSITY: - case GL_COMPRESSED_INTENSITY: - return isSavage4 ? MESA_FORMAT_i8 : ( - do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444); - case GL_INTENSITY4: - return isSavage4 ? MESA_FORMAT_i8 : MESA_FORMAT_ARGB4444; - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return isSavage4 ? MESA_FORMAT_i8 : ( - !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444); -#else - case GL_INTENSITY: - case GL_COMPRESSED_INTENSITY: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - case GL_INTENSITY4: - return MESA_FORMAT_ARGB4444; - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; -#endif - - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return MESA_FORMAT_RGBA_DXT1; - - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return MESA_FORMAT_RGBA_DXT3; - - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - if (!isSavage4) - /* Not the best choice but Savage3D/MX/IX don't support DXT3 or DXT5. */ - return MESA_FORMAT_RGBA_DXT1; - /* fall through */ - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return MESA_FORMAT_RGBA_DXT5; - -/* - 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: - _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__); - return MESA_FORMAT_NONE; - } -} - -static void savageSetTexImages( savageContextPtr imesa, - const struct gl_texture_object *tObj ) -{ - savageTexObjPtr t = (savageTexObjPtr) tObj->DriverData; - struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; - GLuint offset, i, textureFormat, tileIndex, size; - GLint firstLevel, lastLevel; - - assert(t); - assert(image); - - switch (image->TexFormat) { - case MESA_FORMAT_ARGB8888: - textureFormat = TFT_ARGB8888; - t->texelBytes = tileIndex = 4; - break; - case MESA_FORMAT_ARGB1555: - textureFormat = TFT_ARGB1555; - t->texelBytes = tileIndex = 2; - break; - case MESA_FORMAT_ARGB4444: - textureFormat = TFT_ARGB4444; - t->texelBytes = tileIndex = 2; - break; - case MESA_FORMAT_RGB565: - textureFormat = TFT_RGB565; - t->texelBytes = tileIndex = 2; - break; - case MESA_FORMAT_L8: - textureFormat = TFT_L8; - t->texelBytes = tileIndex = 1; - break; - case MESA_FORMAT_I8: - textureFormat = TFT_I8; - t->texelBytes = tileIndex = 1; - break; - case MESA_FORMAT_A8: - textureFormat = TFT_A8; - t->texelBytes = tileIndex = 1; - break; - case MESA_FORMAT_RGB_DXT1: - textureFormat = TFT_S3TC4Bit; - tileIndex = TILE_INDEX_DXT1; - t->texelBytes = 8; - break; - case MESA_FORMAT_RGBA_DXT1: - textureFormat = TFT_S3TC4Bit; - tileIndex = TILE_INDEX_DXT1; - t->texelBytes = 8; - break; - case MESA_FORMAT_RGBA_DXT3: - textureFormat = TFT_S3TC4A4Bit; - tileIndex = TILE_INDEX_DXTn; - t->texelBytes = 16; - break; - case MESA_FORMAT_RGBA_DXT5: - textureFormat = TFT_S3TC4CA4Bit; - tileIndex = TILE_INDEX_DXTn; - t->texelBytes = 16; - break; - default: - _mesa_problem(imesa->glCtx, "Bad texture format in %s", __FUNCTION__); - return; - } - t->hwFormat = textureFormat; - - /* Select tiling format depending on the chipset and texture format */ - if (imesa->savageScreen->chipset <= S3_SAVAGE4) - t->tileInfo = &tileInfo_s3d_s4[tileIndex]; - else - t->tileInfo = &tileInfo_pro[tileIndex]; - - /* Compute which mipmap levels we really want to send to the hardware. - */ - driCalculateTextureFirstLastLevel( &t->base ); - firstLevel = t->base.firstLevel; - lastLevel = t->base.lastLevel; - - /* Figure out the size now (and count the levels). Upload won't be - * done until later. If the number of tiles changes, it means that - * this function is called for the first time on this tex object or - * the image or the destination color format changed. So all tiles - * are marked as dirty. - */ - offset = 0; - size = 1; - for ( i = firstLevel ; i <= lastLevel && tObj->Image[0][i] ; i++ ) { - GLuint nTiles; - nTiles = savageTexImageTiles (image->Width2, image->Height2, t->tileInfo); - if (t->image[i].nTiles != nTiles) { - GLuint words = (nTiles + 31) / 32; - if (t->image[i].nTiles != 0) { - free(t->image[i].dirtyTiles); - } - t->image[i].dirtyTiles = malloc(words*sizeof(GLuint)); - memset(t->image[i].dirtyTiles, ~0, words*sizeof(GLuint)); - } - t->image[i].nTiles = nTiles; - - t->image[i].offset = offset; - - image = tObj->Image[0][i]; - if (t->texelBytes >= 8) - size = savageCompressedTexImageSize (image->Width2, image->Height2, - t->texelBytes); - else - size = savageTexImageSize (image->Width2, image->Height2, - t->texelBytes); - offset += size; - } - - t->base.lastLevel = i-1; - t->base.totalSize = offset; - /* the last three mipmap levels don't add to the offset. They are packed - * into 64 pixels. */ - if (size == 0) - t->base.totalSize += (t->texelBytes >= 8 ? 4 : 64) * t->texelBytes; - /* 2k-aligned (really needed?) */ - t->base.totalSize = (t->base.totalSize + 2047UL) & ~2047UL; -} - -void savageDestroyTexObj(savageContextPtr imesa, savageTexObjPtr t) -{ - GLuint i; - - /* Free dirty tiles bit vectors */ - for (i = 0; i < SAVAGE_TEX_MAXLEVELS; ++i) { - if (t->image[i].nTiles) - free (t->image[i].dirtyTiles); - } - - /* See if it was the driver's current object. - */ - if ( imesa != NULL ) - { - for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) - { - if ( &t->base == imesa->CurrentTexObj[ i ] ) { - assert( t->base.bound & (1 << i) ); - imesa->CurrentTexObj[ i ] = NULL; - } - } - } -} - -/* Upload a texture's images to one of the texture heaps. May have to - * eject our own and/or other client's texture objects to make room - * for the upload. - */ -static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t ) -{ - const GLint numLevels = t->base.lastLevel - t->base.firstLevel + 1; - GLuint i; - - assert(t); - - LOCK_HARDWARE(imesa); - - /* Do we need to eject LRU texture objects? - */ - if (!t->base.memBlock) { - GLint heap; - GLuint ofs; - - heap = driAllocateTexture(imesa->textureHeaps, imesa->lastTexHeap, - (driTextureObject *)t); - if (heap == -1) { - UNLOCK_HARDWARE(imesa); - return; - } - - assert(t->base.memBlock); - ofs = t->base.memBlock->ofs; - t->setup.physAddr = imesa->savageScreen->textureOffset[heap] + ofs; - t->bufAddr = (GLubyte *)imesa->savageScreen->texVirtual[heap] + ofs; - imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; /* FIXME: really needed? */ - } - - /* Let the world know we've used this memory recently. - */ - driUpdateTextureLRU( &t->base ); - UNLOCK_HARDWARE(imesa); - - if (t->base.dirty_images[0] || t->dirtySubImages) { - if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX) - fprintf(stderr, "Texture upload: |"); - - /* Heap timestamps are only reliable with Savage DRM 2.3.x or - * later. Earlier versions had only 16 bit time stamps which - * would wrap too frequently. */ - if (imesa->savageScreen->driScrnPriv->drm_version.minor >= 3) { - unsigned int heap = t->base.heap->heapId; - LOCK_HARDWARE(imesa); - savageWaitEvent (imesa, imesa->textureHeaps[heap]->timestamp); - } else { - savageFlushVertices (imesa); - LOCK_HARDWARE(imesa); - savageFlushCmdBufLocked (imesa, GL_FALSE); - WAIT_IDLE_EMPTY_LOCKED(imesa); - } - - for (i = 0 ; i < numLevels ; i++) { - const GLint j = t->base.firstLevel + i; /* the texObj's level */ - if (t->base.dirty_images[0] & (1 << j)) { - savageMarkAllTiles(t, j); - if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX) - fprintf (stderr, "*"); - } else if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX) { - if (t->dirtySubImages & (1 << j)) - fprintf (stderr, "."); - else - fprintf (stderr, " "); - } - if ((t->base.dirty_images[0] | t->dirtySubImages) & (1 << j)) - savageUploadTexLevel( t, j ); - } - - UNLOCK_HARDWARE(imesa); - t->base.dirty_images[0] = 0; - t->dirtySubImages = 0; - - if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX) - fprintf(stderr, "|\n"); - } -} - - -static void -savage4_set_wrap_mode( savageContextPtr imesa, unsigned unit, - GLenum s_mode, GLenum t_mode ) -{ - switch( s_mode ) { - case GL_REPEAT: - imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Wrap; - break; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Clamp; - break; - case GL_MIRRORED_REPEAT: - imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Mirror; - break; - } - - switch( t_mode ) { - case GL_REPEAT: - imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Wrap; - break; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Clamp; - break; - case GL_MIRRORED_REPEAT: - imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Mirror; - break; - } -} - - -/** - * Sets the hardware bits for the specified GL texture filter modes. - * - * \todo - * Does the Savage4 have the ability to select the magnification filter? - */ -static void -savage4_set_filter_mode( savageContextPtr imesa, unsigned unit, - GLenum minFilter, GLenum magFilter ) -{ - (void) magFilter; - - switch (minFilter) { - case GL_NEAREST: - imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Point; - imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_FALSE; - break; - - case GL_LINEAR: - imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Bilin; - imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_FALSE; - break; - - case GL_NEAREST_MIPMAP_NEAREST: - imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Point; - imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE; - break; - - case GL_LINEAR_MIPMAP_NEAREST: - imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Bilin; - imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE; - break; - - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Trilin; - imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE; - break; - } -} - - -static void savageUpdateTex0State_s4( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - struct gl_texture_object *tObj; - struct gl_texture_image *image; - savageTexObjPtr t; - GLuint format; - - /* disable */ - imesa->regs.s4.texDescr.ni.tex0En = GL_FALSE; - imesa->regs.s4.texBlendCtrl[0].ui = TBC_NoTexMap; - imesa->regs.s4.texCtrl[0].ui = 0x20f040; - if (ctx->Texture.Unit[0]._ReallyEnabled == 0) - return; - - tObj = ctx->Texture.Unit[0]._Current; - if ((ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) - || tObj->Image[0][tObj->BaseLevel]->Border > 0) { - /* 3D texturing enabled, or texture border - fallback */ - FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE); - return; - } - - /* Do 2D texture setup */ - - t = tObj->DriverData; - if (!t) { - t = savageAllocTexObj( tObj ); - if (!t) - return; - } - - imesa->CurrentTexObj[0] = &t->base; - t->base.bound |= 1; - - if (t->base.dirty_images[0] || t->dirtySubImages) { - savageSetTexImages(imesa, tObj); - savageUploadTexImages(imesa, t); - } - - driUpdateTextureLRU( &t->base ); - - format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - switch (ctx->Texture.Unit[0].EnvMode) { - case GL_REPLACE: - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE; - switch(format) - { - case GL_LUMINANCE: - case GL_RGB: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_Decal; - break; - - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - case GL_INTENSITY: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_Copy; - break; - - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_CopyAlpha; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 0, - &imesa->regs.s4.texBlendCtrl[0]); - break; - - case GL_DECAL: - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE; - switch (format) - { - case GL_RGB: - case GL_LUMINANCE: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_Decal; - break; - - case GL_RGBA: - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_DecalAlpha; - break; - - /* - GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_INTENSITY - are undefined with GL_DECAL - */ - - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_CopyAlpha; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 0, - &imesa->regs.s4.texBlendCtrl[0]); - break; - - case GL_MODULATE: - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE; - imesa->regs.s4.texBlendCtrl[0].ui = TBC_ModulAlpha; - __HWEnvCombineSingleUnitScale(imesa, 0, 0, - &imesa->regs.s4.texBlendCtrl[0]); - break; - - case GL_BLEND: - imesa->regs.s4.texBlendColor.ui = imesa->texEnvColor; - - switch (format) - { - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_ModulAlpha; - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE; - break; - - case GL_LUMINANCE: - case GL_RGB: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_Blend0; - imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE; - imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE; - imesa->regs.s4.texDescr.ni.tex1Width = - imesa->regs.s4.texDescr.ni.tex0Width; - imesa->regs.s4.texDescr.ni.tex1Height = - imesa->regs.s4.texDescr.ni.tex0Height; - imesa->regs.s4.texDescr.ni.tex1Fmt = - imesa->regs.s4.texDescr.ni.tex0Fmt; - - imesa->regs.s4.texAddr[1].ui = imesa->regs.s4.texAddr[0].ui; - imesa->regs.s4.texBlendCtrl[1].ui = TBC_Blend1; - - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_TRUE; - imesa->bTexEn1 = GL_TRUE; - break; - - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_BlendAlpha0; - imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE; - imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE; - imesa->regs.s4.texDescr.ni.tex1Width = - imesa->regs.s4.texDescr.ni.tex0Width; - imesa->regs.s4.texDescr.ni.tex1Height = - imesa->regs.s4.texDescr.ni.tex0Height; - imesa->regs.s4.texDescr.ni.tex1Fmt = - imesa->regs.s4.texDescr.ni.tex0Fmt; - - imesa->regs.s4.texAddr[1].ui = imesa->regs.s4.texAddr[0].ui; - imesa->regs.s4.texBlendCtrl[1].ui = TBC_BlendAlpha1; - - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_TRUE; - imesa->bTexEn1 = GL_TRUE; - break; - - case GL_INTENSITY: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_BlendInt0; - imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE; - imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE; - imesa->regs.s4.texDescr.ni.tex1Width = - imesa->regs.s4.texDescr.ni.tex0Width; - imesa->regs.s4.texDescr.ni.tex1Height = - imesa->regs.s4.texDescr.ni.tex0Height; - imesa->regs.s4.texDescr.ni.tex1Fmt = - imesa->regs.s4.texDescr.ni.tex0Fmt; - - imesa->regs.s4.texAddr[1].ui = imesa->regs.s4.texAddr[0].ui; - imesa->regs.s4.texBlendCtrl[1].ui = TBC_BlendInt1; - - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_TRUE; - imesa->regs.s4.texCtrl[0].ni.alphaArg1Invert = GL_TRUE; - imesa->bTexEn1 = GL_TRUE; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 0, - &imesa->regs.s4.texBlendCtrl[0]); - break; - - case GL_ADD: - imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE; - switch (format) - { - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_ModulAlpha; - break; - - case GL_LUMINANCE: - case GL_RGB: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_Add; - break; - - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_Add; - break; - - case GL_INTENSITY: - imesa->regs.s4.texBlendCtrl[0].ui = TBC_AddAlpha; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 0, - &imesa->regs.s4.texBlendCtrl[0]); - break; - -#if GL_ARB_texture_env_combine - case GL_COMBINE_ARB: - __HWParseTexEnvCombine(imesa, 0, &imesa->regs.s4.texCtrl[0], - &imesa->regs.s4.texBlendCtrl[0]); - break; -#endif - - default: - fprintf(stderr, "unknown tex env mode"); - exit(1); - break; - } - - savage4_set_wrap_mode( imesa, 0, t->setup.sWrapMode, t->setup.tWrapMode ); - savage4_set_filter_mode( imesa, 0, t->setup.minFilter, t->setup.magFilter ); - - if((ctx->Texture.Unit[0].LodBias !=0.0F) || - (imesa->regs.s4.texCtrl[0].ni.dBias != 0)) - { - int bias = (int)(ctx->Texture.Unit[0].LodBias * 32.0) + - SAVAGE4_LOD_OFFSET; - if (bias < -256) - bias = -256; - else if (bias > 255) - bias = 255; - imesa->regs.s4.texCtrl[0].ni.dBias = bias & 0x1ff; - } - - image = tObj->Image[0][tObj->BaseLevel]; - imesa->regs.s4.texDescr.ni.tex0En = GL_TRUE; - imesa->regs.s4.texDescr.ni.tex0Width = image->WidthLog2; - imesa->regs.s4.texDescr.ni.tex0Height = image->HeightLog2; - imesa->regs.s4.texDescr.ni.tex0Fmt = t->hwFormat; - imesa->regs.s4.texCtrl[0].ni.dMax = t->base.lastLevel - t->base.firstLevel; - - if (imesa->regs.s4.texDescr.ni.tex1En) - imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE; - - imesa->regs.s4.texAddr[0].ui = (uint32_t) t->setup.physAddr | 0x2; - if(t->base.heap->heapId == SAVAGE_AGP_HEAP) - imesa->regs.s4.texAddr[0].ui |= 0x1; - - return; -} -static void savageUpdateTex1State_s4( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - struct gl_texture_object *tObj; - struct gl_texture_image *image; - savageTexObjPtr t; - GLuint format; - - /* disable */ - if(imesa->bTexEn1) - { - imesa->bTexEn1 = GL_FALSE; - return; - } - - imesa->regs.s4.texDescr.ni.tex1En = GL_FALSE; - imesa->regs.s4.texBlendCtrl[1].ui = TBC_NoTexMap1; - imesa->regs.s4.texCtrl[1].ui = 0x20f040; - imesa->regs.s4.texDescr.ni.texBLoopEn = GL_FALSE; - if (ctx->Texture.Unit[1]._ReallyEnabled == 0) - return; - - tObj = ctx->Texture.Unit[1]._Current; - - if ((ctx->Texture.Unit[1]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) - || tObj->Image[0][tObj->BaseLevel]->Border > 0) { - /* 3D texturing enabled, or texture border - fallback */ - FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE); - return; - } - - /* Do 2D texture setup */ - - t = tObj->DriverData; - if (!t) { - t = savageAllocTexObj( tObj ); - if (!t) - return; - } - - imesa->CurrentTexObj[1] = &t->base; - - t->base.bound |= 2; - - if (t->base.dirty_images[0] || t->dirtySubImages) { - savageSetTexImages(imesa, tObj); - savageUploadTexImages(imesa, t); - } - - driUpdateTextureLRU( &t->base ); - - format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - switch (ctx->Texture.Unit[1].EnvMode) { - case GL_REPLACE: - imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE; - switch (format) - { - case GL_LUMINANCE: - case GL_RGB: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_Decal; - break; - - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_Copy; - break; - - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_CopyAlpha1; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl); - break; - case GL_MODULATE: - imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE; - imesa->regs.s4.texBlendCtrl[1].ui = TBC_ModulAlpha1; - __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl); - break; - - case GL_ADD: - imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE; - switch (format) - { - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_ModulAlpha1; - break; - - case GL_LUMINANCE: - case GL_RGB: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_Add1; - break; - - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_Add1; - break; - - case GL_INTENSITY: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_AddAlpha1; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl); - break; - -#if GL_ARB_texture_env_combine - case GL_COMBINE_ARB: - __HWParseTexEnvCombine(imesa, 1, &texCtrl, &imesa->regs.s4.texBlendCtrl); - break; -#endif - - case GL_DECAL: - imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE; - - switch (format) - { - case GL_LUMINANCE: - case GL_RGB: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_Decal1; - break; - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_DecalAlpha1; - break; - - /* - // GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_INTENSITY - // are undefined with GL_DECAL - */ - case GL_ALPHA: - imesa->regs.s4.texBlendCtrl[1].ui = TBC_CopyAlpha1; - break; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl); - break; - - case GL_BLEND: - if (format == GL_LUMINANCE) - { - /* - // This is a hack for GLQuake, invert. - */ - imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_TRUE; - imesa->regs.s4.texBlendCtrl[1].ui = 0; - } - __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl); - break; - - default: - fprintf(stderr, "unknown tex 1 env mode\n"); - exit(1); - break; - } - - savage4_set_wrap_mode( imesa, 1, t->setup.sWrapMode, t->setup.tWrapMode ); - savage4_set_filter_mode( imesa, 1, t->setup.minFilter, t->setup.magFilter ); - - if((ctx->Texture.Unit[1].LodBias !=0.0F) || - (imesa->regs.s4.texCtrl[1].ni.dBias != 0)) - { - int bias = (int)(ctx->Texture.Unit[1].LodBias * 32.0) + - SAVAGE4_LOD_OFFSET; - if (bias < -256) - bias = -256; - else if (bias > 255) - bias = 255; - imesa->regs.s4.texCtrl[1].ni.dBias = bias & 0x1ff; - } - - image = tObj->Image[0][tObj->BaseLevel]; - imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE; - imesa->regs.s4.texDescr.ni.tex1Width = image->WidthLog2; - imesa->regs.s4.texDescr.ni.tex1Height = image->HeightLog2; - imesa->regs.s4.texDescr.ni.tex1Fmt = t->hwFormat; - imesa->regs.s4.texCtrl[1].ni.dMax = t->base.lastLevel - t->base.firstLevel; - imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE; - - imesa->regs.s4.texAddr[1].ui = (uint32_t) t->setup.physAddr | 2; - if(t->base.heap->heapId == SAVAGE_AGP_HEAP) - imesa->regs.s4.texAddr[1].ui |= 0x1; -} -static void savageUpdateTexState_s3d( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - struct gl_texture_object *tObj; - struct gl_texture_image *image; - savageTexObjPtr t; - GLuint format; - - /* disable */ - imesa->regs.s3d.texCtrl.ui = 0; - imesa->regs.s3d.texCtrl.ni.texEn = GL_FALSE; - imesa->regs.s3d.texCtrl.ni.dBias = 0x08; - imesa->regs.s3d.texCtrl.ni.texXprEn = GL_TRUE; - if (ctx->Texture.Unit[0]._ReallyEnabled == 0) - return; - - tObj = ctx->Texture.Unit[0]._Current; - if ((ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) - || tObj->Image[0][tObj->BaseLevel]->Border > 0) { - /* 3D texturing enabled, or texture border - fallback */ - FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE); - return; - } - - /* Do 2D texture setup */ - t = tObj->DriverData; - if (!t) { - t = savageAllocTexObj( tObj ); - if (!t) - return; - } - - imesa->CurrentTexObj[0] = &t->base; - t->base.bound |= 1; - - if (t->base.dirty_images[0] || t->dirtySubImages) { - savageSetTexImages(imesa, tObj); - savageUploadTexImages(imesa, t); - } - - driUpdateTextureLRU( &t->base ); - - format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - /* FIXME: copied from utah-glx, probably needs some tuning */ - switch (ctx->Texture.Unit[0].EnvMode) { - case GL_DECAL: - imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_DECALALPHA_S3D; - break; - case GL_REPLACE: - switch (format) { - case GL_ALPHA: /* FIXME */ - imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = 1; - break; - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = 4; - break; - case GL_RGB: - case GL_LUMINANCE: - imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_DECAL_S3D; - break; - case GL_INTENSITY: - imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_COPY_S3D; - } - break; - case GL_BLEND: /* hardware can't do GL_BLEND */ - FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE); - return; - case GL_MODULATE: - imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_MODULATEALPHA_S3D; - break; - default: - fprintf(stderr, "unknown tex env mode\n"); - /*exit(1);*/ - break; - } - - /* The Savage3D can't handle different wrapping modes in s and t. - * If they are not the same, fall back to software. */ - if (t->setup.sWrapMode != t->setup.tWrapMode) { - FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE); - return; - } - imesa->regs.s3d.texCtrl.ni.uWrapEn = 0; - imesa->regs.s3d.texCtrl.ni.vWrapEn = 0; - imesa->regs.s3d.texCtrl.ni.wrapMode = - (t->setup.sWrapMode == GL_REPEAT) ? TAM_Wrap : TAM_Clamp; - - switch (t->setup.minFilter) { - case GL_NEAREST: - imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Point; - imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_TRUE; - break; - - case GL_LINEAR: - imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Bilin; - imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_TRUE; - break; - - case GL_NEAREST_MIPMAP_NEAREST: - imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Point; - imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_FALSE; - break; - - case GL_LINEAR_MIPMAP_NEAREST: - imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Bilin; - imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_FALSE; - break; - - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Trilin; - imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_FALSE; - break; - } - - /* There is no way to specify a maximum mipmap level. We may have to - disable mipmapping completely. */ - /* - if (t->max_level < t->image[0].image->WidthLog2 || - t->max_level < t->image[0].image->HeightLog2) { - texCtrl.ni.mipmapEnable = GL_TRUE; - if (texCtrl.ni.filterMode == TFM_Trilin) - texCtrl.ni.filterMode = TFM_Bilin; - texCtrl.ni.filterMode = TFM_Point; - } - */ - - if((ctx->Texture.Unit[0].LodBias !=0.0F) || - (imesa->regs.s3d.texCtrl.ni.dBias != 0)) - { - int bias = (int)(ctx->Texture.Unit[0].LodBias * 16.0); - if (bias < -256) - bias = -256; - else if (bias > 255) - bias = 255; - imesa->regs.s3d.texCtrl.ni.dBias = bias & 0x1ff; - } - - image = tObj->Image[0][tObj->BaseLevel]; - imesa->regs.s3d.texCtrl.ni.texEn = GL_TRUE; - imesa->regs.s3d.texDescr.ni.texWidth = image->WidthLog2; - imesa->regs.s3d.texDescr.ni.texHeight = image->HeightLog2; - assert (t->hwFormat <= 7); - imesa->regs.s3d.texDescr.ni.texFmt = t->hwFormat; - - imesa->regs.s3d.texAddr.ui = (uint32_t) t->setup.physAddr | 2; - if(t->base.heap->heapId == SAVAGE_AGP_HEAP) - imesa->regs.s3d.texAddr.ui |= 0x1; -} - - -static void savageTimestampTextures( savageContextPtr imesa ) -{ - /* Timestamp current texture objects for texture heap aging. - * Only useful with long-lived 32-bit event tags available - * with Savage DRM 2.3.x or later. */ - if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) && - imesa->savageScreen->driScrnPriv->drm_version.minor >= 3) { - unsigned int e; - FLUSH_BATCH(imesa); - e = savageEmitEvent(imesa, SAVAGE_WAIT_3D); - if (imesa->CurrentTexObj[0]) - imesa->CurrentTexObj[0]->timestamp = e; - if (imesa->CurrentTexObj[1]) - imesa->CurrentTexObj[1]->timestamp = e; - } -} - - -static void savageUpdateTextureState_s4( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - - /* When a texture is about to change or be disabled, timestamp the - * old texture(s). We'll have to wait for this time stamp before - * uploading anything to the same texture heap. - */ - if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled && - ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) || - (imesa->CurrentTexObj[1] && ctx->Texture.Unit[1]._ReallyEnabled && - ctx->Texture.Unit[1]._Current->DriverData != imesa->CurrentTexObj[1]) || - (imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled) || - (imesa->CurrentTexObj[1] && !ctx->Texture.Unit[1]._ReallyEnabled)) - savageTimestampTextures(imesa); - - if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1; - if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound &= ~2; - imesa->CurrentTexObj[0] = 0; - imesa->CurrentTexObj[1] = 0; - savageUpdateTex0State_s4( ctx ); - savageUpdateTex1State_s4( ctx ); - imesa->dirty |= (SAVAGE_UPLOAD_TEX0 | - SAVAGE_UPLOAD_TEX1); -} -static void savageUpdateTextureState_s3d( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - - /* When a texture is about to change or be disabled, timestamp the - * old texture(s). We'll have to wait for this time stamp before - * uploading anything to the same texture heap. - */ - if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled && - ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) || - (imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled)) - savageTimestampTextures(imesa); - - if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1; - imesa->CurrentTexObj[0] = 0; - savageUpdateTexState_s3d( ctx ); - imesa->dirty |= (SAVAGE_UPLOAD_TEX0); -} -void savageUpdateTextureState( struct gl_context *ctx) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_FALSE); - FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_FALSE); - if (imesa->savageScreen->chipset >= S3_SAVAGE4) - savageUpdateTextureState_s4 (ctx); - else - savageUpdateTextureState_s3d (ctx); -} - - - -/***************************************** - * DRIVER functions - *****************************************/ - -static void savageTexEnv( struct gl_context *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - - if (pname == GL_TEXTURE_ENV_MODE) { - - imesa->new_state |= SAVAGE_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; - GLuint r, g, b, a; - 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]); - - imesa->texEnvColor = ((a << 24) | (r << 16) | - (g << 8) | (b << 0)); - - - } -} - -/* Update the heap's time stamp, so the new image is not uploaded - * while the old one is still in use. If the texture that is going to - * be changed is currently bound, we need to timestamp the texture - * first. */ -static void savageTexImageChanged (savageTexObjPtr t) { - if (t->base.heap) { - if (t->base.bound) - savageTimestampTextures( - (savageContextPtr)t->base.heap->driverContext); - if (t->base.timestamp > t->base.heap->timestamp) - t->base.heap->timestamp = t->base.timestamp; - } -} - -static void savageTexImage1D( struct gl_context *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 ) -{ - savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData; - if (t) { - savageTexImageChanged (t); - } else { - t = savageAllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - return; - } - } - _mesa_store_teximage1d( ctx, target, level, internalFormat, - width, border, format, type, - pixels, packing, texObj, texImage ); - t->base.dirty_images[0] |= (1 << level); - SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void savageTexSubImage1D( struct gl_context *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 ) -{ - savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData; - assert( t ); /* this _should_ be true */ - if (t) { - savageTexImageChanged (t); - savageMarkDirtyTiles(t, level, texImage->Width2, 1, - xoffset, 0, width, 1); - } else { - t = savageAllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); - return; - } - t->base.dirty_images[0] |= (1 << level); - } - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, packing, texObj, - texImage); - t->dirtySubImages |= (1 << level); - SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void savageTexImage2D( struct gl_context *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 ) -{ - savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData; - if (t) { - savageTexImageChanged (t); - } else { - t = savageAllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - _mesa_store_teximage2d( ctx, target, level, internalFormat, - width, height, border, format, type, - pixels, packing, texObj, texImage ); - t->base.dirty_images[0] |= (1 << level); - SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void savageTexSubImage2D( struct gl_context *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 ) -{ - savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData; - assert( t ); /* this _should_ be true */ - if (t) { - savageTexImageChanged (t); - savageMarkDirtyTiles(t, level, texImage->Width2, texImage->Height2, - xoffset, yoffset, width, height); - } else { - t = savageAllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - return; - } - t->base.dirty_images[0] |= (1 << level); - } - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); - t->dirtySubImages |= (1 << level); - SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void -savageCompressedTexImage2D( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData; - if (t) { - savageTexImageChanged (t); - } else { - t = savageAllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } - _mesa_store_compressed_teximage2d( ctx, target, level, internalFormat, - width, height, border, imageSize, - data, texObj, texImage ); - t->base.dirty_images[0] |= (1 << level); - SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void -savageCompressedTexSubImage2D( struct gl_context *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData; - assert( t ); /* this _should_ be true */ - if (t) { - savageTexImageChanged (t); - savageMarkDirtyTiles(t, level, texImage->Width2, texImage->Height2, - xoffset, yoffset, width, height); - } else { - t = savageAllocTexObj(texObj); - if (!t) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - return; - } - t->base.dirty_images[0] |= (1 << level); - } - _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, - width, height, format, imageSize, - data, texObj, texImage); - t->dirtySubImages |= (1 << level); - SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void savageTexParameter( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - savageTexObjPtr t = (savageTexObjPtr) tObj->DriverData; - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - - if (!t || (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D)) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - savageSetTexFilter(t,tObj->Sampler.MinFilter,tObj->Sampler.MagFilter); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - savageSetTexWrapping(t,tObj->Sampler.WrapS,tObj->Sampler.WrapT); - break; - - case GL_TEXTURE_BORDER_COLOR: - savageSetTexBorderColor(t,tObj->Sampler.BorderColor.f); - break; - - default: - return; - } - - imesa->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void savageBindTexture( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - - assert( (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) || - (tObj->DriverData != NULL) ); - - imesa->new_state |= SAVAGE_NEW_TEXTURE; -} - -static void savageDeleteTexture( struct gl_context *ctx, struct gl_texture_object *tObj ) -{ - driTextureObject *t = (driTextureObject *)tObj->DriverData; - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - - if (t) { - if (t->bound) - savageTimestampTextures(imesa); - - driDestroyTextureObject(t); - } - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); -} - - -static struct gl_texture_object * -savageNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - savageAllocTexObj( obj ); - - return obj; -} - -void savageDDInitTextureFuncs( struct dd_function_table *functions ) -{ - functions->TexEnv = savageTexEnv; - functions->ChooseTextureFormat = savageChooseTextureFormat; - functions->TexImage1D = savageTexImage1D; - functions->TexSubImage1D = savageTexSubImage1D; - functions->TexImage2D = savageTexImage2D; - functions->TexSubImage2D = savageTexSubImage2D; - functions->CompressedTexImage2D = savageCompressedTexImage2D; - functions->CompressedTexSubImage2D = savageCompressedTexSubImage2D; - functions->BindTexture = savageBindTexture; - functions->NewTextureObject = savageNewTextureObject; - functions->DeleteTexture = savageDeleteTexture; - functions->IsTextureResident = driIsTextureResident; - functions->TexParameter = savageTexParameter; - - /* Texel fetching with our custom texture formats works just like - * the standard argb formats. */ -#if 0 - _savage_texformat_a1114444.FetchTexel1D = _mesa_texformat_argb4444.FetchTexel1D; - _savage_texformat_a1114444.FetchTexel2D = _mesa_texformat_argb4444.FetchTexel2D; - _savage_texformat_a1114444.FetchTexel3D = _mesa_texformat_argb4444.FetchTexel3D; - _savage_texformat_a1114444.FetchTexel1Df= _mesa_texformat_argb4444.FetchTexel1Df; - _savage_texformat_a1114444.FetchTexel2Df= _mesa_texformat_argb4444.FetchTexel2Df; - _savage_texformat_a1114444.FetchTexel3Df= _mesa_texformat_argb4444.FetchTexel3Df; - - _savage_texformat_a1118888.FetchTexel1D = _mesa_texformat_argb8888.FetchTexel1D; - _savage_texformat_a1118888.FetchTexel2D = _mesa_texformat_argb8888.FetchTexel2D; - _savage_texformat_a1118888.FetchTexel3D = _mesa_texformat_argb8888.FetchTexel3D; - _savage_texformat_a1118888.FetchTexel1Df= _mesa_texformat_argb8888.FetchTexel1Df; - _savage_texformat_a1118888.FetchTexel2Df= _mesa_texformat_argb8888.FetchTexel2Df; - _savage_texformat_a1118888.FetchTexel3Df= _mesa_texformat_argb8888.FetchTexel3Df; -#endif -} diff --git a/src/mesa/drivers/dri/savage/savagetex.h b/src/mesa/drivers/dri/savage/savagetex.h deleted file mode 100644 index 6108c1aade9..00000000000 --- a/src/mesa/drivers/dri/savage/savagetex.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SAVAGETEX_INC -#define SAVAGETEX_INC - -#include "main/mtypes.h" - -#include "savagecontext.h" -#include "texmem.h" - -#define SAVAGE_TEX_MAXLEVELS 12 - -/** \brief Texture tiling information */ -typedef struct savage_tileinfo_t { - GLuint width, height; /**< tile width and height */ - GLuint wInSub, hInSub; /**< tile width and height in subtiles */ - GLuint subWidth, subHeight; /**< subtile width and height */ - GLuint tinyOffset[2]; /**< internal offsets size 1 and 2 images */ -} savageTileInfo, *savageTileInfoPtr; - -typedef struct { - GLuint offset; - GLuint nTiles; - GLuint *dirtyTiles; /* bit vector of dirty tiles (still unused) */ -} savageTexImage; - -typedef struct { - driTextureObject base; - - GLubyte *bufAddr; - - GLuint age; - savageTexImage image[SAVAGE_TEX_MAXLEVELS]; - GLuint dirtySubImages; - - struct { - GLuint sWrapMode, tWrapMode; - GLuint minFilter, magFilter; - GLuint physAddr; - } setup; - - GLuint hwFormat; - GLuint texelBytes; - const savageTileInfo *tileInfo; -} savageTexObj, *savageTexObjPtr; - -#define SAVAGE_NO_PALETTE 0x0 -#define SAVAGE_USE_PALETTE 0x1 -#define SAVAGE_UPDATE_PALETTE 0x2 -#define SAVAGE_FALLBACK_PALETTE 0x4 -#define __HWEnvCombineSingleUnitScale(imesa, flag0, flag1, TexBlendCtrl) -#define __HWParseTexEnvCombine(imesa, flag0, TexCtrl, TexBlendCtrl) - - -void savageUpdateTextureState( struct gl_context *ctx ); -void savageDDInitTextureFuncs( struct dd_function_table *functions ); - -void savageDestroyTexObj( savageContextPtr imesa, savageTexObjPtr t ); - -#endif diff --git a/src/mesa/drivers/dri/savage/savagetris.c b/src/mesa/drivers/dri/savage/savagetris.c deleted file mode 100644 index 79a951147f9..00000000000 --- a/src/mesa/drivers/dri/savage/savagetris.c +++ /dev/null @@ -1,1306 +0,0 @@ -/* -*- c-basic-offset: 3 -*- */ -/************************************************************************** - -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 <[email protected]> - * Felix Kuehling <[email protected]> - * - */ - -#include <stdio.h> -#include <math.h> - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/macros.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 "savagetris.h" -#include "savagestate.h" -#include "savagetex.h" -#include "savageioctl.h" - -static void savageRasterPrimitive( struct gl_context *ctx, GLuint prim ); -static void savageRenderPrimitive( struct gl_context *ctx, GLenum prim ); - - -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 -}; - - -/*********************************************************************** - * Emit primitives * - ***********************************************************************/ - -#if defined (USE_X86_ASM) -#define EMIT_VERT( j, vb, vertex_size, start, v ) \ -do { int __tmp; \ - vb += start; \ - __asm__ __volatile__( "rep ; movsl" \ - : "=%c" (j), "=D" (vb), "=S" (__tmp) \ - : "0" (vertex_size-start), \ - "D" ((long)vb), \ - "S" ((long)&(v)->ui[start])); \ -} while (0) -#else -#define EMIT_VERT( j, vb, vertex_size, start, v ) \ -do { \ - for ( j = start ; j < vertex_size ; j++ ) \ - vb[j] = (v)->ui[j]; \ - vb += vertex_size; \ -} while (0) -#endif - -static void INLINE savage_draw_triangle (savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1, - savageVertexPtr v2) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 3*vertsize); - GLuint j; - - EMIT_VERT (j, vb, vertsize, 0, v0); - EMIT_VERT (j, vb, vertsize, 0, v1); - EMIT_VERT (j, vb, vertsize, 0, v2); -} - -static void INLINE savage_draw_quad (savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1, - savageVertexPtr v2, - savageVertexPtr v3) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - GLuint j; - - EMIT_VERT (j, vb, vertsize, 0, v0); - EMIT_VERT (j, vb, vertsize, 0, v1); - EMIT_VERT (j, vb, vertsize, 0, v3); - EMIT_VERT (j, vb, vertsize, 0, v1); - EMIT_VERT (j, vb, vertsize, 0, v2); - EMIT_VERT (j, vb, vertsize, 0, v3); -} - -static INLINE void savage_draw_point (savageContextPtr imesa, - savageVertexPtr tmp) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - const GLfloat x = tmp->v.x; - const GLfloat y = tmp->v.y; - const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, - imesa->glCtx->Const.MinPointSize, - imesa->glCtx->Const.MaxPointSize); - GLuint j; - - *(float *)&vb[0] = x - sz; - *(float *)&vb[1] = y - sz; - EMIT_VERT (j, vb, vertsize, 2, tmp); - - *(float *)&vb[0] = x + sz; - *(float *)&vb[1] = y - sz; - EMIT_VERT (j, vb, vertsize, 2, tmp); - - *(float *)&vb[0] = x + sz; - *(float *)&vb[1] = y + sz; - EMIT_VERT (j, vb, vertsize, 2, tmp); - - *(float *)&vb[0] = x + sz; - *(float *)&vb[1] = y + sz; - EMIT_VERT (j, vb, vertsize, 2, tmp); - - *(float *)&vb[0] = x - sz; - *(float *)&vb[1] = y + sz; - EMIT_VERT (j, vb, vertsize, 2, tmp); - - *(float *)&vb[0] = x - sz; - *(float *)&vb[1] = y - sz; - EMIT_VERT (j, vb, vertsize, 2, tmp); -} - -static INLINE void savage_draw_line (savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1 ) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - const GLfloat width = CLAMP(imesa->glCtx->Line.Width, - imesa->glCtx->Const.MinLineWidth, - imesa->glCtx->Const.MaxLineWidth); - GLfloat dx, dy, ix, iy; - GLuint j; - - 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; - EMIT_VERT (j, vb, vertsize, 2, v0); - - *(float *)&vb[0] = v1->v.x + ix; - *(float *)&vb[1] = v1->v.y + iy; - EMIT_VERT (j, vb, vertsize, 2, v1); - - *(float *)&vb[0] = v0->v.x + ix; - *(float *)&vb[1] = v0->v.y + iy; - EMIT_VERT (j, vb, vertsize, 2, v0); - - *(float *)&vb[0] = v0->v.x - ix; - *(float *)&vb[1] = v0->v.y - iy; - EMIT_VERT (j, vb, vertsize, 2, v0); - - *(float *)&vb[0] = v1->v.x - ix; - *(float *)&vb[1] = v1->v.y - iy; - EMIT_VERT (j, vb, vertsize, 2, v1); - - *(float *)&vb[0] = v1->v.x + ix; - *(float *)&vb[1] = v1->v.y + iy; - EMIT_VERT (j, vb, vertsize, 2, v1); -} - -/* Fallback drawing functions for the ptex hack. Code duplication - * (especially lines and points) isn't beautiful, but I didn't feel - * like inventing yet another template. :-/ - */ -#define PTEX_VERTEX( j, tmp, vertex_size, start, v) \ -do { \ - GLfloat rhw = 1.0 / v->f[vertex_size]; \ - for ( j = start ; j < vertex_size ; j++ ) \ - tmp.f[j] = v->f[j]; \ - tmp.f[3] *= v->f[vertex_size]; \ - tmp.f[vertex_size-2] *= rhw; \ - tmp.f[vertex_size-1] *= rhw; \ -} while (0) - -static void INLINE savage_ptex_tri (savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1, - savageVertexPtr v2) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 3*vertsize); - savageVertex tmp; - GLuint j; - - PTEX_VERTEX (j, tmp, vertsize, 0, v0); EMIT_VERT (j, vb, vertsize, 0, &tmp); - PTEX_VERTEX (j, tmp, vertsize, 0, v1); EMIT_VERT (j, vb, vertsize, 0, &tmp); - PTEX_VERTEX (j, tmp, vertsize, 0, v2); EMIT_VERT (j, vb, vertsize, 0, &tmp); -} - -static INLINE void savage_ptex_line (savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1 ) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - const GLfloat width = CLAMP(imesa->glCtx->Line.Width, - imesa->glCtx->Const.MinLineWidth, - imesa->glCtx->Const.MaxLineWidth); - GLfloat dx, dy, ix, iy; - savageVertex tmp0, tmp1; - GLuint j; - - PTEX_VERTEX (j, tmp0, vertsize, 2, v0); - PTEX_VERTEX (j, tmp1, vertsize, 2, v1); - - 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; - EMIT_VERT (j, vb, vertsize, 2, &tmp0); - - *(float *)&vb[0] = v1->v.x + ix; - *(float *)&vb[1] = v1->v.y + iy; - EMIT_VERT (j, vb, vertsize, 2, &tmp1); - - *(float *)&vb[0] = v0->v.x + ix; - *(float *)&vb[1] = v0->v.y + iy; - EMIT_VERT (j, vb, vertsize, 2, &tmp0); - - *(float *)&vb[0] = v0->v.x - ix; - *(float *)&vb[1] = v0->v.y - iy; - EMIT_VERT (j, vb, vertsize, 2, &tmp0); - - *(float *)&vb[0] = v1->v.x - ix; - *(float *)&vb[1] = v1->v.y - iy; - EMIT_VERT (j, vb, vertsize, 2, &tmp1); - - *(float *)&vb[0] = v1->v.x + ix; - *(float *)&vb[1] = v1->v.y + iy; - EMIT_VERT (j, vb, vertsize, 2, &tmp1); -} - -static INLINE void savage_ptex_point (savageContextPtr imesa, - savageVertexPtr v0) { - GLuint vertsize = imesa->HwVertexSize; - uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - const GLfloat x = v0->v.x; - const GLfloat y = v0->v.y; - const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, - imesa->glCtx->Const.MinPointSize, - imesa->glCtx->Const.MaxPointSize); - savageVertex tmp; - GLuint j; - - PTEX_VERTEX (j, tmp, vertsize, 2, v0); - - *(float *)&vb[0] = x - sz; - *(float *)&vb[1] = y - sz; - EMIT_VERT (j, vb, vertsize, 2, &tmp); - - *(float *)&vb[0] = x + sz; - *(float *)&vb[1] = y - sz; - EMIT_VERT (j, vb, vertsize, 2, &tmp); - - *(float *)&vb[0] = x + sz; - *(float *)&vb[1] = y + sz; - EMIT_VERT (j, vb, vertsize, 2, &tmp); - - *(float *)&vb[0] = x + sz; - *(float *)&vb[1] = y + sz; - EMIT_VERT (j, vb, vertsize, 2, &tmp); - - *(float *)&vb[0] = x - sz; - *(float *)&vb[1] = y + sz; - EMIT_VERT (j, vb, vertsize, 2, &tmp); - - *(float *)&vb[0] = x - sz; - *(float *)&vb[1] = y - sz; - EMIT_VERT (j, vb, vertsize, 2, &tmp); -} - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( a, b, c ) \ -do { \ - if (DO_FALLBACK) \ - imesa->draw_tri( imesa, a, b, c ); \ - else \ - savage_draw_triangle( imesa, a, b, c ); \ -} while (0) - -#define QUAD( a, b, c, d ) \ -do { \ - if (DO_FALLBACK) { \ - imesa->draw_tri( imesa, a, b, d ); \ - imesa->draw_tri( imesa, b, c, d ); \ - } else \ - savage_draw_quad( imesa, a, b, c, d ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - imesa->draw_line( imesa, v0, v1 ); \ - else \ - savage_draw_line( imesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - imesa->draw_point( imesa, v0 ); \ - else \ - savage_draw_point( imesa, v0 ); \ -} while (0) - - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define SAVAGE_OFFSET_BIT 0x1 -#define SAVAGE_TWOSIDE_BIT 0x2 -#define SAVAGE_UNFILLED_BIT 0x4 -#define SAVAGE_FALLBACK_BIT 0x8 -#define SAVAGE_MAX_TRIFUNC 0x10 - - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[SAVAGE_MAX_TRIFUNC]; - - -#define DO_FALLBACK (IND & SAVAGE_FALLBACK_BIT) -#define DO_OFFSET (IND & SAVAGE_OFFSET_BIT) -#define DO_UNFILLED (IND & SAVAGE_UNFILLED_BIT) -#define DO_TWOSIDE (IND & SAVAGE_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_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX savageVertex -#define TAB rast_tab - -#define DEPTH_SCALE imesa->depth_scale -#define REVERSE_DEPTH 1 -#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_size * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - savage_color_t *color = (savage_color_t *)&((v)->ub4[coloroffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ -} while (0) -#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 ) \ -do { \ - if (specoffset) { \ - savage_color_t *spec = (savage_color_t *)&((v)->ub4[specoffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ - } \ -} while (0) -#define VERT_COPY_SPEC( v0, v1 ) \ - if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset]) -#define VERT_SAVE_SPEC( idx ) \ - if (specoffset) spec[idx] = v[idx]->ui[specoffset] -#define VERT_RESTORE_SPEC( idx ) \ - if (specoffset) v[idx]->ui[specoffset] = spec[idx] - -#define LOCAL_VARS(n) \ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \ - GLuint color[n] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - GLuint coloroffset = \ - ((imesa->skip & SAVAGE_SKIP_W) ? 3 : 4); \ - GLboolean specoffset = \ - ((imesa->skip & SAVAGE_SKIP_C1) ? 0 : coloroffset+1); \ - (void) color; (void) spec; (void) coloroffset; (void) specoffset; - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (imesa->raster_primitive != reduced_prim[x]) \ - savageRasterPrimitive( ctx, x ) -#define RENDER_PRIMITIVE imesa->render_primitive -#define IND SAVAGE_FALLBACK_BIT -#define TAG(x) x -#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 (SAVAGE_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_OFFSET_BIT|SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT|SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_UNFILLED_BIT|SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT|SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_UNFILLED_BIT|SAVAGE_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT| \ - SAVAGE_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_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(); -} - - - -/*********************************************************************** - * 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 -savage_fallback_tri( savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1, - savageVertexPtr v2 ) -{ - struct gl_context *ctx = imesa->glCtx; - SWvertex v[3]; - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - _swsetup_Translate( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - - -static void -savage_fallback_line( savageContextPtr imesa, - savageVertexPtr v0, - savageVertexPtr v1 ) -{ - struct gl_context *ctx = imesa->glCtx; - SWvertex v[2]; - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -static void -savage_fallback_point( savageContextPtr imesa, - savageVertexPtr v0 ) -{ - struct gl_context *ctx = imesa->glCtx; - SWvertex v[1]; - FLUSH_BATCH(imesa); - WAIT_IDLE_EMPTY(imesa); - _swsetup_Translate( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} - - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define VERT(x) (savageVertexPtr)(savageVerts + (x * vertsize * sizeof(int))) -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - savage_draw_point( imesa, VERT(start) ) -#define RENDER_LINE( v0, v1 ) \ - savage_draw_line( imesa, VERT(v0), VERT(v1) ) -#define RENDER_TRI( v0, v1, v2 ) \ - savage_draw_triangle( imesa, VERT(v0), VERT(v1), VERT(v2) ) -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - savage_draw_quad( imesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) -#define INIT(x) do { \ - if (0) fprintf(stderr, "%s\n", __FUNCTION__); \ - savageRenderPrimitive( ctx, x ); \ - /*SAVAGE_CONTEXT(ctx)->render_primitive = x;*/ \ -} while (0) -#undef LOCAL_VARS -#define LOCAL_VARS \ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \ - const GLuint vertsize = imesa->vertex_size; \ - const char *savageVerts = (char *)imesa->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) savage_##x##_verts -#include "tnl/t_vb_rendertmp.h" -#undef ELT -#undef TAG -#define TAG(x) savage_##x##_elts -#define ELT(x) elt[x] -#include "tnl/t_vb_rendertmp.h" - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void savageRenderClippedPoly( struct gl_context *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 savageRenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} -/* -static void savageFastRenderClippedPoly( struct gl_context *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 _SAVAGE_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_POINT_SMOOTH | \ - _DD_NEW_TRI_STIPPLE | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET) \ - -/* original driver didn't have DD_POINT_SMOOTH. really needed? */ -#define POINT_FALLBACK (DD_POINT_SMOOTH) -#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH) -#define TRI_FALLBACK (DD_TRI_STIPPLE|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 savageChooseRenderState(struct gl_context *ctx) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - /* Hook in fallback functions for the ptex hack. Do this first, so - * that a real fallback will overwrite them with the respective - * savage_fallback_... function. - */ - if (imesa->ptexHack) { - /* Do textures make sense with points? */ - imesa->draw_point = savage_ptex_point; - imesa->draw_line = savage_ptex_line; - imesa->draw_tri = savage_ptex_tri; - index |= SAVAGE_FALLBACK_BIT; - } else { - imesa->draw_point = savage_draw_point; - imesa->draw_line = savage_draw_line; - imesa->draw_tri = savage_draw_triangle; - } - - if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= SAVAGE_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= SAVAGE_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= SAVAGE_UNFILLED_BIT; - } - - /* Hook in fallbacks for specific primitives. - */ - if (flags & ANY_FALLBACK_FLAGS) { - if (flags & POINT_FALLBACK) imesa->draw_point = savage_fallback_point; - if (flags & LINE_FALLBACK) imesa->draw_line = savage_fallback_line; - if (flags & TRI_FALLBACK) imesa->draw_tri = savage_fallback_tri; - index |= SAVAGE_FALLBACK_BIT; - if (SAVAGE_DEBUG & DEBUG_FALLBACKS) { - fprintf (stderr, "Per-primitive fallback, TriangleCaps=0x%x\n", - ctx->_TriangleCaps); - } - } - } - - if (index != imesa->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 = savage_render_tab_verts; - tnl->Driver.Render.PrimTabElts = savage_render_tab_elts; - tnl->Driver.Render.ClippedLine = rast_tab[index].line; - tnl->Driver.Render.ClippedPolygon = savageRenderClippedPoly/*r128FastRenderClippedPoly*/; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = savageRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = savageRenderClippedPoly; - } - - imesa->RenderIndex = index; - } -} - -/**********************************************************************/ -/* Validate state at pipeline start */ -/**********************************************************************/ - -static void savageRunPipeline( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - - if (imesa->no_rast) - FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_TRUE); - - if (imesa->new_state) - savageDDUpdateHwState( ctx ); - - if (!imesa->Fallback) { - if (imesa->new_gl_state & _SAVAGE_NEW_RENDER_STATE) - savageChooseRenderState( ctx ); - - /* choose the correct primitive type for tnl rendering */ - if (imesa->savageScreen->chipset < S3_SAVAGE4 && - (ctx->_TriangleCaps & DD_FLATSHADE)) { - if (imesa->HwPrim != SAVAGE_PRIM_TRILIST_201) - savageFlushVertices(imesa); - imesa->HwPrim = SAVAGE_PRIM_TRILIST_201; - } else { - if (imesa->HwPrim != SAVAGE_PRIM_TRILIST) - savageFlushVertices(imesa); - imesa->HwPrim = SAVAGE_PRIM_TRILIST; - } - - imesa->new_gl_state = 0; - } - - _tnl_run_pipeline( ctx ); - - if (imesa->no_rast) - FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_FALSE); -} - -/**********************************************************************/ -/* 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. - */ - -static void savageRasterPrimitive( struct gl_context *ctx, GLuint prim ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); - - /* Update culling */ - if (imesa->raster_primitive != prim) { - imesa->raster_primitive = prim; - imesa->new_state |= SAVAGE_NEW_CULL; - savageDDUpdateHwState (ctx); - } - -#if 0 - if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple) - { - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - mmesa->setup.dwgctl &= ~(0xf<<20); - if (mmesa->raster_primitive == GL_TRIANGLES) - mmesa->setup.dwgctl |= mmesa->poly_stipple; - } -#endif -} - -static void savageRenderPrimitive( struct gl_context *ctx, GLenum prim ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLuint rprim = reduced_prim[prim]; - - imesa->render_primitive = prim; - - if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - - if (imesa->raster_primitive != rprim) { - savageRasterPrimitive( ctx, rprim ); - } -} - -/* Check if projective texture coordinates are used and if we can fake - * them. Fallback to swrast we can't. Returns GL_TRUE if projective - * texture coordinates must be faked, GL_FALSE otherwise. - */ -static GLboolean savageCheckPTexHack( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) { - if (!RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_ATTRIB_TEX1, _TNL_LAST_TEX )) - return GL_TRUE; /* apply ptex hack */ - else - FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE); - } - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4) - FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE); - - return GL_FALSE; /* don't apply ptex hack */ -} - - -#define DO_EMIT_ATTR( ATTR, STYLE ) \ -do { \ - imesa->vertex_attrs[imesa->vertex_attr_count].attrib = (ATTR); \ - imesa->vertex_attrs[imesa->vertex_attr_count].format = (STYLE); \ - imesa->vertex_attr_count++; \ -} while (0) - -#define NEED_ATTR( INDEX, SKIP ) \ -do { \ - setupIndex |= (INDEX); \ - skip &= ~(SKIP); \ -} while (0) - -#define EMIT_ATTR( ATTR, STYLE, INDEX, SKIP ) \ -do { \ - NEED_ATTR( INDEX, SKIP ); \ - DO_EMIT_ATTR( ATTR, STYLE ); \ -} while (0) - -#define EMIT_PAD( N ) \ -do { \ - imesa->vertex_attrs[imesa->vertex_attr_count].attrib = 0; \ - imesa->vertex_attrs[imesa->vertex_attr_count].format = EMIT_PAD; \ - imesa->vertex_attrs[imesa->vertex_attr_count].offset = (N); \ - imesa->vertex_attr_count++; \ -} while (0) - -#define SAVAGE_EMIT_XYZ 0x0001 -#define SAVAGE_EMIT_W 0x0002 -#define SAVAGE_EMIT_C0 0x0004 -#define SAVAGE_EMIT_C1 0x0008 -#define SAVAGE_EMIT_FOG 0x0010 -#define SAVAGE_EMIT_S0 0x0020 -#define SAVAGE_EMIT_T0 0x0040 -#define SAVAGE_EMIT_Q0 0x0080 -#define SAVAGE_EMIT_ST0 0x0060 -#define SAVAGE_EMIT_STQ0 0x00e0 -#define SAVAGE_EMIT_S1 0x0100 -#define SAVAGE_EMIT_T1 0x0200 -#define SAVAGE_EMIT_ST1 0x0300 - - -static INLINE GLuint savageChooseVertexFormat_s3d( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - GLuint setupIndex = SAVAGE_EMIT_XYZ; - GLubyte skip; - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - imesa->vertex_attr_count = 0; - - skip = SAVAGE_SKIP_ALL_S3D; - skip &= ~SAVAGE_SKIP_Z; /* all mesa vertices have a z coordinate */ - - /* EMIT_ATTR's must be in order as they tell t_vertex.c how to - * build up a hardware vertex. - */ - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX ) || !(ctx->_TriangleCaps & DD_FLATSHADE)) - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, SAVAGE_EMIT_W, SAVAGE_SKIP_W ); - else { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 ); - EMIT_PAD( 4 ); - skip &= ~SAVAGE_SKIP_W; - } - - /* t_context.c always includes a diffuse color */ - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, SAVAGE_EMIT_C0, SAVAGE_SKIP_C0 ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_EMIT_C1, SAVAGE_SKIP_C1 ); - else - EMIT_PAD( 3 ); - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_EMIT_FOG, SAVAGE_SKIP_C1 ); - else - EMIT_PAD( 1 ); - skip &= ~SAVAGE_SKIP_C1; - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) { - if (imesa->ptexHack) - EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0); - else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) - assert (0); /* should be caught by savageCheckPTexHack */ - else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size >= 2) - /* The chromium menu emits some 3D tex coords even though no - * 3D texture is enabled. Ignore the 3rd coordinate. */ - EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 ); - else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 1) { - EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 ); - EMIT_PAD( 4 ); - } else - EMIT_PAD( 8 ); - } else - EMIT_PAD( 8 ); - skip &= ~SAVAGE_SKIP_ST0; - - assert (skip == 0); - imesa->skip = skip; - return setupIndex; -} - - -static INLINE GLuint savageChooseVertexFormat_s4( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - GLuint setupIndex = SAVAGE_EMIT_XYZ; - GLubyte skip; - GLuint size, mask; - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - skip = SAVAGE_SKIP_ALL_S4; - skip &= ~SAVAGE_SKIP_Z; /* all mesa vertices have a z coordinate */ - - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX ) || !(ctx->_TriangleCaps & DD_FLATSHADE)) - NEED_ATTR( SAVAGE_EMIT_W, SAVAGE_SKIP_W ); - - /* t_context.c always includes a diffuse color */ - NEED_ATTR( SAVAGE_EMIT_C0, SAVAGE_SKIP_C0 ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) - NEED_ATTR( SAVAGE_EMIT_C1, SAVAGE_SKIP_C1 ); - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) - NEED_ATTR( SAVAGE_EMIT_FOG, SAVAGE_SKIP_C1 ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) { - if (imesa->ptexHack) - NEED_ATTR( SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0); - else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) - assert (0); /* should be caught by savageCheckPTexHack */ - else if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size >= 2) - /* The chromium menu emits some 3D tex coords even though no - * 3D texture is enabled. Ignore the 3rd coordinate. */ - NEED_ATTR( SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 ); - else - NEED_ATTR( SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 ); - } - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 )) { - if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4) - /* projective textures are not supported by the hardware */ - assert (0); /* should be caught by savageCheckPTexHack */ - else if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size >= 2) - NEED_ATTR( SAVAGE_EMIT_ST1, SAVAGE_SKIP_ST1 ); - else - NEED_ATTR( SAVAGE_EMIT_S1, SAVAGE_SKIP_S1 ); - } - - /* if nothing changed we can skip the rest */ - if (setupIndex == imesa->SetupIndex && imesa->vertex_size != 0) - return setupIndex; - - if (imesa->enable_vdma) { - mask = SAVAGE_SKIP_W; - size = 10 - (skip & 1) - (skip >> 1 & 1) - - (skip >> 2 & 1) - (skip >> 3 & 1) - (skip >> 4 & 1) - - (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1); - - while (size < 8) { - if (skip & mask) { - skip &= ~mask; - size++; - } - mask <<= 1; - } - } - - imesa->vertex_attr_count = 0; - - if (skip & SAVAGE_SKIP_W) - DO_EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT ); - else if (setupIndex & SAVAGE_EMIT_W) - DO_EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT ); - else { - DO_EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT ); - EMIT_PAD( 4 ); - } - - DO_EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA ); - - if (!(skip & SAVAGE_SKIP_C1)) { - if (!(setupIndex & (SAVAGE_EMIT_C1|SAVAGE_EMIT_FOG))) - EMIT_PAD( 4 ); - else { - if (setupIndex & SAVAGE_EMIT_C1) - DO_EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR ); - else - EMIT_PAD( 3 ); - if (setupIndex & SAVAGE_EMIT_FOG) - DO_EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); - else - EMIT_PAD( 1 ); - } - } - - if ((skip & SAVAGE_SKIP_ST0) != SAVAGE_SKIP_ST0) { - if ((setupIndex & SAVAGE_EMIT_STQ0) == SAVAGE_EMIT_STQ0) - DO_EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW ); - else if ((setupIndex & SAVAGE_EMIT_ST0) == SAVAGE_EMIT_ST0) - DO_EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F ); - else if ((setupIndex & SAVAGE_EMIT_ST0) == SAVAGE_EMIT_S0) { - DO_EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F ); - if (!(skip & SAVAGE_SKIP_T0)) EMIT_PAD( 4 ); - } else { - if (!(skip & SAVAGE_SKIP_S0)) EMIT_PAD( 4 ); - if (!(skip & SAVAGE_SKIP_T0)) EMIT_PAD( 4 ); - } - } - - if ((skip & SAVAGE_SKIP_ST1) != SAVAGE_SKIP_ST1) { - if ((setupIndex & SAVAGE_EMIT_ST1) == SAVAGE_EMIT_ST1) - DO_EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F ); - else if ((setupIndex & SAVAGE_EMIT_ST1) == SAVAGE_EMIT_S1) { - DO_EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_1F ); - if (!(skip & SAVAGE_SKIP_T1)) EMIT_PAD( 4 ); - } else { - if (!(skip & SAVAGE_SKIP_S1)) EMIT_PAD( 4 ); - if (!(skip & SAVAGE_SKIP_T1)) EMIT_PAD( 4 ); - } - } - - imesa->skip = skip; - return setupIndex; -} - - -static void savageRenderStart( struct gl_context *ctx ) -{ - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint setupIndex = SAVAGE_EMIT_XYZ; - GLboolean ptexHack; - - /* Check if we need to apply the ptex hack. Choose a new render - * state if necessary. (Note: this can't be done in - * savageRunPipeline, since the number of vertex coordinates can - * change in the pipeline. texmat or texgen or both?) */ - ptexHack = savageCheckPTexHack( ctx ); - if (ptexHack != imesa->ptexHack) { - imesa->ptexHack = ptexHack; - savageChooseRenderState (ctx); - } - /* Handle fallback cases identified in savageCheckPTexHack. */ - if (SAVAGE_CONTEXT(ctx)->Fallback) { - tnl->Driver.Render.Start(ctx); - return; - } - - /* Important: - */ - VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; - - if (imesa->savageScreen->chipset < S3_SAVAGE4) { - setupIndex = savageChooseVertexFormat_s3d(ctx); - } else { - setupIndex = savageChooseVertexFormat_s4(ctx); - } - - /* Need to change the vertex emit code if the SetupIndex changed or - * is set for the first time (indicated by vertex_size == 0). */ - if (setupIndex != imesa->SetupIndex || imesa->vertex_size == 0) { - GLuint hwVertexSize; - imesa->vertex_size = - _tnl_install_attrs( ctx, - imesa->vertex_attrs, - imesa->vertex_attr_count, - imesa->hw_viewport, 0 ); - imesa->vertex_size >>= 2; - imesa->SetupIndex = setupIndex; - - hwVertexSize = imesa->vertex_size; - if (setupIndex & SAVAGE_EMIT_Q0) { - /* The vertex setup code emits homogenous texture - * coordinates. They are converted to normal 2D coords by - * savage_ptex_tri/line/point. Now we have two different - * vertex sizes. Functions that emit vertices to the hardware - * need to use HwVertexSize, anything that manipulates the - * vertices generated by t_vertex uses vertex_size. */ - hwVertexSize--; - assert (imesa->ptexHack); - } else - assert (!imesa->ptexHack); - - if (hwVertexSize != imesa->HwVertexSize) { - /* Changing the vertex size: flush vertex and command buffer and - * discard the DMA buffer, if we were using one. */ - savageFlushVertices(imesa); - savageFlushCmdBuf(imesa, GL_TRUE); - if (hwVertexSize == 8 && imesa->enable_vdma) { - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf (stderr, "Using DMA, skip=0x%02x\n", imesa->skip); - /* we can use vertex dma */ - imesa->vtxBuf = &imesa->dmaVtxBuf; - } else { - if (SAVAGE_DEBUG & DEBUG_DMA) - fprintf (stderr, "Not using DMA, skip=0x%02x\n", imesa->skip); - imesa->vtxBuf = &imesa->clientVtxBuf; - } - imesa->HwVertexSize = hwVertexSize; - } - } -} - -static void savageRenderFinish( struct gl_context *ctx ) -{ - /* Flush the last primitive now, before any state is changed. */ - savageFlushVertices(SAVAGE_CONTEXT(ctx)); - - if (SAVAGE_CONTEXT(ctx)->RenderIndex & SAVAGE_FALLBACK_BIT) - _swrast_flush( ctx ); -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - -static const char * const fallbackStrings[] = { - "Texture mode", - "Draw buffer", - "Read buffer", - "Color mask", - "Specular", - "LogicOp", - "glEnable(GL_STENCIL) without hw stencil buffer", - "glRenderMode(selection or feedback)", - "glBlendEquation", - "Hardware rasterization disabled", - "Projective texture", -}; - -void savageFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - savageContextPtr imesa = SAVAGE_CONTEXT(ctx); - GLuint oldfallback = imesa->Fallback; - GLuint index; - for (index = 0; (1 << index) < bit; ++index); - - if (mode) { - imesa->Fallback |= bit; - if (oldfallback == 0) { - /* the first fallback */ - _swsetup_Wakeup( ctx ); - imesa->RenderIndex = ~0; - } - if (!(oldfallback & bit) && (SAVAGE_DEBUG & DEBUG_FALLBACKS)) - fprintf (stderr, "Savage begin fallback: 0x%x %s\n", - bit, fallbackStrings[index]); - } - else { - imesa->Fallback &= ~bit; - if (oldfallback == bit) { - /* the last fallback */ - _swrast_flush( ctx ); - tnl->Driver.Render.Start = savageRenderStart; - tnl->Driver.Render.PrimitiveNotify = savageRenderPrimitive; - tnl->Driver.Render.Finish = savageRenderFinish; - - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_invalidate_vertex_state( ctx, ~0 ); - _tnl_invalidate_vertices( ctx, ~0 ); - _tnl_install_attrs( ctx, - imesa->vertex_attrs, - imesa->vertex_attr_count, - imesa->hw_viewport, 0 ); - - imesa->new_gl_state |= _SAVAGE_NEW_RENDER_STATE; - } - if ((oldfallback & bit) && (SAVAGE_DEBUG & DEBUG_FALLBACKS)) - fprintf (stderr, "Savage end fallback: 0x%x %s\n", - bit, fallbackStrings[index]); - } -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - -void savageInitTriFuncs( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - } - - tnl->Driver.RunPipeline = savageRunPipeline; - tnl->Driver.Render.Start = savageRenderStart; - tnl->Driver.Render.Finish = savageRenderFinish; - tnl->Driver.Render.PrimitiveNotify = savageRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) ); - - SAVAGE_CONTEXT(ctx)->verts = (char *)tnl->clipspace.vertex_buf; -} diff --git a/src/mesa/drivers/dri/savage/savagetris.h b/src/mesa/drivers/dri/savage/savagetris.h deleted file mode 100644 index 5dcae78f760..00000000000 --- a/src/mesa/drivers/dri/savage/savagetris.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** - -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 <[email protected]> - * Felix Kuehling <[email protected]> - * - */ - -#ifndef __R128_TRIS_H__ -#define __R128_TRIS_H__ - -#include "main/mtypes.h" - -extern void savageInitTriFuncs( struct gl_context *ctx ); - - -extern void savageFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( ctx, bit, mode ) savageFallback( ctx, bit, mode ) - - -#endif /* __R128_TRIS_H__ */ diff --git a/src/mesa/drivers/dri/savage/server/savage_dri.h b/src/mesa/drivers/dri/savage/server/savage_dri.h deleted file mode 100644 index 214d9851aff..00000000000 --- a/src/mesa/drivers/dri/savage/server/savage_dri.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef __SAVAGE_DRI_H__ -#define __SAVAGE_DRI_H__ - -#include "drm.h" - -typedef struct { - int chipset; - int width; - int height; - int mem; - int cpp; - int zpp; - - int agpMode; /* 0 for PCI cards */ - - unsigned int sarea_priv_offset; - - unsigned int bufferSize; /* size of DMA buffers */ - - unsigned int frontbufferSize; - unsigned int frontOffset; - - unsigned int backbufferSize; - unsigned int backOffset; - - unsigned int depthbufferSize; - unsigned int depthOffset; - - unsigned int textureOffset; - unsigned int textureSize; - int logTextureGranularity; - - /* Linear aperture */ - drm_handle_t apertureHandle; - unsigned int apertureSize; - unsigned int aperturePitch; /* in byte */ - - /* Status page (probably not needed, but no harm, read-only) */ - drm_handle_t statusHandle; - unsigned int statusSize; - - /* AGP textures */ - drm_handle_t agpTextureHandle; - unsigned int agpTextureSize; - int logAgpTextureGranularity; - - /* Not sure about this one */ - drm_handle_t xvmcSurfHandle; /* ? */ -} SAVAGEDRIRec, *SAVAGEDRIPtr; - -#endif diff --git a/src/mesa/drivers/dri/sis/Makefile b/src/mesa/drivers/dri/sis/Makefile deleted file mode 100644 index 0e0bf0d4eac..00000000000 --- a/src/mesa/drivers/dri/sis/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# src/mesa/drivers/dri/sis/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = sis_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - sis6326_state.c \ - sis6326_clear.c \ - sis_alloc.c \ - sis_clear.c \ - sis_context.c \ - sis_dd.c \ - sis_fog.c \ - sis_lock.c \ - sis_screen.c \ - sis_span.c \ - sis_state.c \ - sis_stencil.c \ - sis_tex.c \ - sis_texstate.c \ - sis_tris.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/sis/server/sis_common.h b/src/mesa/drivers/dri/sis/server/sis_common.h deleted file mode 100644 index bd9bab846fc..00000000000 --- a/src/mesa/drivers/dri/sis/server/sis_common.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Common header definitions for SiS 2D/3D/DRM suite - * - * Copyright (C) 2003 Eric Anholt - * - * 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 the copyright holder not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The copyright holder makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDER 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. - * - * Author: - * Eric Anholt <[email protected]> - * - */ - -#ifndef _SIS_COMMON_H_ -#define _SIS_COMMON_H_ - -#define DRM_SIS_FB_ALLOC 0x04 -#define DRM_SIS_FB_FREE 0x05 -#define DRM_SIS_FLIP 0x08 -#define DRM_SIS_FLIP_INIT 0x09 -#define DRM_SIS_FLIP_FINAL 0x10 -#define DRM_SIS_AGP_INIT 0x13 -#define DRM_SIS_AGP_ALLOC 0x14 -#define DRM_SIS_AGP_FREE 0x15 -#define DRM_SIS_FB_INIT 0x16 - -typedef struct { - int context; - unsigned long offset; - unsigned long size; - void *free; -} drm_sis_mem_t; - -typedef struct { - unsigned long offset, size; -} drm_sis_agp_t; - -typedef struct { - unsigned long offset, size; -} drm_sis_fb_t; - -typedef struct { - unsigned int left, right; -} drm_sis_flip_t; - -#endif /* _SIS_COMMON_H_ */ - diff --git a/src/mesa/drivers/dri/sis/server/sis_dri.h b/src/mesa/drivers/dri/sis/server/sis_dri.h deleted file mode 100644 index 7d8f507115d..00000000000 --- a/src/mesa/drivers/dri/sis/server/sis_dri.h +++ /dev/null @@ -1,75 +0,0 @@ - -/* modified from tdfx_dri.h */ - -#ifndef _SIS_DRI_ -#define _SIS_DRI_ - -#include "xf86drm.h" -#include "drm.h" - -#define SIS_MAX_DRAWABLES 256 -#define SISIOMAPSIZE (64*1024) - -typedef struct { - int CtxOwner; - int QueueLength; - unsigned int AGPCmdBufNext; - unsigned int FrameCount; -#ifdef SIS315DRI - /* For 315 series */ - unsigned long sharedWPoffset; -#endif -#if 0 - unsigned char *AGPCmdBufBase; - unsigned long AGPCmdBufAddr; - unsigned long AGPCmdBufOffset; - unsigned int AGPCmdBufSize; - unsigned long AGPCmdBufNext; -#endif -} SISSAREAPriv, *SISSAREAPrivPtr; - -#define AGPVtxBufNext AGPCmdBufNext - -#define SIS_FRONT 0 -#define SIS_BACK 1 -#define SIS_DEPTH 2 - -typedef struct { - drm_handle_t handle; - drmSize size; -} sisRegion, *sisRegionPtr; - -typedef struct { - sisRegion regs, agp; - int deviceID; - int width; - int height; - int mem; /* unused in Mesa 3 DRI */ - int bytesPerPixel; - int priv1; /* unused in Mesa 3 DRI */ - int priv2; /* unused in Mesa 3 DRI */ - int fbOffset; /* unused in Mesa 3 DRI */ - int backOffset; /* unused in Mesa 3 DRI */ - int depthOffset; /* unused in Mesa 3 DRI */ - int textureOffset; /* unused in Mesa 3 DRI */ - int textureSize; /* unused in Mesa 3 DRI */ - unsigned int AGPCmdBufOffset; - unsigned int AGPCmdBufSize; - int irqEnabled; /* unused in Mesa 3 DRI */ - unsigned int scrnX, scrnY; /* unused in Mesa 3 DRI */ -} SISDRIRec, *SISDRIPtr; - -#define AGPVtxBufOffset AGPCmdBufOffset -#define AGPVtxBufSize AGPCmdBufSize - -typedef struct { - /* Nothing here yet */ - int dummy; -} SISConfigPrivRec, *SISConfigPrivPtr; - -typedef struct { - /* Nothing here yet */ - int dummy; -} SISDRIContextRec, *SISDRIContextPtr; - -#endif diff --git a/src/mesa/drivers/dri/sis/sis6326_clear.c b/src/mesa/drivers/dri/sis/sis6326_clear.c deleted file mode 100644 index fba6c7f2d7d..00000000000 --- a/src/mesa/drivers/dri/sis/sis6326_clear.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2005 Eric Anholt - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION 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: - * Eric Anholt <[email protected]> - * - */ - -#include "sis_context.h" -#include "sis_state.h" -#include "sis_lock.h" -#include "sis_reg.h" - -#include "swrast/swrast.h" -#include "main/macros.h" - -static void sis_clear_front_buffer(struct gl_context *ctx, GLenum mask, GLint x, - GLint y, GLint width, GLint height); -static void sis_clear_back_buffer(struct gl_context *ctx, GLenum mask, GLint x, - GLint y, GLint width, GLint height); -static void sis_clear_z_buffer(struct gl_context * ctx, GLbitfield mask, GLint x, - GLint y, GLint width, GLint height ); - -static void -set_color_pattern( sisContextPtr smesa, GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha ) -{ - /* XXX only RGB565 and ARGB8888 */ - switch (smesa->colorFormat) - { - case DST_FORMAT_ARGB_8888: - smesa->clearColorPattern = (alpha << 24) + - (red << 16) + (green << 8) + (blue); - break; - case DST_FORMAT_RGB_565: - smesa->clearColorPattern = ((red >> 3) << 11) + - ((green >> 2) << 5) + (blue >> 3); - smesa->clearColorPattern |= smesa->clearColorPattern << 16; - break; - default: - sis_fatal_error("Bad dst color format\n"); - } -} - -void -sis6326UpdateZPattern(sisContextPtr smesa, GLclampd z) -{ - CLAMPED_FLOAT_TO_USHORT(smesa->clearZStencilPattern, z * 65535.0); -} - -void -sis6326DDClear(struct gl_context *ctx, GLbitfield mask) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLint x1, y1, width1, height1; - - /* get region after locking: */ - x1 = ctx->DrawBuffer->_Xmin; - y1 = ctx->DrawBuffer->_Ymin; - width1 = ctx->DrawBuffer->_Xmax - x1; - height1 = ctx->DrawBuffer->_Ymax - y1; - y1 = Y_FLIP(y1 + height1 - 1); - - /* XXX: Scissoring */ - - fprintf(stderr, "Clear\n"); - - /* Mask out any non-existent buffers */ - if (smesa->depth.offset == 0 || !ctx->Depth.Mask) - mask &= ~BUFFER_BIT_DEPTH; - - LOCK_HARDWARE(); - - if (mask & BUFFER_BIT_FRONT_LEFT) { - sis_clear_front_buffer(ctx, mask, x1, y1, width1, height1); - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if (mask & BUFFER_BIT_BACK_LEFT) { - sis_clear_back_buffer(ctx, mask, x1, y1, width1, height1); - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if (mask & BUFFER_BIT_DEPTH) { - sis_clear_z_buffer(ctx, mask, x1, y1, width1, height1); - mask &= ~BUFFER_BIT_DEPTH; - } - - UNLOCK_HARDWARE(); - - if (mask != 0) - _swrast_Clear(ctx, mask); -} - - -void -sis6326DDClearColor(struct gl_context *ctx, const GLfloat color[4]) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLubyte c[4]; - - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - set_color_pattern( smesa, c[0], c[1], c[2], c[3] ); -} - -void -sis6326DDClearDepth(struct gl_context *ctx, GLclampd d) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - sis6326UpdateZPattern(smesa, d); -} - -static void -sis_clear_back_buffer(struct gl_context *ctx, GLenum mask, GLint x, GLint y, - GLint width, GLint height) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - /* XXX: The order of writing these registers seems to matter, while - * it actually shouldn't. - */ - mWait3DCmdQueue(6); - MMIO(REG_6326_BitBlt_DstSrcPitch, smesa->back.pitch << 16); - MMIO(REG_6326_BitBlt_fgColor, SiS_ROP_PATCOPY | - smesa->clearColorPattern); - MMIO(REG_6326_BitBlt_bgColor, SiS_ROP_PATCOPY | - smesa->clearColorPattern); - MMIO(REG_6326_BitBlt_DstAddr, smesa->back.offset + - (y+height) * smesa->back.pitch + - (x+width) * smesa->bytesPerPixel); - MMIO(REG_6326_BitBlt_HeightWidth, ((height-1) << 16) | - (width * smesa->bytesPerPixel)); - MMIO_WMB(); - MMIO(REG_6326_BitBlt_Cmd, BLT_PAT_BG); -} - -static void -sis_clear_front_buffer(struct gl_context *ctx, GLenum mask, GLint x, GLint y, - GLint width, GLint height) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - int count; - drm_clip_rect_t *pExtents = NULL; - - pExtents = smesa->driDrawable->pClipRects; - count = smesa->driDrawable->numClipRects; - - mWait3DCmdQueue(3); - MMIO(REG_6326_BitBlt_DstSrcPitch, smesa->front.pitch << 16); - MMIO(REG_6326_BitBlt_fgColor, SiS_ROP_PATCOPY | - smesa->clearColorPattern); - MMIO(REG_6326_BitBlt_bgColor, SiS_ROP_PATCOPY | - smesa->clearColorPattern); - - while (count--) { - GLint x1 = pExtents->x1 - smesa->driDrawable->x; - GLint y1 = pExtents->y1 - smesa->driDrawable->y; - GLint x2 = pExtents->x2 - smesa->driDrawable->x; - GLint y2 = pExtents->y2 - smesa->driDrawable->y; - - if (x > x1) - x1 = x; - if (y > y1) - y1 = y; - - if (x + width < x2) - x2 = x + width; - if (y + height < y2) - y2 = y + height; - width = x2 - x1; - height = y2 - y1; - - pExtents++; - - if (width <= 0 || height <= 0) - continue; - - mWait3DCmdQueue(3); - MMIO(REG_6326_BitBlt_DstAddr, smesa->front.offset + - (y2-1) * smesa->front.pitch + x2 * smesa->bytesPerPixel); - MMIO(REG_6326_BitBlt_HeightWidth, ((height-1) << 16) | - (width * smesa->bytesPerPixel)); - MMIO_WMB(); - MMIO(REG_6326_BitBlt_Cmd, BLT_PAT_BG); - } -} - -static void -sis_clear_z_buffer(struct gl_context * ctx, GLbitfield mask, GLint x, GLint y, - GLint width, GLint height) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - mWait3DCmdQueue(6); - MMIO(REG_6326_BitBlt_DstAddr, - smesa->depth.offset + y * smesa->depth.pitch + x * 2); - MMIO(REG_6326_BitBlt_DstSrcPitch, smesa->depth.pitch << 16); - MMIO(REG_6326_BitBlt_HeightWidth, ((height-1) << 16) | (width * 2)); - MMIO(REG_6326_BitBlt_fgColor, SiS_ROP_PATCOPY | smesa->clearZStencilPattern); - MMIO(REG_6326_BitBlt_bgColor, SiS_ROP_PATCOPY | smesa->clearZStencilPattern); - MMIO_WMB(); - MMIO(REG_6326_BitBlt_Cmd, BLT_PAT_BG | BLT_XINC | BLT_YINC); -} - diff --git a/src/mesa/drivers/dri/sis/sis6326_reg.h b/src/mesa/drivers/dri/sis/sis6326_reg.h deleted file mode 100644 index 8e645f0799c..00000000000 --- a/src/mesa/drivers/dri/sis/sis6326_reg.h +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright 2005 Eric Anholt - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION 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: - * Eric Anholt <[email protected]> - * - */ - -#ifndef _sis6326_reg_h_ -#define _sis6326_reg_h_ - -#define REG_6326_BitBlt_SrcAddr 0x8280 -#define REG_6326_BitBlt_DstAddr 0x8284 -#define REG_6326_BitBlt_DstSrcPitch 0x8288 -#define REG_6326_BitBlt_HeightWidth 0x828c -#define REG_6326_BitBlt_fgColor 0x8290 -#define REG_6326_BitBlt_bgColor 0x8294 -#define REG_6326_BitBlt_Mask30 0x8298 -#define REG_6326_BitBlt_Mask74 0x829c -#define REG_6326_BitBlt_ClipTopLeft 0x82a0 -#define REG_6326_BitBlt_ClitBottomRight 0x82a4 -#define REG_6326_BitBlt_Cmd 0x82a8 -#define REG_6326_BitBlt_Pat 0x82ac - -#define REG_6326_3D_TSFSa 0x8800 -#define REG_6326_3D_TSZa 0x8804 -#define REG_6326_3D_TSXa 0x8808 -#define REG_6326_3D_TSYa 0x880C -#define REG_6326_3D_TSARGBa 0x8810 -#define REG_6326_3D_TSUa 0x8814 -#define REG_6326_3D_TSVa 0x8818 -#define REG_6326_3D_TSWa 0x881C - -#define REG_6326_3D_TSFSb 0x8820 -#define REG_6326_3D_TSZb 0x8824 -#define REG_6326_3D_TSXb 0x8828 -#define REG_6326_3D_TSYb 0x882C -#define REG_6326_3D_TSARGBb 0x8830 -#define REG_6326_3D_TSUb 0x8834 -#define REG_6326_3D_TSVb 0x8838 -#define REG_6326_3D_TSWb 0x883C - -#define REG_6326_3D_TSFSc 0x8840 -#define REG_6326_3D_TSZc 0x8844 -#define REG_6326_3D_TSXc 0x8848 -#define REG_6326_3D_TSYc 0x884C -#define REG_6326_3D_TSARGBc 0x8850 -#define REG_6326_3D_TSUc 0x8854 -#define REG_6326_3D_TSVc 0x8858 -#define REG_6326_3D_TSWc 0x885C - -#define REG_6326_3D_TEnable 0x8A00 -#define REG_6326_3D_ZSet 0x8A04 -#define REG_6326_3D_ZAddress 0x8A08 - -#define REG_6326_3D_AlphaSet 0x8A0C -#define REG_6326_3D_AlphaAddress 0x8A10 -#define REG_6326_3D_DstSet 0x8A14 -#define REG_6326_3D_DstAddress 0x8A18 -#define REG_6326_3D_LinePattern 0x8A1C -#define REG_6326_3D_FogSet 0x8A20 - -#define REG_6326_3D_DstSrcBlendMode 0x8A28 - -#define REG_6326_3D_ClipTopBottom 0x8A30 -#define REG_6326_3D_ClipLeftRight 0x8A34 - -#define REG_6326_3D_TextureSet 0x8A38 -#define REG_6326_3D_TextureBlendSet 0x8A3C -/* Low transparency value is in TextureBlendSet */ -#define REG_6326_3D_TextureTransparencyColorHigh 0x8A40 - -#define REG_6326_3D_TextureAddress0 0x8A44 -#define REG_6326_3D_TextureAddress1 0x8A48 -#define REG_6326_3D_TextureAddress2 0x8A4C -#define REG_6326_3D_TextureAddress3 0x8A50 -#define REG_6326_3D_TextureAddress4 0x8A54 -#define REG_6326_3D_TextureAddress5 0x8A58 -#define REG_6326_3D_TextureAddress6 0x8A5C -#define REG_6326_3D_TextureAddress7 0x8A60 -#define REG_6326_3D_TextureAddress8 0x8A64 -#define REG_6326_3D_TextureAddress9 0x8A68 - -#define REG_6326_3D_TexturePitch01 0x8A6C -#define REG_6326_3D_TexturePitch23 0x8A70 -#define REG_6326_3D_TexturePitch45 0x8A74 -#define REG_6326_3D_TexturePitch67 0x8A78 -#define REG_6326_3D_TexturePitch89 0x8A7C - -#define REG_6326_3D_TextureWidthHeight 0x8A80 -#define REG_6326_3D_TextureBorderColor 0x8A90 - -#define REG_6326_3D_EndPrimitiveList 0x8Aff - -/* - * REG_6326_BitBlt_fgColor (0x8290-0x8293) - * REG_6326_BitBlt_bgColor (0x8294-0x8297) - */ -#define MASK_BltRop 0xff000000 -#define MASK_BltColor 0x00ffffff - -#define SiS_ROP_SRCCOPY 0xcc000000 -#define SiS_ROP_PATCOPY 0xf0000000 - -/* - * REG_6326_BitBlt_Cmd (0x82a8-0x82ab) - */ -#define MASK_QueueStatus 0x0000ffff -#define MASK_BltCmd0 0x00ff0000 -#define MASK_BltCmd1 0xff000000 - -#define BLT_SRC_BG 0x00000000 -#define BLT_SRC_FG 0x00010000 -#define BLT_SRC_VID 0x00020000 -#define BLT_SRC_CPU 0x00030000 -#define BLT_PAT_BG 0x00000000 -#define BLT_PAT_FG 0x00040000 -#define BLT_PAT_PAT 0x000b0000 -#define BLT_XINC 0x00100000 -#define BLT_YINC 0x00200000 -#define BLT_CLIP 0x00400000 -#define BLT_BUSY 0x04000000 - -/* - * REG_3D_PrimitiveSet -- Define Fire Primitive Mask (89F8h-89FBh) - */ -#define MASK_6326_DrawPrimitiveCommand 0x00000007 -#define MASK_6326_SetFirePosition 0x00000F00 -#define MASK_6326_ShadingMode 0x001c0000 -#define MASK_6326_Direction 0x0003f000 - -/* OP_3D_{POINT,LINE,TRIANGLE}_DRAW same as 300-series */ -/* OP_3D_DIRECTION*_ same as 300-series */ - -#define OP_6326_3D_FIRE_TFIRE 0x00000000 -#define OP_6326_3D_FIRE_TSARGBa 0x00000100 -#define OP_6326_3D_FIRE_TSWa 0x00000200 -#define OP_6326_3D_FIRE_TSARGBb 0x00000300 -#define OP_6326_3D_FIRE_TSWb 0x00000400 -#define OP_6326_3D_FIRE_TSARGBc 0x00000500 -#define OP_6326_3D_FIRE_TSWc 0x00000600 -#define OP_6326_3D_FIRE_TSVc 0x00000700 - -#define OP_6326_3D_ATOP 0x00000000 -#define OP_6326_3D_BTOP 0x00010000 -#define OP_6326_3D_CTOP 0x00020000 -#define OP_6326_3D_AMID 0x00000000 -#define OP_6326_3D_BMID 0x00004000 -#define OP_6326_3D_CMID 0x00008000 -#define OP_6326_3D_ABOT 0x00000000 -#define OP_6326_3D_BBOT 0x00001000 -#define OP_6326_3D_CBOT 0x00002000 - -#define OP_6326_3D_SHADE_FLAT_TOP 0x00040000 -#define OP_6326_3D_SHADE_FLAT_MID 0x00080000 -#define OP_6326_3D_SHADE_FLAT_BOT 0x000c0000 -#define OP_6326_3D_SHADE_FLAT_GOURAUD 0x00100000 - - -/* - * REG_6326_3D_EngineFire - */ -#define MASK_CmdQueueLen 0x0FFF0000 -#define ENG_3DIDLEQE 0x00000002 -#define ENG_3DIDLE 0x00000001 - -/* - * REG_6326_3D_TEnable -- Define Capility Enable Mask (8A00h-8A03h) - */ -#define S_ENABLE_Dither (1 << 0) -#define S_ENABLE_Transparency (1 << 1) -#define S_ENABLE_Blend (1 << 2) -#define S_ENABLE_Fog (1 << 3) -#define S_ENABLE_Specular (1 << 4) -#define S_ENABLE_LargeCache (1 << 5) -#define S_ENABLE_TextureCache (1 << 7) -#define S_ENABLE_TextureTransparency (1 << 8) -#define S_ENABLE_TexturePerspective (1 << 9) -#define S_ENABLE_Texture (1 << 10) -#define S_ENABLE_PrimSetup (1 << 11) -#define S_ENABLE_LinePattern (1 << 12) -#define S_ENABLE_StippleAlpha (1 << 13) /* requires S_ENABLE_Stipple */ -#define S_ENABLE_Stipple (1 << 14) -#define S_ENABLE_AlphaBuffer (1 << 16) -#define S_ENABLE_AlphaTest (1 << 17) -#define S_ENABLE_AlphaWrite (1 << 18) -#define S_ENABLE_ZTest (1 << 20) -#define S_ENABLE_ZWrite (1 << 21) - -/* - * REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh) - */ -#define MASK_6326_ZBufferPitch 0x00003FFF -#define MASK_6326_ZTestMode 0x00070000 -#define MASK_6326_ZBufferFormat 0x00100000 - -#define S_ZSET_FORMAT_8 0x00000000 -#define S_ZSET_FORMAT_16 0x00100000 - -#define S_ZSET_PASS_NEVER 0x00000000 -#define S_ZSET_PASS_LESS 0x00010000 -#define S_ZSET_PASS_EQUAL 0x00020000 -#define S_ZSET_PASS_LEQUAL 0x00030000 -#define S_ZSET_PASS_GREATER 0x00040000 -#define S_ZSET_PASS_NOTEQUAL 0x00050000 -#define S_ZSET_PASS_GEQUAL 0x00060000 -#define S_ZSET_PASS_ALWAYS 0x00070000 - -/* - * REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A0Ch-8A0Fh) - */ -#define MASK_AlphaBufferPitch 0x000003FF -#define MASK_AlphaRefValue 0x00FF0000 -#define MASK_AlphaTestMode 0x07000000 -#define MASK_AlphaBufferFormat 0x30000000 - -#define S_ASET_FORMAT_8 0x30000000 - -#define S_ASET_PASS_NEVER 0x00000000 -#define S_ASET_PASS_LESS 0x01000000 -#define S_ASET_PASS_EQUAL 0x02000000 -#define S_ASET_PASS_LEQUAL 0x03000000 -#define S_ASET_PASS_GREATER 0x04000000 -#define S_ASET_PASS_NOTEQUAL 0x05000000 -#define S_ASET_PASS_GEQUAL 0x06000000 -#define S_ASET_PASS_ALWAYS 0x07000000 - -/* - * REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A14h-8A17h) - */ -/* pitch, format, depth, rgborder, rop bits same as 300-series */ - -/* - * REG_6326_3D_FogSet -- Define Fog Mask (8A20h-8A23h) - */ -#define MASK_6326_FogColor 0x00FFFFFF -#define MASK_6326_FogMode 0x01000000 - -#define FOGMODE_6326_CONST 0x00000000 -#define FOGMODE_6326_LINEAR 0x01000000 - -/* - * REG_6326_3D_DstSrcBlendMode (0x8A28 - 0x8A2B) - */ -#define MASK_6326_SrcBlendMode 0xf0000000 -#define MASK_6326_DstBlendMode 0x0f000000 -#define MASK_6326_TransparencyColor 0x00ffffff - -#define S_DBLEND_ZERO 0x00000000 -#define S_DBLEND_ONE 0x10000000 -#define S_DBLEND_SRC_COLOR 0x20000000 -#define S_DBLEND_INV_SRC_COLOR 0x30000000 -#define S_DBLEND_SRC_ALPHA 0x40000000 -#define S_DBLEND_INV_SRC_ALPHA 0x50000000 -#define S_DBLEND_DST_ALPHA 0x60000000 -#define S_DBLEND_INV_DST_ALPHA 0x70000000 - -#define S_SBLEND_ZERO 0x00000000 -#define S_SBLEND_ONE 0x01000000 -#define S_SBLEND_SRC_ALPHA 0x04000000 -#define S_SBLEND_INV_SRC_ALPHA 0x05000000 -#define S_SBLEND_DST_ALPHA 0x06000000 -#define S_SBLEND_INV_DST_ALPHA 0x07000000 -#define S_SBLEND_DST_COLOR 0x08000000 -#define S_SBLEND_INV_DST_COLOR 0x09000000 -#define S_SBLEND_SRC_ALPHA_SAT 0x0A000000 -#define S_SBLEND_BOTH_SRC_ALPHA 0x0B000000 -#define S_SBLEND_BOTH_INV_SRC_ALPHA 0x0C000000 - -/* - * REG_6326_3D_TextureSet (0x8A38 - 0x8A3B) - */ -#define MASK_6326_TextureMinFilter 0x00000007 -#define MASK_6326_TextureMagFilter 0x00000008 -#define MASK_6326_ClearTexCache 0x00000010 -#define MASK_6326_TextureInSystem 0x00000020 -#define MASK_6326_TextureLevel 0x00000F00 -#define MASK_6326_TextureSignYUVFormat 0x00008000 -#define MASK_6326_TextureMappingMode 0x00FF0000 - -#define TEXEL_6326_BGR_ORDER 0x80000000 - -#define TEXEL_6326_INDEX1 0x00000000 -#define TEXEL_6326_INDEX2 0x01000000 -#define TEXEL_6326_INDEX4 0x02000000 - -#define TEXEL_6326_M4 0x10000000 -#define TEXEL_6326_AM44 0x16000000 - -#define TEXEL_6326_YUV422 0x20000000 /* YUYV */ -#define TEXEL_6326_YVU422 0x21000000 /* YVYU */ -#define TEXEL_6326_UVY422 0x22000000 /* UYVY */ -#define TEXEL_6326_VUY422 0x23000000 /* VYUY */ - -#define TEXEL_6326_L1 0x30000000 -#define TEXEL_6326_L2 0x31000000 -#define TEXEL_6326_L4 0x32000000 -#define TEXEL_6326_L8 0x33000000 - -#define TEXEL_6326_AL22 0x35000000 -#define TEXEL_6326_AL44 0x38000000 -#define TEXEL_6326_AL88 0x3c000000 - -#define TEXEL_6326_RGB_332_8 0x40000000 -#define TEXEL_6326_RGB_233_8 0x41000000 -#define TEXEL_6326_RGB_232_8 0x42000000 -#define TEXEL_6326_ARGB_1232_8 0x43000000 - -#define TEXEL_6326_RGB_555_16 0x50000000 -#define TEXEL_6326_RGB_565_16 0x51000000 -#define TEXEL_6326_ARGB_1555_16 0x52000000 -#define TEXEL_6326_ARGB_4444_16 0x53000000 -#define TEXEL_6326_ARGB_8332_16 0x54000000 -#define TEXEL_6326_ARGB_8233_16 0x55000000 -#define TEXEL_6326_ARGB_8232_16 0x56000000 - -#define TEXEL_6326_ARGB_8565_24 0x63000000 -#define TEXEL_6326_ARGB_8555_24 0x67000000 -#define TEXEL_6326_RGB_888_24 0x68000000 - -#define TEXEL_6326_ARGB_8888_32 0x73000000 -#define TEXEL_6326_ARGB_0888_32 0x74000000 - -#define TEX_MAP_WRAP_U 0x00010000 -#define TEX_MAP_WRAP_V 0x00020000 -#define TEX_MAP_MIRROR_U 0x00040000 -#define TEX_MAP_MIRROR_V 0x00080000 -#define TEX_MAP_CLAMP_U 0x00100000 -#define TEX_MAP_CLAMP_V 0x00200000 -#define TEX_MAP_USE_CTB_SMOOTH 0x00400000 -#define TEX_MAP_USE_CTB 0x00800000 - -#define TEX_FILTER_NEAREST 0x00000000 -#define TEX_FILTER_LINEAR 0x00000001 -#define TEX_FILTER_NEAREST_MIP_NEAREST 0x00000002 -#define TEX_FILTER_NEAREST_MIP_LINEAR 0x00000003 -#define TEX_FILTER_LINEAR_MIP_NEAREST 0x00000004 -#define TEX_FILTER_LINEAR_MIP_LINEAR 0x00000005 -#define TEX_FILTER_MAG_NEAREST 0x00000000 -#define TEX_FILTER_MAG_LINEAR 0x00000008 - -/* - * REG_6326_3D_TextureBlendSet (0x8A3C - 0x8A3F) - */ -#define MASK_TextureTransparencyLowB 0x000000ff -#define MASK_TextureTransparencyLowG 0x0000FF00 -#define MASK_TextureTransparencyLowR 0x00ff0000 -#define MASK_TextureBlend 0x0f000000 - -#define TB_C_CS (0 << 26) -#define TB_C_CF (1 << 26) -#define TB_C_CFCS (2 << 26) /* also 3 << 26 */ -#define TB_C_CFOMAS_ASCS (4 << 26) -#define TB_C_CSOMAF_AFCF (6 << 26) /* also 7 << 26 */ - -#define TB_A_AS (0 << 24) -#define TB_A_AF (1 << 24) -#define TB_A_AFAS (1 << 24) - -/* - * REG_6326_3D_TextureTransparencyColorHigh (0x8A40 - 0x8A43) - */ -#define MASK_TextureTransparencyHighB 0x000000FF -#define MASK_TextureTransparencyHighG 0x0000FF00 -#define MASK_TextureTransparencyHighR 0x00FF0000 - -/* - * REG_3D_TexturePitch01-89 (0x8A6C - 0x8A7F) - */ -#define MASK_TexturePitchOdd 0x000003FF -#define MASK_TexturePitchEven 0x03FF0000 -#define SHIFT_TexturePitchEven 16 - -/* - * REG_3D_TextureWidthHeightMix (0x8A80 - 0x8A83) - */ -#define MASK_TextureWidthLog2 0xf0000000 -#define MASK_TextureHeightLog2 0x0f000000 - -/* - * REG_3D_TextureBorderColor (0x8A90 - 0x8A93) - */ -#define MASK_TextureBorderColorB 0x000000FF -#define MASK_TextureBorderColorG 0x0000FF00 -#define MASK_TextureBorderColorR 0x00FF0000 -#define MASK_TextureBorderColorA 0xFF000000 - -#endif /* _sis6326_reg_h_ */ diff --git a/src/mesa/drivers/dri/sis/sis6326_state.c b/src/mesa/drivers/dri/sis/sis6326_state.c deleted file mode 100644 index 9ca58293b43..00000000000 --- a/src/mesa/drivers/dri/sis/sis6326_state.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Copyright 2005 Eric Anholt - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION 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: - * Eric Anholt <[email protected]> - * - */ - -#include "sis_context.h" -#include "sis_state.h" -#include "sis_tris.h" -#include "sis_lock.h" -#include "sis_tex.h" -#include "sis_reg.h" - -#include "main/context.h" -#include "main/colormac.h" -#include "main/state.h" -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "swrast_setup/swrast_setup.h" - - -/* ============================================================= - * Alpha blending - */ - -static void -sis6326DDAlphaFunc( struct gl_context *ctx, GLenum func, GLfloat ref ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLubyte refbyte; - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - CLAMPED_FLOAT_TO_UBYTE(refbyte, ref); - current->hwAlpha = refbyte << 16; - - /* Alpha Test function */ - switch (func) - { - case GL_NEVER: - current->hwAlpha |= S_ASET_PASS_NEVER; - break; - case GL_LESS: - current->hwAlpha |= S_ASET_PASS_LESS; - break; - case GL_EQUAL: - current->hwAlpha |= S_ASET_PASS_EQUAL; - break; - case GL_LEQUAL: - current->hwAlpha |= S_ASET_PASS_LEQUAL; - break; - case GL_GREATER: - current->hwAlpha |= S_ASET_PASS_GREATER; - break; - case GL_NOTEQUAL: - current->hwAlpha |= S_ASET_PASS_NOTEQUAL; - break; - case GL_GEQUAL: - current->hwAlpha |= S_ASET_PASS_GEQUAL; - break; - case GL_ALWAYS: - current->hwAlpha |= S_ASET_PASS_ALWAYS; - break; - } - - prev->hwAlpha = current->hwAlpha; - smesa->GlobalFlag |= GFLAG_ALPHASETTING; -} - -static void -sis6326DDBlendFuncSeparate( struct gl_context *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - current->hwDstSrcBlend = 0; - - switch (dfactorRGB) - { - case GL_ZERO: - current->hwDstSrcBlend |= S_DBLEND_ZERO; - break; - case GL_ONE: - current->hwDstSrcBlend |= S_DBLEND_ONE; - break; - case GL_SRC_COLOR: - current->hwDstSrcBlend |= S_DBLEND_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - current->hwDstSrcBlend |= S_DBLEND_INV_SRC_COLOR; - break; - case GL_SRC_ALPHA: - current->hwDstSrcBlend |= S_DBLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - current->hwDstSrcBlend |= S_DBLEND_INV_SRC_ALPHA; - break; - case GL_DST_ALPHA: - current->hwDstSrcBlend |= S_DBLEND_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - current->hwDstSrcBlend |= S_DBLEND_INV_DST_ALPHA; - break; - } - - switch (sfactorRGB) - { - case GL_ZERO: - current->hwDstSrcBlend |= S_SBLEND_ZERO; - break; - case GL_ONE: - current->hwDstSrcBlend |= S_SBLEND_ONE; - break; - case GL_SRC_ALPHA: - current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - current->hwDstSrcBlend |= S_SBLEND_INV_SRC_ALPHA; - break; - case GL_DST_ALPHA: - current->hwDstSrcBlend |= S_SBLEND_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - current->hwDstSrcBlend |= S_SBLEND_INV_DST_ALPHA; - break; - case GL_DST_COLOR: - current->hwDstSrcBlend |= S_SBLEND_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - current->hwDstSrcBlend |= S_SBLEND_INV_DST_COLOR; - break; - case GL_SRC_ALPHA_SATURATE: - current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA_SAT; - break; - } - - if (current->hwDstSrcBlend != prev->hwDstSrcBlend) { - prev->hwDstSrcBlend = current->hwDstSrcBlend; - smesa->GlobalFlag |= GFLAG_DSTBLEND; - } -} - -/* ============================================================= - * Depth testing - */ - -static void -sis6326DDDepthFunc( struct gl_context *ctx, GLenum func ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - current->hwZ &= ~MASK_6326_ZTestMode; - switch (func) - { - case GL_LESS: - current->hwZ |= S_ZSET_PASS_LESS; - break; - case GL_GEQUAL: - current->hwZ |= S_ZSET_PASS_GEQUAL; - break; - case GL_LEQUAL: - current->hwZ |= S_ZSET_PASS_LEQUAL; - break; - case GL_GREATER: - current->hwZ |= S_ZSET_PASS_GREATER; - break; - case GL_NOTEQUAL: - current->hwZ |= S_ZSET_PASS_NOTEQUAL; - break; - case GL_EQUAL: - current->hwZ |= S_ZSET_PASS_EQUAL; - break; - case GL_ALWAYS: - current->hwZ |= S_ZSET_PASS_ALWAYS; - break; - case GL_NEVER: - current->hwZ |= S_ZSET_PASS_NEVER; - break; - } - - if (current->hwZ != prev->hwZ) { - prev->hwZ = current->hwZ; - smesa->GlobalFlag |= GFLAG_ZSETTING; - } -} - -static void -sis6326DDDepthMask( struct gl_context *ctx, GLboolean flag ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &smesa->current; - - if (ctx->Depth.Test) - current->hwCapEnable |= S_ENABLE_ZWrite; - else - current->hwCapEnable &= ~S_ENABLE_ZWrite; -} - -/* ============================================================= - * Fog - */ - -static void -sis6326DDFogfv( struct gl_context *ctx, GLenum pname, const GLfloat *params ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &smesa->current; - __GLSiSHardware *prev = &smesa->prev; - - GLint fogColor; - - switch(pname) - { - case GL_FOG_COLOR: - fogColor = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16; - fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8; - fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] ); - current->hwFog = 0x01000000 | fogColor; - if (current->hwFog != prev->hwFog) { - prev->hwFog = current->hwFog; - smesa->GlobalFlag |= GFLAG_FOGSETTING; - } - break; - } -} - -/* ============================================================= - * Clipping - */ - -void -sis6326UpdateClipping(struct gl_context *ctx) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - GLint x1, y1, x2, y2; - - x1 = 0; - y1 = 0; - x2 = smesa->width - 1; - y2 = smesa->height - 1; - - if (ctx->Scissor.Enabled) { - if (ctx->Scissor.X > x1) - x1 = ctx->Scissor.X; - if (ctx->Scissor.Y > y1) - y1 = ctx->Scissor.Y; - if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2) - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2) - y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1; - } - - y1 = Y_FLIP(y1); - y2 = Y_FLIP(y2); - - /*current->clipTopBottom = (y2 << 13) | y1; - current->clipLeftRight = (x1 << 13) | x2;*/ /* XXX */ - current->clipTopBottom = (0 << 13) | smesa->height; - current->clipLeftRight = (0 << 13) | smesa->width; - - if ((current->clipTopBottom != prev->clipTopBottom) || - (current->clipLeftRight != prev->clipLeftRight)) { - prev->clipTopBottom = current->clipTopBottom; - prev->clipLeftRight = current->clipLeftRight; - smesa->GlobalFlag |= GFLAG_CLIPPING; - } -} - -static void -sis6326DDScissor( struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) -{ - if (ctx->Scissor.Enabled) - sis6326UpdateClipping( ctx ); -} - -/* ============================================================= - * Culling - */ - -static void -sis6326UpdateCull( struct gl_context *ctx ) -{ - /* XXX culling */ -} - - -static void -sis6326DDCullFace( struct gl_context *ctx, GLenum mode ) -{ - sis6326UpdateCull( ctx ); -} - -static void -sis6326DDFrontFace( struct gl_context *ctx, GLenum mode ) -{ - sis6326UpdateCull( ctx ); -} - -/* ============================================================= - * Masks - */ - -static void sis6326DDColorMask( struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - if (r && g && b && ((ctx->Visual.alphaBits == 0) || a)) { - FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 0); - } else { - FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 1); - } -} - -/* ============================================================= - * Rendering attributes - */ - -static void sis6326UpdateSpecular(struct gl_context *ctx) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &smesa->current; - - if (_mesa_need_secondary_color(ctx)) - current->hwCapEnable |= S_ENABLE_Specular; - else - current->hwCapEnable &= ~S_ENABLE_Specular; -} - -static void sis6326DDLightModelfv(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { - sis6326UpdateSpecular(ctx); - } -} -static void sis6326DDShadeModel( struct gl_context *ctx, GLenum mode ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */ - smesa->hw_primitive = -1; -} - -/* ============================================================= - * Window position - */ - -/* ============================================================= - * Viewport - */ - -static void sis6326CalcViewport( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = smesa->hw_viewport; - - /* See also sis_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] + smesa->driDrawable->h + SUBPIXEL_Y; - m[MAT_SZ] = v[MAT_SZ] * smesa->depth_scale; - m[MAT_TZ] = v[MAT_TZ] * smesa->depth_scale; -} - -static void sis6326DDViewport( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - sis6326CalcViewport( ctx ); -} - -static void sis6326DDDepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - sis6326CalcViewport( ctx ); -} - -/* ============================================================= - * Miscellaneous - */ - -static void -sis6326DDLogicOpCode( struct gl_context *ctx, GLenum opcode ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if (!ctx->Color.ColorLogicOpEnabled) - return; - - current->hwDstSet &= ~MASK_ROP2; - switch (opcode) - { - case GL_CLEAR: - current->hwDstSet |= LOP_CLEAR; - break; - case GL_SET: - current->hwDstSet |= LOP_SET; - break; - case GL_COPY: - current->hwDstSet |= LOP_COPY; - break; - case GL_COPY_INVERTED: - current->hwDstSet |= LOP_COPY_INVERTED; - break; - case GL_NOOP: - current->hwDstSet |= LOP_NOOP; - break; - case GL_INVERT: - current->hwDstSet |= LOP_INVERT; - break; - case GL_AND: - current->hwDstSet |= LOP_AND; - break; - case GL_NAND: - current->hwDstSet |= LOP_NAND; - break; - case GL_OR: - current->hwDstSet |= LOP_OR; - break; - case GL_NOR: - current->hwDstSet |= LOP_NOR; - break; - case GL_XOR: - current->hwDstSet |= LOP_XOR; - break; - case GL_EQUIV: - current->hwDstSet |= LOP_EQUIV; - break; - case GL_AND_REVERSE: - current->hwDstSet |= LOP_AND_REVERSE; - break; - case GL_AND_INVERTED: - current->hwDstSet |= LOP_AND_INVERTED; - break; - case GL_OR_REVERSE: - current->hwDstSet |= LOP_OR_REVERSE; - break; - case GL_OR_INVERTED: - current->hwDstSet |= LOP_OR_INVERTED; - break; - } - - if (current->hwDstSet != prev->hwDstSet) { - prev->hwDstSet = current->hwDstSet; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } -} - -void sis6326DDDrawBuffer( struct gl_context *ctx, GLenum mode ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if(getenv("SIS_DRAW_FRONT")) - ctx->DrawBuffer->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; - - if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) { - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - current->hwDstSet &= ~MASK_DstBufferPitch; - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - current->hwOffsetDest = smesa->front.offset; - current->hwDstSet |= smesa->front.pitch; - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - case BUFFER_BACK_LEFT: - current->hwOffsetDest = smesa->back.offset; - current->hwDstSet |= smesa->back.pitch; - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - default: - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - if (current->hwDstSet != prev->hwDstSet) { - prev->hwDstSet = current->hwDstSet; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } - - if (current->hwOffsetDest != prev->hwOffsetDest) { - prev->hwOffsetDest = current->hwOffsetDest; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } -} - -/* ============================================================= - * Polygon stipple - */ - -/* ============================================================= - * Render mode - */ - -/* ============================================================= - * State enable/disable - */ - -static void -sis6326DDEnable( struct gl_context *ctx, GLenum cap, GLboolean state ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *current = &smesa->current; - - switch (cap) - { - case GL_ALPHA_TEST: - if (state) - current->hwCapEnable |= S_ENABLE_AlphaTest; - else - current->hwCapEnable &= ~S_ENABLE_AlphaTest; - break; - case GL_BLEND: - /* TODO: */ - if (state) - /* if (state & !ctx->Color.ColorLogicOpEnabled) */ - current->hwCapEnable |= S_ENABLE_Blend; - else - current->hwCapEnable &= ~S_ENABLE_Blend; - break; - case GL_CULL_FACE: - /* XXX culling */ - break; - case GL_DEPTH_TEST: - if (state && smesa->depth.offset != 0) - current->hwCapEnable |= S_ENABLE_ZTest; - else - current->hwCapEnable &= ~S_ENABLE_ZTest; - sis6326DDDepthMask( ctx, ctx->Depth.Mask ); - break; - case GL_DITHER: - if (state) - current->hwCapEnable |= S_ENABLE_Dither; - else - current->hwCapEnable &= ~S_ENABLE_Dither; - break; - case GL_FOG: - if (state) - current->hwCapEnable |= S_ENABLE_Fog; - else - current->hwCapEnable &= ~S_ENABLE_Fog; - break; - case GL_COLOR_LOGIC_OP: - if (state) - sis6326DDLogicOpCode( ctx, ctx->Color.LogicOp ); - else - sis6326DDLogicOpCode( ctx, GL_COPY ); - break; - case GL_SCISSOR_TEST: - sis6326UpdateClipping( ctx ); - break; - case GL_STENCIL_TEST: - if (state) { - FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1); - } else { - FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0); - } - break; - case GL_LIGHTING: - case GL_COLOR_SUM_EXT: - sis6326UpdateSpecular(ctx); - break; - } -} - -/* ============================================================= - * State initialization, management - */ - -/* Called before beginning of rendering. */ -void -sis6326UpdateHWState( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if (smesa->NewGLState & _NEW_TEXTURE) - sisUpdateTextureState( ctx ); - - if (current->hwCapEnable ^ prev->hwCapEnable) { - prev->hwCapEnable = current->hwCapEnable; - smesa->GlobalFlag |= GFLAG_ENABLESETTING; - } - - if (smesa->GlobalFlag & GFLAG_RENDER_STATES) - sis_update_render_state( smesa ); - - if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES) - sis_update_texture_state( smesa ); -} - -static void -sis6326DDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - smesa->NewGLState |= new_state; -} - -/* Initialize the context's hardware state. - */ -void sis6326DDInitState( sisContextPtr smesa ) -{ - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - struct gl_context *ctx = smesa->glCtx; - - /* add Texture Perspective Enable */ - current->hwCapEnable = S_ENABLE_TextureCache | - S_ENABLE_TexturePerspective | S_ENABLE_Dither; - - /* Z test mode is LESS */ - current->hwZ = S_ZSET_PASS_LESS | S_ZSET_FORMAT_16; - if (ctx->Visual.depthBits > 0) - current->hwCapEnable |= S_ENABLE_ZWrite; - - /* Alpha test mode is ALWAYS, alpha ref value is 0 */ - current->hwAlpha = S_ASET_PASS_ALWAYS; - - /* ROP2 is COPYPEN */ - current->hwDstSet = LOP_COPY; - - /* LinePattern is 0, Repeat Factor is 0 */ - current->hwLinePattern = 0x00008000; - - /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */ - current->hwDstSrcBlend = S_SBLEND_ONE | S_DBLEND_ZERO; - - switch (smesa->bytesPerPixel) - { - case 2: - current->hwDstSet |= DST_FORMAT_RGB_565; - break; - case 4: - current->hwDstSet |= DST_FORMAT_ARGB_8888; - break; - } - - smesa->depth_scale = 1.0 / (GLfloat)0xffff; - - smesa->clearTexCache = GL_TRUE; - - smesa->clearColorPattern = 0; - - sis6326UpdateZPattern(smesa, 1.0); - sis6326UpdateCull(ctx); - - /* Set initial fog settings. Start and end are the same case. */ - sis6326DDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); - sis6326DDFogfv( ctx, GL_FOG_END, &ctx->Fog.End ); - sis6326DDFogfv( ctx, GL_FOG_MODE, NULL ); - - memcpy(prev, current, sizeof(__GLSiSHardware)); -} - -/* Initialize the driver's state functions. - */ -void sis6326DDInitStateFuncs( struct gl_context *ctx ) -{ - ctx->Driver.UpdateState = sis6326DDInvalidateState; - - ctx->Driver.Clear = sis6326DDClear; - ctx->Driver.ClearColor = sis6326DDClearColor; - ctx->Driver.ClearDepth = sis6326DDClearDepth; - - ctx->Driver.AlphaFunc = sis6326DDAlphaFunc; - ctx->Driver.BlendFuncSeparate = sis6326DDBlendFuncSeparate; - ctx->Driver.ColorMask = sis6326DDColorMask; - ctx->Driver.CullFace = sis6326DDCullFace; - ctx->Driver.DepthMask = sis6326DDDepthMask; - ctx->Driver.DepthFunc = sis6326DDDepthFunc; - ctx->Driver.DepthRange = sis6326DDDepthRange; - ctx->Driver.DrawBuffer = sis6326DDDrawBuffer; - ctx->Driver.Enable = sis6326DDEnable; - ctx->Driver.FrontFace = sis6326DDFrontFace; - ctx->Driver.Fogfv = sis6326DDFogfv; - ctx->Driver.LogicOpcode = sis6326DDLogicOpCode; - ctx->Driver.Scissor = sis6326DDScissor; - ctx->Driver.ShadeModel = sis6326DDShadeModel; - ctx->Driver.LightModelfv = sis6326DDLightModelfv; - ctx->Driver.Viewport = sis6326DDViewport; -} diff --git a/src/mesa/drivers/dri/sis/sis_alloc.c b/src/mesa/drivers/dri/sis/sis_alloc.c deleted file mode 100644 index ce34e44da22..00000000000 --- a/src/mesa/drivers/dri/sis/sis_alloc.c +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_context.h" -#include "sis_alloc.h" - -#include "sis_common.h" - -#include <unistd.h> - -#define Z_BUFFER_HW_ALIGNMENT 16 -#define Z_BUFFER_HW_PLUS (16 + 4) - -/* 3D engine uses 2, and bitblt uses 4 */ -#define DRAW_BUFFER_HW_ALIGNMENT 16 -#define DRAW_BUFFER_HW_PLUS (16 + 4) - -#define ALIGNMENT(value, align) (((value) + (align) - 1) / (align) * (align)) - -static int _total_video_memory_used = 0; -static int _total_video_memory_count = 0; - -void * -sisAllocFB( sisContextPtr smesa, GLuint size, void **handle ) -{ - drm_sis_mem_t fb; - - _total_video_memory_used += size; - - fb.context = smesa->hHWContext; - fb.size = size; - if (drmCommandWriteRead( smesa->driFd, DRM_SIS_FB_ALLOC, &fb, - sizeof(drm_sis_mem_t) ) || fb.offset == 0) - { - return NULL; - } - *handle = (void *)fb.free; - - if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sisAllocFB: size=%d, offset=%lu, pid=%d, count=%d\n", - size, fb.offset, (GLint)getpid(), - ++_total_video_memory_count); - } - - return (void *)(smesa->FbBase + fb.offset); -} - -void -sisFreeFB( sisContextPtr smesa, void *handle ) -{ - drm_sis_mem_t fb; - - if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sisFreeFB: free=%p, pid=%d, count=%d\n", - handle, (GLint)getpid(), --_total_video_memory_count); - } - - fb.context = smesa->hHWContext; - fb.free = handle; - drmCommandWrite( smesa->driFd, DRM_SIS_FB_FREE, &fb, sizeof(drm_sis_mem_t) ); -} - -void * -sisAllocAGP( sisContextPtr smesa, GLuint size, void **handle ) -{ - drm_sis_mem_t agp; - - if (smesa->AGPSize == 0) - return NULL; - - agp.context = smesa->hHWContext; - agp.size = size; - if (drmCommandWriteRead( smesa->driFd, DRM_SIS_AGP_ALLOC, &agp, - sizeof(drm_sis_mem_t) ) || agp.offset == 0) - { - return NULL; - } - *handle = (void *)agp.free; - - if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sisAllocAGP: size=%u, offset=%lu, pid=%d, count=%d\n", - size, agp.offset, (GLint)getpid(), - ++_total_video_memory_count); - } - - return (void *)(smesa->AGPBase + agp.offset); -} - -void -sisFreeAGP( sisContextPtr smesa, void *handle ) -{ - drm_sis_mem_t agp; - - if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sisFreeAGP: free=%p, pid=%d, count=%d\n", - handle, (GLint)getpid(), --_total_video_memory_count); - } - - agp.context = smesa->hHWContext; - agp.free = handle; - drmCommandWrite( smesa->driFd, DRM_SIS_AGP_FREE, &agp, - sizeof(drm_sis_mem_t) ); -} - -void -sisAllocZStencilBuffer( sisContextPtr smesa ) -{ - int cpp = ( smesa->glCtx->Visual.depthBits + - smesa->glCtx->Visual.stencilBits ) / 8; - char *addr; - - smesa->depth.bpp = cpp * 8; - smesa->depth.pitch = ALIGNMENT(smesa->driDrawable->w * cpp, 4); - smesa->depth.size = smesa->depth.pitch * smesa->driDrawable->h; - smesa->depth.size += Z_BUFFER_HW_PLUS; - - addr = sisAllocFB(smesa, smesa->depth.size, &smesa->depth.handle); - if (addr == NULL) - sis_fatal_error("Failure to allocate Z buffer.\n"); - addr = (char *)ALIGNMENT((unsigned long)addr, Z_BUFFER_HW_ALIGNMENT); - - smesa->depth.map = addr; - smesa->depth.offset = addr - (char *)smesa->FbBase; - - /* stencil buffer is same as depth buffer */ - smesa->stencil.size = smesa->depth.size; - smesa->stencil.offset = smesa->depth.offset; - smesa->stencil.handle = smesa->depth.handle; - smesa->stencil.pitch = smesa->depth.pitch; - smesa->stencil.bpp = smesa->depth.bpp; - smesa->stencil.map = smesa->depth.map; -} - -void -sisFreeZStencilBuffer( sisContextPtr smesa ) -{ - sisFreeFB(smesa, smesa->depth.handle); - smesa->depth.map = NULL; - smesa->depth.offset = 0; -} - -void -sisAllocBackbuffer( sisContextPtr smesa ) -{ - int cpp = smesa->bytesPerPixel; - char *addr; - - smesa->back.bpp = smesa->bytesPerPixel * 8; - smesa->back.pitch = ALIGNMENT(smesa->driDrawable->w * cpp, 4); - smesa->back.size = smesa->back.pitch * smesa->driDrawable->h; - smesa->back.size += DRAW_BUFFER_HW_PLUS; - - addr = sisAllocFB(smesa, smesa->back.size, &smesa->back.handle); - if (addr == NULL) - sis_fatal_error("Failure to allocate back buffer.\n"); - addr = (char *)ALIGNMENT((unsigned long)addr, DRAW_BUFFER_HW_ALIGNMENT); - - smesa->back.map = addr; - smesa->back.offset = addr - (char *)smesa->FbBase; -} - -void -sisFreeBackbuffer( sisContextPtr smesa ) -{ - sisFreeFB(smesa, smesa->back.handle); - smesa->back.map = NULL; - smesa->back.offset = 0; -} diff --git a/src/mesa/drivers/dri/sis/sis_alloc.h b/src/mesa/drivers/dri/sis/sis_alloc.h deleted file mode 100644 index eb784afad9e..00000000000 --- a/src/mesa/drivers/dri/sis/sis_alloc.h +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -enum { - VIDEO_TYPE, - AGP_TYPE -}; - -void sisAllocZStencilBuffer( sisContextPtr smesa ); -void sisFreeZStencilBuffer( sisContextPtr smesa ); -void sisAllocBackbuffer( sisContextPtr smesa ); -void sisFreeBackbuffer ( sisContextPtr smesa ); -void *sisAllocFB( sisContextPtr smesa, GLuint size, void **handle ); -void sisFreeFB( sisContextPtr smesa, void *handle ); -void *sisAllocAGP( sisContextPtr smesa, GLuint size, void **handle ); -void sisFreeAGP( sisContextPtr smesa, void *handle ); diff --git a/src/mesa/drivers/dri/sis/sis_clear.c b/src/mesa/drivers/dri/sis/sis_clear.c deleted file mode 100644 index a5d870469da..00000000000 --- a/src/mesa/drivers/dri/sis/sis_clear.c +++ /dev/null @@ -1,408 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_context.h" -#include "sis_state.h" -#include "sis_lock.h" - -#include "swrast/swrast.h" -#include "main/macros.h" - -static GLbitfield sis_3D_Clear( struct gl_context * ctx, GLbitfield mask, - GLint x, GLint y, GLint width, - GLint height ); -static void sis_clear_color_buffer( struct gl_context *ctx, GLenum mask, GLint x, - GLint y, GLint width, GLint height ); -static void sis_clear_z_stencil_buffer( struct gl_context * ctx, - GLbitfield mask, GLint x, - GLint y, GLint width, - GLint height ); - -static void -set_color_pattern( sisContextPtr smesa, GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha ) -{ - /* XXX only RGB565 and ARGB8888 */ - switch (smesa->colorFormat) - { - case DST_FORMAT_ARGB_8888: - smesa->clearColorPattern = (alpha << 24) + - (red << 16) + (green << 8) + (blue); - break; - case DST_FORMAT_RGB_565: - smesa->clearColorPattern = ((red >> 3) << 11) + - ((green >> 2) << 5) + (blue >> 3); - smesa->clearColorPattern |= smesa->clearColorPattern << 16; - break; - default: - sis_fatal_error("Bad dst color format\n"); - } -} - -void -sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z, GLint stencil ) -{ - GLuint zPattern; - - switch (smesa->zFormat) - { - case SiS_ZFORMAT_Z16: - CLAMPED_FLOAT_TO_USHORT(zPattern, z); - zPattern |= zPattern << 16; - break; - case SiS_ZFORMAT_S8Z24: - zPattern = FLOAT_TO_UINT(z) >> 8; - zPattern |= stencil << 24; - break; - case SiS_ZFORMAT_Z32: - zPattern = FLOAT_TO_UINT(z); - break; - default: - sis_fatal_error("Bad Z format\n"); - } - smesa->clearZStencilPattern = zPattern; -} - -void -sisDDClear( struct gl_context * ctx, GLbitfield mask ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - GLint x1, y1, width1, height1; - - /* get region after locking: */ - x1 = ctx->DrawBuffer->_Xmin; - y1 = ctx->DrawBuffer->_Ymin; - width1 = ctx->DrawBuffer->_Xmax - x1; - height1 = ctx->DrawBuffer->_Ymax - y1; - y1 = Y_FLIP(y1 + height1 - 1); - - /* Mask out any non-existent buffers */ - if (ctx->Visual.depthBits == 0 || !ctx->Depth.Mask) - mask &= ~BUFFER_BIT_DEPTH; - if (ctx->Visual.stencilBits == 0) - mask &= ~BUFFER_BIT_STENCIL; - - LOCK_HARDWARE(); - - /* The 3d clear code is use for masked clears because apparently the SiS - * 300-series can't do write masks for 2d blits. 3d isn't used in general - * because it's slower, even in the case of clearing multiple buffers. - */ - /* XXX: Appears to be broken with stencil. */ - if ((smesa->current.hwCapEnable2 & (MASK_AlphaMaskWriteEnable | - MASK_ColorMaskWriteEnable) && - (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT)) != 0) || - ((ctx->Stencil.WriteMask[0] & 0xff) != 0xff && - (mask & BUFFER_BIT_STENCIL) != 0) ) - { - mask = sis_3D_Clear( ctx, mask, x1, y1, width1, height1 ); - } - - if ( mask & BUFFER_BIT_FRONT_LEFT || mask & BUFFER_BIT_BACK_LEFT) { - sis_clear_color_buffer( ctx, mask, x1, y1, width1, height1 ); - mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); - } - - if (mask & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) { - if (smesa->depth.offset != 0) - sis_clear_z_stencil_buffer( ctx, mask, x1, y1, width1, height1 ); - mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - } - - UNLOCK_HARDWARE(); - - if (mask != 0) - _swrast_Clear( ctx, mask); -} - - -void -sisDDClearColor( struct gl_context * ctx, const GLfloat color[4] ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLubyte c[4]; - - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - set_color_pattern( smesa, c[0], c[1], c[2], c[3] ); -} - -void -sisDDClearDepth( struct gl_context * ctx, GLclampd d ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - sisUpdateZStencilPattern( smesa, d, ctx->Stencil.Clear ); -} - -void -sisDDClearStencil( struct gl_context * ctx, GLint s ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - sisUpdateZStencilPattern( smesa, ctx->Depth.Clear, s ); -} - -static GLbitfield -sis_3D_Clear( struct gl_context * ctx, GLbitfield mask, - GLint x, GLint y, GLint width, GLint height ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *current = &smesa->current; - - float left, top, right, bottom, zClearVal; - GLboolean bClrColor, bClrDepth, bClrStencil; - GLint dwPrimitiveSet; - GLint dwEnable1 = 0, dwEnable2 = MASK_ColorMaskWriteEnable; - GLint dwDepthMask = 0, dwSten1 = 0, dwSten2 = 0; - GLint dirtyflags = GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 | - GFLAG_CLIPPING | GFLAG_DESTSETTING; - int count; - drm_clip_rect_t *pExtents; - - bClrColor = (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT)) != 0; - bClrDepth = (mask & BUFFER_BIT_DEPTH) != 0; - bClrStencil = (mask & BUFFER_BIT_STENCIL) != 0; - - if (smesa->GlobalFlag & GFLAG_RENDER_STATES) - sis_update_render_state( smesa ); - - if (bClrStencil) { - dwSten1 = STENCIL_FORMAT_8 | SiS_STENCIL_ALWAYS | - ((ctx->Stencil.Clear & 0xff) << 8) | 0xff; - dwSten2 = SiS_SFAIL_REPLACE | SiS_SPASS_ZFAIL_REPLACE | - SiS_SPASS_ZPASS_REPLACE; - dwEnable1 = MASK_ZWriteEnable | MASK_StencilWriteEnable | - MASK_StencilTestEnable; - dwEnable2 |= MASK_ZMaskWriteEnable; - dwDepthMask |= (ctx->Stencil.WriteMask[0] & 0xff) << 24; - } else if (bClrDepth) { - dwEnable1 = MASK_ZWriteEnable; - dwEnable2 |= MASK_ZMaskWriteEnable; - } - - if (bClrDepth) { - zClearVal = ctx->Depth.Clear; - if (ctx->Visual.depthBits != 32) - dwDepthMask |= 0x00ffffff; - else - dwDepthMask = 0xffffffff; - } else - zClearVal = 0.0; - - mWait3DCmdQueue(9); - MMIO(REG_3D_TEnable, dwEnable1); - MMIO(REG_3D_TEnable2, dwEnable2); - if (bClrDepth || bClrStencil) { - MMIO(REG_3D_ZSet, (current->hwZ & ~MASK_ZTestMode) | SiS_Z_COMP_ALWAYS); - dirtyflags |= GFLAG_ZSETTING; - } - if (bClrColor) { - MMIO(REG_3D_DstSet, (current->hwDstSet & ~MASK_ROP2) | LOP_COPY); - } else { - MMIO(REG_3D_DstAlphaWriteMask, 0L); - } - if (bClrStencil) { - MMIO(REG_3D_StencilSet, dwSten1); - MMIO(REG_3D_StencilSet2, dwSten2); - dirtyflags |= GFLAG_STENCILSETTING; - } - - if (mask & BUFFER_BIT_FRONT_LEFT) { - pExtents = smesa->driDrawable->pClipRects; - count = smesa->driDrawable->numClipRects; - } else { - pExtents = NULL; - count = 1; - } - - while(count--) { - left = x; - right = x + width; - top = y; - bottom = y + height; - - if (pExtents != NULL) { - GLuint x1, y1, x2, y2; - - x1 = pExtents->x1 - smesa->driDrawable->x; - y1 = pExtents->y1 - smesa->driDrawable->y; - x2 = pExtents->x2 - smesa->driDrawable->x - 1; - y2 = pExtents->y2 - smesa->driDrawable->y - 1; - - left = (left > x1) ? left : x1; - right = (right > x2) ? x2 : right; - top = (top > y1) ? top : y1; - bottom = (bottom > y2) ? y2 : bottom; - pExtents++; - if (left > right || top > bottom) - continue; - } - - mWait3DCmdQueue(20); - - MMIO(REG_3D_ClipTopBottom, ((GLint)top << 13) | (GLint)bottom); - MMIO(REG_3D_ClipLeftRight, ((GLint)left << 13) | (GLint)right); - - /* the first triangle */ - dwPrimitiveSet = OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBc | - SHADE_FLAT_VertexC; - MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet); - - MMIO(REG_3D_TSZa, *(GLint *) &zClearVal); - MMIO(REG_3D_TSXa, *(GLint *) &right); - MMIO(REG_3D_TSYa, *(GLint *) &top); - MMIO(REG_3D_TSARGBa, smesa->clearColorPattern); - - MMIO(REG_3D_TSZb, *(GLint *) &zClearVal); - MMIO(REG_3D_TSXb, *(GLint *) &left); - MMIO(REG_3D_TSYb, *(GLint *) &top); - MMIO(REG_3D_TSARGBb, smesa->clearColorPattern); - - MMIO(REG_3D_TSZc, *(GLint *) &zClearVal); - MMIO(REG_3D_TSXc, *(GLint *) &left); - MMIO(REG_3D_TSYc, *(GLint *) &bottom); - MMIO(REG_3D_TSARGBc, smesa->clearColorPattern); - - /* second triangle */ - dwPrimitiveSet = OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBb | - SHADE_FLAT_VertexB; - MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet); - - MMIO(REG_3D_TSZb, *(GLint *) &zClearVal); - MMIO(REG_3D_TSXb, *(GLint *) &right); - MMIO(REG_3D_TSYb, *(GLint *) &bottom); - MMIO(REG_3D_TSARGBb, smesa->clearColorPattern); - } - - mEndPrimitive(); - - /* If BUFFER_BIT_FRONT_LEFT is set, we've only cleared the front buffer so far */ - if ((mask & BUFFER_BIT_FRONT_LEFT) != 0 && (mask & BUFFER_BIT_BACK_LEFT) != 0) - sis_3D_Clear( ctx, BUFFER_BIT_BACK_LEFT, x, y, width, height ); - - smesa->GlobalFlag |= dirtyflags; - - return mask & ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL | BUFFER_BIT_BACK_LEFT | - BUFFER_BIT_FRONT_LEFT); -} - -static void -sis_clear_color_buffer( struct gl_context *ctx, GLenum mask, GLint x, GLint y, - GLint width, GLint height ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - int count; - drm_clip_rect_t *pExtents = NULL; - GLint xx, yy; - GLint x0, y0, width0, height0; - - /* Clear back buffer */ - if (mask & BUFFER_BIT_BACK_LEFT) { - mWait3DCmdQueue (8); - MMIO(REG_SRC_PITCH, (smesa->bytesPerPixel == 4) ? - BLIT_DEPTH_32 : BLIT_DEPTH_16); - MMIO(REG_DST_X_Y, (x << 16) | y); - MMIO(REG_DST_ADDR, smesa->back.offset); - MMIO(REG_DST_PITCH_HEIGHT, (smesa->virtualY << 16) | smesa->back.pitch); - MMIO(REG_WIDTH_HEIGHT, (height << 16) | width); - MMIO(REG_PATFG, smesa->clearColorPattern); - MMIO(REG_BLIT_CMD, CMD_DIR_X_INC | CMD_DIR_Y_INC | CMD_ROP_PAT); - MMIO(REG_CommandQueue, -1); - } - - if ((mask & BUFFER_BIT_FRONT_LEFT) == 0) - return; - - /* Clear front buffer */ - x0 = x; - y0 = y; - width0 = width; - height0 = height; - - pExtents = smesa->driDrawable->pClipRects; - count = smesa->driDrawable->numClipRects; - - while (count--) { - GLint x2 = pExtents->x1 - smesa->driDrawable->x; - GLint y2 = pExtents->y1 - smesa->driDrawable->y; - GLint xx2 = pExtents->x2 - smesa->driDrawable->x; - GLint yy2 = pExtents->y2 - smesa->driDrawable->y; - - x = (x0 > x2) ? x0 : x2; - y = (y0 > y2) ? y0 : y2; - xx = ((x0 + width0) > (xx2)) ? xx2 : x0 + width0; - yy = ((y0 + height0) > (yy2)) ? yy2 : y0 + height0; - width = xx - x; - height = yy - y; - pExtents++; - - if (width <= 0 || height <= 0) - continue; - - mWait3DCmdQueue (8); - MMIO(REG_SRC_PITCH, (smesa->bytesPerPixel == 4) ? - BLIT_DEPTH_32 : BLIT_DEPTH_16); - MMIO(REG_DST_X_Y, (x << 16) | y); - MMIO(REG_DST_ADDR, smesa->front.offset); - MMIO(REG_DST_PITCH_HEIGHT, (smesa->virtualY << 16) | smesa->front.pitch); - MMIO(REG_WIDTH_HEIGHT, (height << 16) | width); - MMIO(REG_PATFG, smesa->clearColorPattern); - MMIO(REG_BLIT_CMD, CMD_DIR_X_INC | CMD_DIR_Y_INC | CMD_ROP_PAT); - MMIO(REG_CommandQueue, -1); - } -} - -static void -sis_clear_z_stencil_buffer( struct gl_context * ctx, GLbitfield mask, - GLint x, GLint y, GLint width, GLint height ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - mWait3DCmdQueue (8); - MMIO(REG_SRC_PITCH, (smesa->zFormat == SiS_ZFORMAT_Z16) ? - BLIT_DEPTH_16 : BLIT_DEPTH_32); - MMIO(REG_DST_X_Y, (x << 16) | y); - MMIO(REG_DST_ADDR, smesa->depth.offset); - MMIO(REG_DST_PITCH_HEIGHT, (smesa->virtualY << 16) | smesa->depth.pitch); - MMIO(REG_WIDTH_HEIGHT, (height << 16) | width); - MMIO(REG_PATFG, smesa->clearZStencilPattern); - MMIO(REG_BLIT_CMD, CMD_DIR_X_INC | CMD_DIR_Y_INC | CMD_ROP_PAT); - MMIO(REG_CommandQueue, -1); -} - diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c deleted file mode 100644 index 26ecfc463ca..00000000000 --- a/src/mesa/drivers/dri/sis/sis_context.c +++ /dev/null @@ -1,719 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_dri.h" - -#include "sis_context.h" -#include "sis_state.h" -#include "sis_dd.h" -#include "sis_span.h" -#include "sis_stencil.h" -#include "sis_tex.h" -#include "sis_tris.h" -#include "sis_alloc.h" - -#include "main/imports.h" -#include "utils.h" -#include "main/framebuffer.h" - -#include "drivers/common/driverfuncs.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" - -#define need_GL_EXT_fog_coord -#define need_GL_EXT_secondary_color -#include "main/remap_helper.h" - -#ifndef SIS_DEBUG -int SIS_DEBUG = 0; -#endif - -int GlobalCurrentHwcx = -1; -int GlobalHwcxCountBase = 1; -int GlobalCmdQueueLen = 0; - -static struct dri_extension card_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_ARB_texture_border_clamp", NULL }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - /*{ "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },*/ - { "GL_EXT_texture_lod_bias", NULL }, - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_MESA_ycbcr_texture", NULL }, - { "GL_NV_blend_square", NULL }, - { NULL, NULL } -}; - -#if 0 -static struct dri_extension card_extensions_6326[] = -{ - /*{ "GL_ARB_texture_border_clamp", NULL },*/ - /*{ "GL_ARB_texture_mirrored_repeat", NULL },*/ - /*{ "GL_MESA_ycbcr_texture", NULL },*/ - { NULL, NULL } -}; -#endif - -static const struct dri_debug_control debug_control[] = -{ - { "fall", DEBUG_FALLBACKS }, - { NULL, 0 } -}; - -void -WaitEngIdle (sisContextPtr smesa) -{ - GLuint engineState; - - if (smesa->is6326) { - do { - engineState = MMIO_READ(REG_3D_EngineFire); /* XXX right reg? */ - } while ((engineState & ENG_3DIDLEQE) != 0); - } else { - do { - engineState = MMIO_READ(REG_CommandQueue); - } while ((engineState & SiS_EngIdle) != SiS_EngIdle); - } -} - -void -Wait2DEngIdle (sisContextPtr smesa) -{ - GLuint engineState; - - if (smesa->is6326) { - do { - engineState = MMIO_READ(REG_6326_BitBlt_Cmd); - } while ((engineState & BLT_BUSY) != 0); - } else { - do { - engineState = MMIO_READ(REG_CommandQueue); - } while ((engineState & SiS_EngIdle2d) != SiS_EngIdle2d); - } -} - -/* To be called from mWait3DCmdQueue. Separate function for profiling - * purposes, and speed doesn't matter because we're spinning anyway. - */ -void -WaitingFor3dIdle(sisContextPtr smesa, int wLen) -{ - if (smesa->is6326) { - while (*(smesa->CurrentQueueLenPtr) < wLen) { - *(smesa->CurrentQueueLenPtr) = - ((GLuint)MMIO_READ(REG_3D_EngineFire) >> 16) * 2; - } - } else { - while (*(smesa->CurrentQueueLenPtr) < wLen) { - *(smesa->CurrentQueueLenPtr) = - (MMIO_READ(REG_CommandQueue) & MASK_QueueLen) - 20; - } - } -} - -void sisReAllocateBuffers(struct gl_context *ctx, struct gl_framebuffer *drawbuffer, - GLuint width, GLuint height) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - sisUpdateBufferSize(smesa); - - _mesa_resize_framebuffer(ctx, drawbuffer, width, height); -} - -GLboolean -sisCreateContext( gl_api api, - const struct gl_config *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - struct gl_context *ctx, *shareCtx; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - sisContextPtr smesa; - sisScreenPtr sisScreen; - int i; - struct dd_function_table functions; - - smesa = (sisContextPtr)CALLOC( sizeof(*smesa) ); - if (smesa == NULL) - return GL_FALSE; - - /* Init default driver functions then plug in our SIS-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions(&functions); - sisInitDriverFuncs(&functions); - sisInitTextureFuncs(&functions); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((sisContextPtr)sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - smesa->glCtx = _mesa_create_context( API_OPENGL, glVisual, shareCtx, - &functions, (void *) smesa); - if (!smesa->glCtx) { - FREE(smesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = smesa; - ctx = smesa->glCtx; - - sisScreen = smesa->sisScreen = (sisScreenPtr)(sPriv->private); - - smesa->is6326 = GL_FALSE; /* XXX */ - smesa->driContext = driContextPriv; - smesa->driScreen = sPriv; - smesa->driDrawable = NULL; - smesa->hHWContext = driContextPriv->hHWContext; - smesa->driHwLock = &sPriv->pSAREA->lock; - smesa->driFd = sPriv->fd; - - smesa->virtualX = sisScreen->screenX; - smesa->virtualY = sisScreen->screenY; - smesa->bytesPerPixel = sisScreen->cpp; - smesa->IOBase = sisScreen->mmio.map; - smesa->Chipset = sisScreen->deviceID; - - smesa->FbBase = sPriv->pFB; - smesa->displayWidth = sPriv->fbWidth; - smesa->front.pitch = sPriv->fbStride; - - smesa->sarea = (SISSAREAPriv *)((char *)sPriv->pSAREA + - sisScreen->sarea_priv_offset); - - /* support ARGB8888 and RGB565 */ - switch (smesa->bytesPerPixel) - { - case 4: - smesa->redMask = 0x00ff0000; - smesa->greenMask = 0x0000ff00; - smesa->blueMask = 0x000000ff; - smesa->alphaMask = 0xff000000; - smesa->colorFormat = DST_FORMAT_ARGB_8888; - break; - case 2: - smesa->redMask = 0xf800; - smesa->greenMask = 0x07e0; - smesa->blueMask = 0x001f; - smesa->alphaMask = 0; - smesa->colorFormat = DST_FORMAT_RGB_565; - break; - default: - sis_fatal_error("Bad bytesPerPixel %d.\n", smesa->bytesPerPixel); - } - - if (smesa->is6326) { - ctx->Const.MaxTextureUnits = 1; - ctx->Const.MaxTextureLevels = 9; - } else { - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureLevels = 11; - } - ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; - ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; - - /* Parse configuration files */ - driParseConfigFiles (&smesa->optionCache, &sisScreen->optionCache, - sisScreen->driScreen->myNum, "sis"); - -#if DO_DEBUG - SIS_DEBUG = driParseDebugString(getenv("SIS_DEBUG"), debug_control); -#endif - - /* TODO: index mode */ - - smesa->CurrentQueueLenPtr = &(smesa->sarea->QueueLength); - smesa->FrameCountPtr = &(smesa->sarea->FrameCount); - - /* set AGP */ - smesa->AGPSize = sisScreen->agp.size; - smesa->AGPBase = sisScreen->agp.map; - smesa->AGPAddr = sisScreen->agpBaseOffset; - - /* Create AGP command buffer */ - if (smesa->AGPSize != 0 && - !driQueryOptionb(&smesa->optionCache, "agp_disable")) - { - smesa->vb = sisAllocAGP(smesa, 64 * 1024, &smesa->vb_agp_handle); - if (smesa->vb != NULL) { - smesa->using_agp = GL_TRUE; - smesa->vb_cur = smesa->vb; - smesa->vb_last = smesa->vb; - smesa->vb_end = smesa->vb + 64 * 1024; - smesa->vb_agp_offset = ((long)smesa->vb - (long)smesa->AGPBase + - (long)smesa->AGPAddr); - } - } - if (!smesa->using_agp) { - smesa->vb = malloc(64 * 1024); - if (smesa->vb == NULL) { - FREE(smesa); - return GL_FALSE; - } - smesa->vb_cur = smesa->vb; - smesa->vb_last = smesa->vb; - smesa->vb_end = smesa->vb + 64 * 1024; - } - - smesa->GlobalFlag = 0L; - - smesa->Fallback = 0; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - _swrast_allow_pixel_fog( ctx, GL_TRUE ); - _swrast_allow_vertex_fog( ctx, GL_FALSE ); - _tnl_allow_pixel_fog( ctx, GL_TRUE ); - _tnl_allow_vertex_fog( ctx, GL_FALSE ); - - /* XXX these should really go right after _mesa_init_driver_functions() */ - if (smesa->is6326) { - sis6326DDInitStateFuncs( ctx ); - sis6326DDInitState( smesa ); /* Initializes smesa->zFormat, important */ - } else { - sisDDInitStateFuncs( ctx ); - sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */ - sisDDInitStencilFuncs( ctx ); - } - sisInitTriFuncs( ctx ); - sisDDInitSpanFuncs( ctx ); - - driInitExtensions( ctx, card_extensions, GL_FALSE ); - - for (i = 0; i < SIS_MAX_TEXTURES; i++) { - smesa->TexStates[i] = 0; - smesa->PrevTexFormat[i] = 0; - } - - if (driQueryOptionb(&smesa->optionCache, "no_rast")) { - fprintf(stderr, "disabling 3D acceleration\n"); - FALLBACK(smesa, SIS_FALLBACK_DISABLE, 1); - } - smesa->texture_depth = driQueryOptioni(&smesa->optionCache, "texture_depth"); - - return GL_TRUE; -} - -void -sisDestroyContext ( __DRIcontext *driContextPriv ) -{ - sisContextPtr smesa = (sisContextPtr)driContextPriv->driverPrivate; - - assert( smesa != NULL ); - - if ( smesa != NULL ) { - _swsetup_DestroyContext( smesa->glCtx ); - _tnl_DestroyContext( smesa->glCtx ); - _vbo_DestroyContext( smesa->glCtx ); - _swrast_DestroyContext( smesa->glCtx ); - - if (smesa->using_agp) - sisFreeAGP(smesa, smesa->vb_agp_handle); - - /* free the Mesa context */ - /* XXX: Is the next line needed? The DriverCtx (smesa) reference is - * needed for sisDDDeleteTexture, since it needs to call the FB/AGP free - * function. - */ - /* smesa->glCtx->DriverCtx = NULL; */ - _mesa_destroy_context(smesa->glCtx); - } - - FREE( smesa ); -} - -GLboolean -sisMakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ) -{ - if ( driContextPriv ) { - GET_CURRENT_CONTEXT(ctx); - sisContextPtr oldSisCtx = ctx ? SIS_CONTEXT(ctx) : NULL; - sisContextPtr newSisCtx = (sisContextPtr) driContextPriv->driverPrivate; - struct gl_framebuffer *drawBuffer, *readBuffer; - - if ( newSisCtx != oldSisCtx) { - newSisCtx->GlobalFlag = GFLAG_ALL; - } - - newSisCtx->driDrawable = driDrawPriv; - - drawBuffer = (struct gl_framebuffer *)driDrawPriv->driverPrivate; - readBuffer = (struct gl_framebuffer *)driReadPriv->driverPrivate; - - _mesa_make_current( newSisCtx->glCtx, drawBuffer, readBuffer ); - - sisUpdateBufferSize( newSisCtx ); - sisUpdateClipping( newSisCtx->glCtx ); - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - return GL_TRUE; -} - -GLboolean -sisUnbindContext( __DRIcontext *driContextPriv ) -{ - return GL_TRUE; -} - -void -sis_update_render_state( sisContextPtr smesa ) -{ - __GLSiSHardware *prev = &smesa->prev; - - mWait3DCmdQueue (45); - - if (smesa->GlobalFlag & GFLAG_ENABLESETTING) { - if (!smesa->clearTexCache) { - MMIO(REG_3D_TEnable, prev->hwCapEnable); - } else { - MMIO(REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); - MMIO(REG_3D_TEnable, prev->hwCapEnable); - smesa->clearTexCache = GL_FALSE; - } - } - - if (smesa->GlobalFlag & GFLAG_ENABLESETTING2) - MMIO(REG_3D_TEnable2, prev->hwCapEnable2); - - /* Z Setting */ - if (smesa->GlobalFlag & GFLAG_ZSETTING) - { - MMIO(REG_3D_ZSet, prev->hwZ); - MMIO(REG_3D_ZStWriteMask, prev->hwZMask); - MMIO(REG_3D_ZAddress, prev->hwOffsetZ); - } - - /* Alpha Setting */ - if (smesa->GlobalFlag & GFLAG_ALPHASETTING) - MMIO(REG_3D_AlphaSet, prev->hwAlpha); - - if (smesa->GlobalFlag & GFLAG_DESTSETTING) { - MMIO(REG_3D_DstSet, prev->hwDstSet); - MMIO(REG_3D_DstAlphaWriteMask, prev->hwDstMask); - MMIO(REG_3D_DstAddress, prev->hwOffsetDest); - } - - /* Line Setting */ -#if 0 - if (smesa->GlobalFlag & GFLAG_LINESETTING) - MMIO(REG_3D_LinePattern, prev->hwLinePattern); -#endif - - /* Fog Setting */ - if (smesa->GlobalFlag & GFLAG_FOGSETTING) - { - MMIO(REG_3D_FogSet, prev->hwFog); - MMIO(REG_3D_FogInverseDistance, prev->hwFogInverse); - MMIO(REG_3D_FogFarDistance, prev->hwFogFar); - MMIO(REG_3D_FogFactorDensity, prev->hwFogDensity); - } - - /* Stencil Setting */ - if (smesa->GlobalFlag & GFLAG_STENCILSETTING) { - MMIO(REG_3D_StencilSet, prev->hwStSetting); - MMIO(REG_3D_StencilSet2, prev->hwStSetting2); - } - - /* Miscellaneous Setting */ - if (smesa->GlobalFlag & GFLAG_DSTBLEND) - MMIO(REG_3D_DstBlendMode, prev->hwDstSrcBlend); - if (smesa->GlobalFlag & GFLAG_CLIPPING) { - MMIO(REG_3D_ClipTopBottom, prev->clipTopBottom); - MMIO(REG_3D_ClipLeftRight, prev->clipLeftRight); - } - - smesa->GlobalFlag &= ~GFLAG_RENDER_STATES; -} - -void -sis_update_texture_state (sisContextPtr smesa) -{ - __GLSiSHardware *prev = &smesa->prev; - - mWait3DCmdQueue (55); - if (smesa->clearTexCache || (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS)) { - MMIO(REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); - MMIO(REG_3D_TEnable, prev->hwCapEnable); - smesa->clearTexCache = GL_FALSE; - } - - /* Texture Setting */ - if (smesa->GlobalFlag & CFLAG_TEXTURERESET) - MMIO(REG_3D_TextureSet, prev->texture[0].hwTextureSet); - - if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP) - MMIO(REG_3D_TextureMip, prev->texture[0].hwTextureMip); - - /* - MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh); - MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow); - */ - - if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR) - MMIO(REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor); - - if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS) { - switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8) - { - case 11: - MMIO(REG_3D_TextureAddress11, prev->texture[0].texOffset11); - case 10: - MMIO(REG_3D_TextureAddress10, prev->texture[0].texOffset10); - MMIO(REG_3D_TexturePitch10, prev->texture[0].texPitch10); - case 9: - MMIO(REG_3D_TextureAddress9, prev->texture[0].texOffset9); - case 8: - MMIO(REG_3D_TextureAddress8, prev->texture[0].texOffset8); - MMIO(REG_3D_TexturePitch8, prev->texture[0].texPitch89); - case 7: - MMIO(REG_3D_TextureAddress7, prev->texture[0].texOffset7); - case 6: - MMIO(REG_3D_TextureAddress6, prev->texture[0].texOffset6); - MMIO(REG_3D_TexturePitch6, prev->texture[0].texPitch67); - case 5: - MMIO(REG_3D_TextureAddress5, prev->texture[0].texOffset5); - case 4: - MMIO(REG_3D_TextureAddress4, prev->texture[0].texOffset4); - MMIO(REG_3D_TexturePitch4, prev->texture[0].texPitch45); - case 3: - MMIO(REG_3D_TextureAddress3, prev->texture[0].texOffset3); - case 2: - MMIO(REG_3D_TextureAddress2, prev->texture[0].texOffset2); - MMIO(REG_3D_TexturePitch2, prev->texture[0].texPitch23); - case 1: - MMIO(REG_3D_TextureAddress1, prev->texture[0].texOffset1); - case 0: - MMIO(REG_3D_TextureAddress0, prev->texture[0].texOffset0); - MMIO(REG_3D_TexturePitch0, prev->texture[0].texPitch01); - } - } - if (smesa->GlobalFlag & CFLAG_TEXTURERESET_1) - MMIO(REG_3D_Texture1Set, prev->texture[1].hwTextureSet); - if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP_1) - MMIO(REG_3D_Texture1Mip, prev->texture[1].hwTextureMip); - - if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR_1) { - MMIO(REG_3D_Texture1BorderColor, - prev->texture[1].hwTextureBorderColor); - } - if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS_1) { - switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8) - { - case 11: - MMIO(REG_3D_Texture1Address11, prev->texture[1].texOffset11); - case 10: - MMIO(REG_3D_Texture1Address10, prev->texture[1].texOffset10); - MMIO(REG_3D_Texture1Pitch10, prev->texture[1].texPitch10); - case 9: - MMIO(REG_3D_Texture1Address9, prev->texture[1].texOffset9); - case 8: - MMIO(REG_3D_Texture1Address8, prev->texture[1].texOffset8); - MMIO(REG_3D_Texture1Pitch8, prev->texture[1].texPitch89); - case 7: - MMIO(REG_3D_Texture1Address7, prev->texture[1].texOffset7); - case 6: - MMIO(REG_3D_Texture1Address6, prev->texture[1].texOffset6); - MMIO(REG_3D_Texture1Pitch6, prev->texture[1].texPitch67); - case 5: - MMIO(REG_3D_Texture1Address5, prev->texture[1].texOffset5); - case 4: - MMIO(REG_3D_Texture1Address4, prev->texture[1].texOffset4); - MMIO(REG_3D_Texture1Pitch4, prev->texture[1].texPitch45); - case 3: - MMIO(REG_3D_Texture1Address3, prev->texture[1].texOffset3); - case 2: - MMIO(REG_3D_Texture1Address2, prev->texture[1].texOffset2); - MMIO(REG_3D_Texture1Pitch2, prev->texture[1].texPitch23); - case 1: - MMIO(REG_3D_Texture1Address1, prev->texture[1].texOffset1); - case 0: - MMIO(REG_3D_Texture1Address0, prev->texture[1].texOffset0); - MMIO(REG_3D_Texture1Pitch0, prev->texture[1].texPitch01); - } - } - - /* texture environment */ - if (smesa->GlobalFlag & GFLAG_TEXTUREENV) { - MMIO(REG_3D_TextureBlendFactor, prev->hwTexEnvColor); - MMIO(REG_3D_TextureColorBlendSet0, prev->hwTexBlendColor0); - MMIO(REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0); - } - if (smesa->GlobalFlag & GFLAG_TEXTUREENV_1) { - MMIO(REG_3D_TextureBlendFactor, prev->hwTexEnvColor); - MMIO(REG_3D_TextureColorBlendSet1, prev->hwTexBlendColor1); - MMIO(REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1); - } - - smesa->GlobalFlag &= ~GFLAG_TEXTURE_STATES; -} - -void -sis6326_update_render_state( sisContextPtr smesa ) -{ - __GLSiSHardware *prev = &smesa->prev; - - mWait3DCmdQueue (45); - - if (smesa->GlobalFlag & GFLAG_ENABLESETTING) { - if (!smesa->clearTexCache) { - MMIO(REG_6326_3D_TEnable, prev->hwCapEnable); - } else { - MMIO(REG_6326_3D_TEnable, prev->hwCapEnable & ~S_ENABLE_TextureCache); - MMIO(REG_6326_3D_TEnable, prev->hwCapEnable); - smesa->clearTexCache = GL_FALSE; - } - } - - /* Z Setting */ - if (smesa->GlobalFlag & GFLAG_ZSETTING) { - MMIO(REG_6326_3D_ZSet, prev->hwZ); - MMIO(REG_6326_3D_ZAddress, prev->hwOffsetZ); - } - - /* Alpha Setting */ - if (smesa->GlobalFlag & GFLAG_ALPHASETTING) - MMIO(REG_6326_3D_AlphaSet, prev->hwAlpha); - - if (smesa->GlobalFlag & GFLAG_DESTSETTING) { - MMIO(REG_6326_3D_DstSet, prev->hwDstSet); - MMIO(REG_6326_3D_DstAddress, prev->hwOffsetDest); - } - - /* Fog Setting */ - if (smesa->GlobalFlag & GFLAG_FOGSETTING) { - MMIO(REG_6326_3D_FogSet, prev->hwFog); - } - - /* Miscellaneous Setting */ - if (smesa->GlobalFlag & GFLAG_DSTBLEND) - MMIO(REG_6326_3D_DstSrcBlendMode, prev->hwDstSrcBlend); - - if (smesa->GlobalFlag & GFLAG_CLIPPING) { - MMIO(REG_6326_3D_ClipTopBottom, prev->clipTopBottom); - MMIO(REG_6326_3D_ClipLeftRight, prev->clipLeftRight); - } - - smesa->GlobalFlag &= ~GFLAG_RENDER_STATES; -} - -void -sis6326_update_texture_state (sisContextPtr smesa) -{ - __GLSiSHardware *prev = &smesa->prev; - - mWait3DCmdQueue (55); - if (smesa->clearTexCache || (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS)) { - MMIO(REG_6326_3D_TEnable, prev->hwCapEnable & ~S_ENABLE_TextureCache); - MMIO(REG_6326_3D_TEnable, prev->hwCapEnable); - smesa->clearTexCache = GL_FALSE; - } - - /* Texture Setting */ - if (smesa->GlobalFlag & CFLAG_TEXTURERESET) - MMIO(REG_6326_3D_TextureSet, prev->texture[0].hwTextureSet); - - if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP) - MMIO(REG_6326_3D_TextureWidthHeight, prev->texture[0].hwTexWidthHeight); - - /* - MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh); - MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow); - */ - - if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR) - MMIO(REG_6326_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor); - - if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS) { - switch ((prev->texture[0].hwTextureSet & MASK_6326_TextureLevel) >> 8) - { - case 9: - MMIO(REG_6326_3D_TextureAddress9, prev->texture[0].texOffset9); - /* FALLTHROUGH */ - case 8: - MMIO(REG_6326_3D_TextureAddress8, prev->texture[0].texOffset8); - MMIO(REG_6326_3D_TexturePitch89, prev->texture[0].texPitch89); - /* FALLTHROUGH */ - case 7: - MMIO(REG_6326_3D_TextureAddress7, prev->texture[0].texOffset7); - /* FALLTHROUGH */ - case 6: - MMIO(REG_6326_3D_TextureAddress6, prev->texture[0].texOffset6); - MMIO(REG_6326_3D_TexturePitch67, prev->texture[0].texPitch67); - /* FALLTHROUGH */ - case 5: - MMIO(REG_6326_3D_TextureAddress5, prev->texture[0].texOffset5); - /* FALLTHROUGH */ - case 4: - MMIO(REG_6326_3D_TextureAddress4, prev->texture[0].texOffset4); - MMIO(REG_6326_3D_TexturePitch45, prev->texture[0].texPitch45); - /* FALLTHROUGH */ - case 3: - MMIO(REG_6326_3D_TextureAddress3, prev->texture[0].texOffset3); - /* FALLTHROUGH */ - case 2: - MMIO(REG_6326_3D_TextureAddress2, prev->texture[0].texOffset2); - MMIO(REG_6326_3D_TexturePitch23, prev->texture[0].texPitch23); - /* FALLTHROUGH */ - case 1: - MMIO(REG_6326_3D_TextureAddress1, prev->texture[0].texOffset1); - /* FALLTHROUGH */ - case 0: - MMIO(REG_6326_3D_TextureAddress0, prev->texture[0].texOffset0); - MMIO(REG_6326_3D_TexturePitch01, prev->texture[0].texPitch01); - break; - } - } - - /* texture environment */ - if (smesa->GlobalFlag & GFLAG_TEXTUREENV) { - MMIO(REG_6326_3D_TextureBlendSet, prev->hwTexBlendSet); - } - - smesa->GlobalFlag &= ~GFLAG_TEXTURE_STATES; -} diff --git a/src/mesa/drivers/dri/sis/sis_context.h b/src/mesa/drivers/dri/sis/sis_context.h deleted file mode 100644 index a82a659431e..00000000000 --- a/src/mesa/drivers/dri/sis/sis_context.h +++ /dev/null @@ -1,479 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#ifndef _sis_ctx_h_ -#define _sis_ctx_h_ - -#include "main/context.h" -#include "dri_util.h" -#include "drm.h" -#include "drm_sarea.h" -#include "xmlconfig.h" -#include "tnl/t_vertex.h" - -#include "sis_screen.h" -#include "sis_reg.h" -#include "sis6326_reg.h" -#include "sis_dri.h" - -/* for GLboolean */ -#include <GL/gl.h> - -#define PCI_CHIP_SIS300 0x0300 -#define PCI_CHIP_SIS630 0x6300 -#define PCI_CHIP_SIS540 0x5300 - -#define NEW_TEXTURING 0x1 -#define NEW_TEXTURE_ENV 0x2 - -/* Flags for software fallback cases: - */ -#define SIS_FALLBACK_TEXTURE 0x0001 -#define SIS_FALLBACK_TEXTURE0 0x0002 -#define SIS_FALLBACK_TEXTURE1 0x0004 -#define SIS_FALLBACK_TEXENV0 0x0008 -#define SIS_FALLBACK_TEXENV1 0x0010 -#define SIS_FALLBACK_DRAW_BUFFER 0x0020 -#define SIS_FALLBACK_STENCIL 0x0040 -#define SIS_FALLBACK_WRITEMASK 0x0080 -#define SIS_FALLBACK_DISABLE 0x0100 - -/* Flags for hardware state that needs to be updated */ -#define GFLAG_ENABLESETTING 0x00000001 -#define GFLAG_ENABLESETTING2 0x00000002 -#define GFLAG_ZSETTING 0x00000004 -#define GFLAG_ALPHASETTING 0x00000008 -#define GFLAG_DESTSETTING 0x00000010 -#define GFLAG_LINESETTING 0x00000020 -#define GFLAG_STENCILSETTING 0x00000040 -#define GFLAG_FOGSETTING 0x00000080 -#define GFLAG_DSTBLEND 0x00000100 -#define GFLAG_CLIPPING 0x00000200 -#define CFLAG_TEXTURERESET 0x00000400 -#define GFLAG_TEXTUREMIPMAP 0x00000800 -#define GFLAG_TEXBORDERCOLOR 0x00001000 -#define GFLAG_TEXTUREADDRESS 0x00002000 -#define GFLAG_TEXTUREENV 0x00004000 -#define CFLAG_TEXTURERESET_1 0x00008000 -#define GFLAG_TEXTUREMIPMAP_1 0x00010000 -#define GFLAG_TEXBORDERCOLOR_1 0x00020000 -#define GFLAG_TEXTUREADDRESS_1 0x00040000 -#define GFLAG_TEXTUREENV_1 0x00080000 -#define GFLAG_ALL 0x000fffff - -#define GFLAG_TEXTURE_STATES (CFLAG_TEXTURERESET | GFLAG_TEXTUREMIPMAP | \ - GFLAG_TEXBORDERCOLOR | GFLAG_TEXTUREADDRESS | \ - CFLAG_TEXTURERESET_1 | GFLAG_TEXTUREMIPMAP_1 | \ - GFLAG_TEXBORDERCOLOR_1 | \ - GFLAG_TEXTUREADDRESS_1 | \ - GFLAG_TEXTUREENV | GFLAG_TEXTUREENV_1) - - -#define GFLAG_RENDER_STATES (GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 | \ - GFLAG_ZSETTING | GFLAG_ALPHASETTING | \ - GFLAG_DESTSETTING | GFLAG_FOGSETTING | \ - GFLAG_STENCILSETTING | GFLAG_DSTBLEND | \ - GFLAG_CLIPPING) - -/* Use the templated vertex format: - */ -#define TAG(x) sis##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -/* Subpixel offsets for window coordinates (triangles): - */ -#define SUBPIXEL_X (-0.5F) -#define SUBPIXEL_Y (-0.5F) - -#define SIS_MAX_TEXTURE_SIZE 2048 -#define SIS_MAX_TEXTURES 2 -#define SIS_MAX_TEXTURE_LEVELS 11 -#define SIS_MAX_FRAME_LENGTH 3 - -typedef struct { - GLubyte *Data; /* Pointer to texture in offscreen */ - GLuint memType; /* VIDEO_TYPE or AGP_TYPE */ - void *handle; /* Handle for sisFree*() */ - GLuint pitch; - GLuint size; -} sisTexImage; - -typedef struct sis_tex_obj { - sisTexImage image[SIS_MAX_TEXTURE_LEVELS]; /* Image data for each mipmap - * level */ - GLenum format; /* One of GL_ALPHA, GL_INTENSITY, GL_LUMINANCE, - * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA - * MESA_YCBCR */ - GLint hwformat; /* One of the TEXEL_ defines */ - GLint numImages; /* Number of images loaded into .image */ -} sisTexObj, *sisTexObjPtr; - -/* - ** Device dependent context state - */ -typedef struct __GLSiSTextureRec -{ - GLint hwTextureSet; - GLint hwTextureMip; - GLint hwTextureClrHigh; - GLint hwTextureClrLow; - GLint hwTexWidthHeight; /* 6326: Texture Blending Setting */ - GLint hwTextureBorderColor; - - GLint texOffset0; - GLint texOffset1; - GLint texOffset2; - GLint texOffset3; - GLint texOffset4; - GLint texOffset5; - GLint texOffset6; - GLint texOffset7; - GLint texOffset8; - GLint texOffset9; - GLint texOffset10; - GLint texOffset11; - - GLint texPitch01; - GLint texPitch23; - GLint texPitch45; - GLint texPitch67; - GLint texPitch89; - GLint texPitch10; -} __GLSiSTexture; - -typedef struct __GLSiSHardwareRec -{ - GLint hwCapEnable, hwCapEnable2; /* Enable Setting */ - - GLint hwOffsetZ, hwZ; /* Z Setting */ - - GLint hwZBias, hwZMask; /* Z Setting */ - - GLint hwAlpha; /* Alpha Setting */ - - GLint hwDstSet, hwDstMask; /* Destination Setting */ - - GLint hwOffsetDest; /* Destination Setting */ - - GLint hwLinePattern; /* Line Setting */ - - GLint hwFog; /* Fog Setting */ - - GLint hwFogFar, hwFogInverse; /* Fog Distance setting */ - - GLint hwFogDensity; /* Fog factor & density */ - - GLint hwStSetting, hwStSetting2; /* Stencil Setting */ - - GLint hwStOffset; /* Stencil Setting */ - - GLint hwDstSrcBlend; /* Blending mode Setting */ - - GLint clipTopBottom; /* Clip for Top & Bottom */ - - GLint clipLeftRight; /* Clip for Left & Right */ - - struct __GLSiSTextureRec texture[2]; - - GLint hwTexEnvColor; /* Texture Blending Setting */ - - GLint hwTexBlendSet; /* 6326 */ - GLint hwTexBlendColor0; - GLint hwTexBlendColor1; - GLint hwTexBlendAlpha0; - GLint hwTexBlendAlpha1; - -} -__GLSiSHardware; - -typedef struct sis_context sisContextRec; -typedef struct sis_context *sisContextPtr; - -typedef void (*sis_quad_func)( sisContextPtr, - sisVertex *, - sisVertex *, - sisVertex *, - sisVertex * ); - -typedef void (*sis_tri_func)( sisContextPtr, - sisVertex *, - sisVertex *, - sisVertex * ); - -typedef void (*sis_line_func)( sisContextPtr, - sisVertex *, - sisVertex * ); - -typedef void (*sis_point_func)( sisContextPtr, - sisVertex * ); - -/** - * Derived from gl_renderbuffer. - */ -struct sis_renderbuffer { - struct gl_renderbuffer Base; /* must be first! */ - drmSize size; - GLuint offset; - void *handle; - GLuint pitch; - GLuint bpp; - char *map; -}; - -/* Device dependent context state */ - -struct sis_context -{ - /* This must be first in this structure */ - struct gl_context *glCtx; - - /* Vertex state */ - GLuint vertex_size; - struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; - GLuint vertex_attr_count; - char *verts; /* points to tnl->clipspace.vertex_buf */ - - /* Vertex buffer (in system memory or AGP) state. */ - unsigned char *vb; /* Beginning of vertex buffer */ - unsigned char *vb_cur; /* Current write location in vertex buffer */ - unsigned char *vb_last; /* Last written location in vertex buffer */ - unsigned char *vb_end; /* End of vertex buffer */ - void *vb_agp_handle; - GLuint vb_agp_offset; - GLboolean using_agp; - GLint coloroffset; /* Offset in vertex format of current color */ - GLint specoffset; /* Offset in vertex format of specular color */ - - GLuint NewGLState; - GLuint Fallback; - GLuint RenderIndex; - GLfloat hw_viewport[16]; - GLfloat depth_scale; - - unsigned int virtualX, virtualY; - unsigned int bytesPerPixel; - unsigned char *IOBase; - unsigned char *FbBase; - unsigned int displayWidth; - - /* HW RGBA layout */ - unsigned int redMask, greenMask, blueMask, alphaMask; - unsigned int colorFormat; - - /* Z format */ - unsigned int zFormat; - - /* Clear patterns, 4 bytes */ - unsigned int clearColorPattern; - unsigned int clearZStencilPattern; - - /* Fallback rasterization functions - */ - sis_point_func draw_point; - sis_line_func draw_line; - sis_tri_func draw_tri; - sis_quad_func draw_quad; - - GLuint hw_primitive; - GLenum raster_primitive; - GLenum render_primitive; - - /* DRM fd */ - int driFd; - - /* AGP Memory */ - unsigned int AGPSize; - unsigned char *AGPBase; - unsigned int AGPAddr; - - /* register 0x89F4 */ - GLint AGPParseSet; - - /* register 0x89F8 */ - GLint dwPrimitiveSet; - - __GLSiSHardware prev, current; - - int Chipset; - GLboolean is6326; - - GLint drawableID; - - GLint GlobalFlag; - DECLARE_RENDERINPUTS(last_tcl_state_bitset); - - /* Stereo */ - GLboolean useStereo; - GLboolean stereoEnabled; - int stereo_drawIndex; - int stereo_drawSide; - GLboolean irqEnabled; - - GLboolean clearTexCache; - - GLuint TexStates[SIS_MAX_TEXTURES]; - GLuint PrevTexFormat[SIS_MAX_TEXTURES]; - - int *CurrentQueueLenPtr; - unsigned int *FrameCountPtr; - - /* Front/back/depth buffer info */ - GLuint width, height; /* size of buffers */ - GLint bottom; /* used for FLIP macro */ - /* XXX These don't belong here. They should be per-drawable state. */ - struct sis_renderbuffer front; - struct sis_renderbuffer back; - struct sis_renderbuffer depth; - struct sis_renderbuffer stencil; /* mirrors depth */ - - /* Mirrors of some DRI state - */ - __DRIcontext *driContext; /* DRI context */ - __DRIscreen *driScreen; /* DRI screen */ - __DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */ - - unsigned int lastStamp; /* mirror driDrawable->lastStamp */ - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - - sisScreenPtr sisScreen; /* Screen private DRI data */ - SISSAREAPrivPtr sarea; /* Private SAREA data */ - - /* Configuration cache */ - driOptionCache optionCache; - GLint texture_depth; -}; - -#define SIS_CONTEXT(ctx) ((sisContextPtr)(ctx->DriverCtx)) - -/* Macros */ -#define GET_IOBase(x) ((x)->IOBase) - -#define Y_FLIP(Y) (smesa->bottom - (Y)) - -#define SISPACKCOLOR565( r, g, b ) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define SISPACKCOLOR8888( r, g, b, a ) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define SIS_VERBOSE 0 - - -#define MMIO(reg, value) \ -{\ - *(volatile GLint *)(smesa->IOBase + (reg)) = value; \ -} - -#define MMIO_READ(reg) *(volatile GLint *)(smesa->IOBase + (reg)) -#define MMIO_READf(reg) *(volatile GLfloat *)(smesa->IOBase + (reg)) - -#if defined(__i386__) || defined(__x86_64__) -#define MMIO_WMB() __asm __volatile("" : : : "memory") -#elif defined(__ia64__) -#define MMIO_WMB() __asm __volatile("mf" : : : "memory") -#else -#error platform needs WMB -#endif - -#define mEndPrimitive() \ -{ \ - *(volatile GLubyte *)(smesa->IOBase + REG_3D_EndPrimitiveList) = 0xff; \ - *(volatile GLuint *)(smesa->IOBase + 0x8b60) = 0xffffffff; \ -} - -#define sis_fatal_error(...) \ -do { \ - fprintf(stderr, "[%s:%d]:", __FILE__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - exit(-1); \ -} while (0) - -/* Lock required */ -#define mWait3DCmdQueue(wLen) \ -/* Update the mirrored queue pointer if it doesn't indicate enough space */ \ -if (*(smesa->CurrentQueueLenPtr) < (wLen)) { \ - *(smesa->CurrentQueueLenPtr) = \ - (*(GLint *)(GET_IOBase(smesa) + REG_CommandQueue) & MASK_QueueLen) - 20; \ - /* Spin and wait if the queue is actually too full */ \ - if (*(smesa->CurrentQueueLenPtr) < (wLen)) \ - WaitingFor3dIdle(smesa, wLen); \ - *(smesa->CurrentQueueLenPtr) -= wLen; \ -} - -enum _sis_verbose { - VERBOSE_SIS_BUFFER = 0x1, - VERBOSE_SIS_MEMORY = 0x2 -}; - -extern GLboolean sisCreateContext( gl_api api, - const struct gl_config *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ); -extern void sisDestroyContext( __DRIcontext * ); - -void sisReAllocateBuffers(struct gl_context *ctx, struct gl_framebuffer *drawbuffer, - GLuint width, GLuint height); - -extern GLboolean sisMakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ); - -extern GLboolean sisUnbindContext( __DRIcontext *driContextPriv ); - -void WaitEngIdle (sisContextPtr smesa); -void Wait2DEngIdle (sisContextPtr smesa); -void WaitingFor3dIdle(sisContextPtr smesa, int wLen); - -/* update to hw */ -extern void sis_update_texture_state( sisContextPtr smesa ); -extern void sis_update_render_state( sisContextPtr smesa ); -extern void sis6326_update_texture_state( sisContextPtr smesa ); -extern void sis6326_update_render_state( sisContextPtr smesa ); - -/* ================================================================ - * Debugging: - */ -#define DO_DEBUG 1 - -#if DO_DEBUG -extern int SIS_DEBUG; -#else -#define SIS_DEBUG 0 -#endif - -#define DEBUG_FALLBACKS 0x01 - -#endif /* _sis_ctx_h_ */ diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c deleted file mode 100644 index bba516f8dcd..00000000000 --- a/src/mesa/drivers/dri/sis/sis_dd.c +++ /dev/null @@ -1,265 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - * - */ - -#include "sis_context.h" -#include "sis_dd.h" -#include "sis_lock.h" -#include "sis_alloc.h" -#include "sis_span.h" -#include "sis_state.h" -#include "sis_tris.h" - -#include "main/formats.h" -#include "main/renderbuffer.h" - -#include "utils.h" - -/* Return the width and height of the given buffer. - */ -static void -sisGetBufferSize( struct gl_framebuffer *buffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - sisContextPtr smesa = SIS_CONTEXT(ctx); - - LOCK_HARDWARE(); - *width = smesa->driDrawable->w; - *height = smesa->driDrawable->h; - UNLOCK_HARDWARE(); -} - -/* Return various strings for glGetString(). - */ -static const GLubyte * -sisGetString( struct gl_context *ctx, GLenum name ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - static char buffer[128]; - unsigned offset; - GLuint agp_mode = (smesa->AGPSize > 0); - - switch ( name ) - { - case GL_VENDOR: - return (GLubyte *)"Eric Anholt"; - - case GL_RENDERER: - offset = driGetRendererString( buffer, "SiS", agp_mode ); - - return (GLubyte *)buffer; - - default: - return NULL; - } -} - -/* Send all commands to the hardware. - */ -static void -sisFlush( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - SIS_FIREVERTICES(smesa); -} - -/* Make sure all commands have been sent to the hardware and have - * completed processing. - */ -static void -sisFinish( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - SIS_FIREVERTICES(smesa); - LOCK_HARDWARE(); - WaitEngIdle( smesa ); - UNLOCK_HARDWARE(); -} - -static void -sisDeleteRenderbuffer(struct gl_renderbuffer *rb) -{ - /* Don't free() since we're contained in sis_context struct. */ -} - -static GLboolean -sisRenderbufferStorage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - rb->Width = width; - rb->Height = height; - rb->InternalFormat = internalFormat; - return GL_TRUE; -} - -static void -sisInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format) -{ - const GLuint name = 0; - - _mesa_init_renderbuffer(rb, name); - - /* Make sure we're using a null-valued GetPointer routine */ - assert(rb->GetPointer(NULL, rb, 0, 0) == NULL); - - rb->InternalFormat = format; - - if (format == GL_RGBA) { - /* Color */ - rb->Format = MESA_FORMAT_ARGB8888; - rb->DataType = GL_UNSIGNED_BYTE; - } - else if (format == GL_DEPTH_COMPONENT16) { - /* Depth */ - /* we always Get/Put 32-bit Z values */ - rb->Format = MESA_FORMAT_Z16; - rb->DataType = GL_UNSIGNED_INT; - } - else if (format == GL_DEPTH_COMPONENT24) { - /* Depth */ - /* we always Get/Put 32-bit Z values */ - rb->Format = MESA_FORMAT_Z32; - rb->DataType = GL_UNSIGNED_INT; - } - else { - /* Stencil */ - ASSERT(format == GL_STENCIL_INDEX8_EXT); - rb->Format = MESA_FORMAT_S8; - rb->DataType = GL_UNSIGNED_BYTE; - } - - rb->Delete = sisDeleteRenderbuffer; - rb->AllocStorage = sisRenderbufferStorage; -} - -void -sisUpdateBufferSize(sisContextPtr smesa) -{ - __GLSiSHardware *current = &smesa->current; - __GLSiSHardware *prev = &smesa->prev; - struct gl_framebuffer *fb = smesa->glCtx->DrawBuffer; - - if (!smesa->front.Base.InternalFormat) { - /* do one-time init for the renderbuffers */ - sisInitRenderbuffer(&smesa->front.Base, GL_RGBA); - sisSetSpanFunctions(&smesa->front, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &smesa->front.Base); - - if (fb->Visual.doubleBufferMode) { - sisInitRenderbuffer(&smesa->back.Base, GL_RGBA); - sisSetSpanFunctions(&smesa->back, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &smesa->back.Base); - } - - if (smesa->glCtx->Visual.depthBits > 0) { - sisInitRenderbuffer(&smesa->depth.Base, - (smesa->glCtx->Visual.depthBits == 16 - ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24)); - sisSetSpanFunctions(&smesa->depth, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &smesa->depth.Base); - } - - if (smesa->glCtx->Visual.stencilBits > 0) { - sisInitRenderbuffer(&smesa->stencil.Base, GL_STENCIL_INDEX8_EXT); - sisSetSpanFunctions(&smesa->stencil, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &smesa->stencil.Base); - } - } - - /* Make sure initialization did what we think it should */ - assert(smesa->front.Base.InternalFormat); - assert(smesa->front.Base.AllocStorage); - if (fb->Visual.doubleBufferMode) { - assert(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); - assert(smesa->front.Base.AllocStorage); - } - if (fb->Visual.depthBits) { - assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer); - assert(smesa->depth.Base.AllocStorage); - } - - /* XXX Should get the base offset of the frontbuffer from the X Server */ - smesa->front.offset = smesa->driDrawable->x * smesa->bytesPerPixel + - smesa->driDrawable->y * smesa->front.pitch; - smesa->front.map = (char *) smesa->driScreen->pFB + smesa->front.offset; - - if ( smesa->width == smesa->driDrawable->w && - smesa->height == smesa->driDrawable->h ) - { - return; - } - - smesa->front.bpp = smesa->bytesPerPixel * 8; - /* Front pitch set on context create */ - smesa->front.size = smesa->front.pitch * smesa->driDrawable->h; - - smesa->width = smesa->driDrawable->w; - smesa->height = smesa->driDrawable->h; - smesa->bottom = smesa->height - 1; - - if (smesa->back.offset) - sisFreeBackbuffer( smesa ); - if (smesa->depth.offset) - sisFreeZStencilBuffer( smesa ); - - if ( smesa->glCtx->Visual.depthBits > 0 ) - sisAllocZStencilBuffer( smesa ); - if ( smesa->glCtx->Visual.doubleBufferMode ) - sisAllocBackbuffer( smesa ); - - current->hwZ &= ~MASK_ZBufferPitch; - current->hwZ |= smesa->depth.pitch >> 2; - current->hwOffsetZ = smesa->depth.offset >> 2; - - if ((current->hwOffsetZ != prev->hwOffsetZ) || (current->hwZ != prev->hwZ)) { - prev->hwOffsetZ = current->hwOffsetZ; - prev->hwZ = current->hwZ; - smesa->GlobalFlag |= GFLAG_ZSETTING; - } - - sisUpdateClipping( smesa->glCtx ); -} - -/* Initialize the driver's misc functions. - */ -void -sisInitDriverFuncs( struct dd_function_table *functions ) -{ - functions->GetBufferSize = sisGetBufferSize; - functions->GetString = sisGetString; - functions->Finish = sisFinish; - functions->Flush = sisFlush; -} diff --git a/src/mesa/drivers/dri/sis/sis_dd.h b/src/mesa/drivers/dri/sis/sis_dd.h deleted file mode 100644 index b141243a59a..00000000000 --- a/src/mesa/drivers/dri/sis/sis_dd.h +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_DD_H__ -#define __SIS_DD_H__ - -extern void sisUpdateBufferSize( sisContextPtr smesa ); - -extern void sisInitDriverFuncs( struct dd_function_table *functions ); - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_fog.c b/src/mesa/drivers/dri/sis/sis_fog.c deleted file mode 100644 index a9b84654a3d..00000000000 --- a/src/mesa/drivers/dri/sis/sis_fog.c +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_context.h" -#include "sis_state.h" - -#include "main/macros.h" - -static GLint convertFtToFogFt( GLfloat dwInValue ); -static GLint doFPtoFixedNoRound( GLfloat dwInValue, int nFraction ); - -void -sisDDFogfv( struct gl_context *ctx, GLenum pname, const GLfloat *params ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - float fArg; - GLint fogColor; - - switch (pname) - { - case GL_FOG_COORDINATE_SOURCE_EXT: - current->hwFog &= ~MASK_FogMode; - switch (ctx->Fog.FogCoordinateSource) - { - case GL_FOG_COORDINATE_EXT: - current->hwFog &= ~MASK_FogZLookup; - break; - case GL_FRAGMENT_DEPTH_EXT: - current->hwFog |= MASK_FogZLookup; - break; - } - if (current->hwFog != prev->hwFog) { - prev->hwFog = current->hwFog; - smesa->GlobalFlag |= GFLAG_FOGSETTING; - } - break; - case GL_FOG_MODE: - current->hwFog &= ~MASK_FogMode; - switch (ctx->Fog.Mode) - { - case GL_LINEAR: - current->hwFog |= FOGMODE_LINEAR; - break; - case GL_EXP: - current->hwFog |= FOGMODE_EXP; - break; - case GL_EXP2: - current->hwFog |= FOGMODE_EXP2; - break; - } - if (current->hwFog != prev->hwFog) { - prev->hwFog = current->hwFog; - smesa->GlobalFlag |= GFLAG_FOGSETTING; - } - break; - case GL_FOG_DENSITY: - current->hwFogDensity = convertFtToFogFt( ctx->Fog.Density ); - if (current->hwFogDensity != prev->hwFogDensity) { - prev->hwFogDensity = current->hwFogDensity; - smesa->GlobalFlag |= GFLAG_FOGSETTING; - } - break; - case GL_FOG_START: - case GL_FOG_END: - fArg = 1.0 / (ctx->Fog.End - ctx->Fog.Start); - current->hwFogInverse = doFPtoFixedNoRound( fArg, 10 ); - if (pname == GL_FOG_END) - { - if (smesa->Chipset == PCI_CHIP_SIS300) - current->hwFogFar = doFPtoFixedNoRound( ctx->Fog.End, 10 ); - else - current->hwFogFar = doFPtoFixedNoRound( ctx->Fog.End, 6 ); - } - if (current->hwFogFar != prev->hwFogFar || - current->hwFogInverse != prev->hwFogInverse) - { - prev->hwFogFar = current->hwFogFar; - prev->hwFogInverse = current->hwFogInverse; - smesa->GlobalFlag |= GFLAG_FOGSETTING; - } - break; - case GL_FOG_INDEX: - /* TODO */ - break; - case GL_FOG_COLOR: - fogColor = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16; - fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8; - fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] ); - current->hwFog &= 0xff000000; - current->hwFog |= fogColor; - if (current->hwFog != prev->hwFog) { - prev->hwFog = current->hwFog; - smesa->GlobalFlag |= GFLAG_FOGSETTING; - } - break; - } -} - -static GLint -doFPtoFixedNoRound( GLfloat dwInValue, int nFraction ) -{ - GLint dwMantissa; - int nTemp; - union { int i; float f; } u; - GLint val; - - u.f = dwInValue; - val = u.i; - - if (val == 0) - return 0; - nTemp = (int) (val & 0x7F800000) >> 23; - nTemp = nTemp - 127 + nFraction - 23; - dwMantissa = (val & 0x007FFFFF) | 0x00800000; - - if (nTemp < -25) - return 0; - if (nTemp > 0) - dwMantissa <<= nTemp; - else { - nTemp = -nTemp; - dwMantissa >>= nTemp; - } - if (val & 0x80000000) - dwMantissa = ~dwMantissa + 1; - return dwMantissa; -} - -/* s[8].23->s[7].10 */ -static GLint -convertFtToFogFt( GLfloat dwInValue ) -{ - GLint dwMantissa, dwExp; - GLint dwRet; - union { int i; float f; } u; - GLint val; - - u.f = dwInValue; - val = u.i; - - if (val == 0) - return 0; - - /* ----- Standard float Format: s[8].23 ----- - * ----- = (-1)^S * 2^(E - 127) * (1 + M / 2^23) ----- - * ----- = (-1)^S * 2^((E-63) - 64) * (1 + (M/2^13) / 2^10) ----- - * ----- Density float Format: s[7].10 ----- - * ----- New Exponential = E - 63 ----- - * ----- New Mantissa = M / 2^13 ----- - * ----- ----- - */ - - dwExp = (val & 0x7F800000) >> 23; - dwExp -= 63; - - if (dwExp < 0) - return 0; - - if (dwExp <= 0x7F) - dwMantissa = (val & 0x007FFFFF) >> (23 - 10); - else { - /* ----- To Return +Max(or -Max) ----- */ - dwExp = 0x7F; - dwMantissa = 0x3FF; - } - - dwRet = (val & 0x80000000) >> (31 - 17); /* Shift Sign Bit */ - - dwRet |= (dwExp << 10) | dwMantissa; - - return dwRet; -} diff --git a/src/mesa/drivers/dri/sis/sis_lock.c b/src/mesa/drivers/dri/sis/sis_lock.c deleted file mode 100644 index b8ff4e31e25..00000000000 --- a/src/mesa/drivers/dri/sis/sis_lock.c +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#include "main/context.h" -#include "sis_context.h" -#include "sis_lock.h" -#include "sis_dd.h" -#include "sis_state.h" -#include "drirenderbuffer.h" - -/* 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 -sisGetLock( sisContextPtr smesa, GLuint flags ) -{ - __DRIdrawable *dPriv = smesa->driDrawable; - __DRIscreen *sPriv = smesa->driScreen; - SISSAREAPrivPtr sarea = smesa->sarea; - - drmGetLock( smesa->driFd, smesa->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( sPriv, dPriv ); - - if ( smesa->lastStamp != dPriv->lastStamp ) { - sisUpdateBufferSize( smesa ); - sisUpdateClipping( smesa->glCtx ); - if (smesa->is6326) - sis6326DDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] ); - else - sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] ); - driUpdateFramebufferSize(smesa->glCtx, dPriv); - smesa->lastStamp = dPriv->lastStamp; - } - - if ( sarea->CtxOwner != smesa->hHWContext ) { - sarea->CtxOwner = smesa->hHWContext; - smesa->GlobalFlag = GFLAG_ALL; - } -} diff --git a/src/mesa/drivers/dri/sis/sis_lock.h b/src/mesa/drivers/dri/sis/sis_lock.h deleted file mode 100644 index 54844e9b099..00000000000 --- a/src/mesa/drivers/dri/sis/sis_lock.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_LOCK_H -#define __SIS_LOCK_H - -extern void sisGetLock( sisContextPtr smesa, GLuint flags ); - -#ifdef DEBUG_LOCKING -extern char *prevLockFile; -extern int prevLockLine; -#define DEBUG_LOCK() \ - do { \ - prevLockFile=(__FILE__); \ - prevLockLine=(__LINE__); \ - } while (0) -#define DEBUG_RESET() \ - do { \ - prevLockFile=NULL; \ - prevLockLine=0; \ - } while (0) -#define DEBUG_CHECK_LOCK() \ - do { \ - if(prevLockFile){ \ - fprintf(stderr, "LOCK SET : %s:%d\n", __FILE__, __LINE__); \ - } \ - } while (0) -#else -#define DEBUG_LOCK() -#define DEBUG_RESET() -#define DEBUG_CHECK_LOCK() -#endif - -/* Lock the hardware using the global current context */ -#define LOCK_HARDWARE() \ - do { \ - char __ret=0; \ - mEndPrimitive(); \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( smesa->driHwLock, smesa->hHWContext, \ - (DRM_LOCK_HELD | smesa->hHWContext), __ret ); \ - if ( __ret != 0 ) \ - sisGetLock( smesa, 0 ); \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware using the global current context */ -#define UNLOCK_HARDWARE() \ - do { \ - mEndPrimitive(); \ - DRM_UNLOCK(smesa->driFd, smesa->driHwLock, \ - smesa->hHWContext); \ - DEBUG_RESET(); \ - } while (0) - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_reg.h b/src/mesa/drivers/dri/sis/sis_reg.h deleted file mode 100644 index e40c4371bfe..00000000000 --- a/src/mesa/drivers/dri/sis/sis_reg.h +++ /dev/null @@ -1,902 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#ifndef _sis_reg_h_ -#define _sis_reg_h_ - -/* - * Define All the Register Address of 6327 - */ -#define REG_SRC_ADDR 0x8200 -#define REG_SRC_PITCH 0x8204 -# define BLIT_DEPTH_8 0x00000000 -# define BLIT_DEPTH_15 0x40000000 -# define BLIT_DEPTH_16 0x80000000 -# define BLIT_DEPTH_32 0xc0000000 -#define REG_SRC_X_Y 0x8208 -#define REG_DST_X_Y 0x820c -#define REG_DST_ADDR 0x8210 -#define REG_DST_PITCH_HEIGHT 0x8214 -#define REG_WIDTH_HEIGHT 0x8218 -#define REG_PATFG 0x821c -#define REG_PATBG 0x8220 -#define REG_SRCFG 0x8224 -#define REG_SRCBG 0x8228 -#define REG_MONOPAT0 0x822c -#define REG_MONOPAT1 0x8230 -#define REG_CLIPLT 0x8234 -#define REG_CLIPRB 0x8238 -#define REG_BLIT_CMD 0x823c -# define CMD_ROP_PAT 0x0000f000 -# define CMD_ROP_SRC 0x0000cc00 -# define CMD_DD_ENABLE 0x00000006 -# define CMD_SRC_VIDEO 0x00000000 -# define CMD_SRC_CPU 0x00000010 -# define CMD_DIR_X_DEC 0x00000000 -# define CMD_DIR_X_INC 0x00010000 -# define CMD_DIR_Y_DEC 0x00000000 -# define CMD_DIR_Y_INC 0x00020000 - -#define REG_CommandQueue 0x8240 - -#define REG_3D_TSFSa 0x8800 -#define REG_3D_TSZa 0x8804 -#define REG_3D_TSXa 0x8808 -#define REG_3D_TSYa 0x880C -#define REG_3D_TSARGBa 0x8810 -#define REG_3D_TSWGa 0x8814 -#define REG_3D_TSUAa 0x8818 -#define REG_3D_TSVAa 0x881C -#define REG_3D_TSUBa 0x8820 -#define REG_3D_TSVBa 0x8824 -#define REG_3D_TSUCa 0x8828 -#define REG_3D_TSVCa 0x882C - -#define REG_3D_TSFSb 0x8830 -#define REG_3D_TSZb 0x8834 -#define REG_3D_TSXb 0x8838 -#define REG_3D_TSYb 0x883C -#define REG_3D_TSARGBb 0x8840 -#define REG_3D_TSWGb 0x8844 -#define REG_3D_TSUAb 0x8848 -#define REG_3D_TSVAb 0x884C -#define REG_3D_TSUBb 0x8850 -#define REG_3D_TSVBb 0x8854 -#define REG_3D_TSUCb 0x8858 -#define REG_3D_TSVCb 0x885C - -#define REG_3D_TSFSc 0x8860 -#define REG_3D_TSZc 0x8864 -#define REG_3D_TSXc 0x8868 -#define REG_3D_TSYc 0x886C -#define REG_3D_TSARGBc 0x8870 -#define REG_3D_TSWGc 0x8874 -#define REG_3D_TSUAc 0x8878 -#define REG_3D_TSVAc 0x887C -#define REG_3D_TSUBc 0x8880 -#define REG_3D_TSVBc 0x8884 -#define REG_3D_TSUCc 0x8888 -#define REG_3D_TSVCc 0x888C - -/* - * REG_3D_AGPCmdSetting (89e4h-89f7) - */ -#define REG_3D_AGPCmBase 0x89E4 -#define REG_3D_AGPRmDwNum 0x89E8 -#define REG_3D_AGPTtDwNum 0x89EC -#define REG_3D_AGPCmFire 0x89F0 - -#define REG_3D_ParsingSet 0x89F4 -#define REG_3D_PrimitiveSet 0x89F8 -#define REG_3D_ShadeMode 0x89F8 -#define REG_3D_EngineFire 0x89FC -#define REG_3D_EngineStatus 0x89FC -#define REG_3D_TEnable 0x8A00 -#define REG_3D_TEnable2 0x8A04 - -#define REG_3D_ZSet 0x8A08 -#define REG_3D_ZBias 0x8A0C -#define REG_3D_ZStWriteMask 0x8A10 - -#define REG_3D_ZAddress 0x8A14 -#define REG_3D_AlphaSet 0x8A18 -#define REG_3D_AlphaAddress 0x8A1C -#define REG_3D_DstSet 0x8A20 -#define REG_3D_DstAlphaWriteMask 0x8A24 - -#define REG_3D_DstAddress 0x8A28 - -#define REG_3D_LinePattern 0x8A2C - -#define REG_3D_FogSet 0x8A30 - -#define REG_3D_FogFarDistance 0x8A34 -#define REG_3D_FogInverseDistance 0x8A38 -#define REG_3D_FogFactorDensity 0x8A3C - -#define REG_3D_StencilSet 0x8A44 -#define REG_3D_StencilSet2 0x8A48 -#define REG_3D_StencilAddress 0x8A4C - -#define REG_3D_DstBlendMode 0x8A50 -#define REG_3D_SrcBlendMode 0x8A50 -#define REG_3D_ClipTopBottom 0x8A54 -#define REG_3D_ClipLeftRight 0x8A58 - -#define REG_3D_Brightness 0x8A5C - -#define REG_3D_BumpMapSet 0x8A68 -#define REG_3D_BumpMapAddress 0x8A6C -#define REG_3D_BumpMapPitch 0x8A70 -#define REG_3D_BumpMapMatrix0 0x8A74 -#define REG_3D_BumpMapMatrix1 0x8A78 - -/* - * Define the Texture Register Address of 6326 - */ -#define REG_3D_TextureSet 0x8A7C -#define REG_3D_TextureWidthHeight 0x8A7C -#define REG_3D_TextureMip 0x8A80 - -#define REG_3D_TextureTransparencyColorHigh 0x8A84 -#define REG_3D_TextureTransparencyColorLow 0x8A88 -#define REG_3D_TextureBorderColor 0x8A8C -#define REG_3D_TextureAddress0 0x8A90 -#define REG_3D_TextureAddress1 0x8A94 -#define REG_3D_TextureAddress2 0x8A98 -#define REG_3D_TextureAddress3 0x8A9C -#define REG_3D_TextureAddress4 0x8AA0 -#define REG_3D_TextureAddress5 0x8AA4 -#define REG_3D_TextureAddress6 0x8AA8 -#define REG_3D_TextureAddress7 0x8AAC -#define REG_3D_TextureAddress8 0x8AB0 -#define REG_3D_TextureAddress9 0x8AB4 -#define REG_3D_TextureAddress10 0x8AB8 -#define REG_3D_TextureAddress11 0x8ABC -#define REG_3D_TexturePitch0 0x8AC0 -#define REG_3D_TexturePitch1 0x8AC0 -#define REG_3D_TexturePitch2 0x8AC4 -#define REG_3D_TexturePitch3 0x8AC4 -#define REG_3D_TexturePitch4 0x8AC8 -#define REG_3D_TexturePitch5 0x8AC8 -#define REG_3D_TexturePitch6 0x8ACC -#define REG_3D_TexturePitch7 0x8ACC -#define REG_3D_TexturePitch8 0x8AD0 -#define REG_3D_TexturePitch9 0x8AD0 -#define REG_3D_TexturePitch10 0x8AD4 - -#define REG_3D_Texture1Set 0x8ADC -#define REG_3D_Texture1WidthHeight 0x8ADC -#define REG_3D_Texture1Mip 0x8AE0 - -#define REG_3D_Texture1TransparencyColorHigh 0x8AE4 -#define REG_3D_Texture1TransparencyColorLow 0x8AE8 -#define REG_3D_Texture1BorderColor 0x8AEC -#define REG_3D_Texture1Address0 0x8AF0 -#define REG_3D_Texture1Address1 0x8AF4 -#define REG_3D_Texture1Address2 0x8AF8 -#define REG_3D_Texture1Address3 0x8AFC -#define REG_3D_Texture1Address4 0x8B00 -#define REG_3D_Texture1Address5 0x8B04 -#define REG_3D_Texture1Address6 0x8B08 -#define REG_3D_Texture1Address7 0x8B0C -#define REG_3D_Texture1Address8 0x8B10 -#define REG_3D_Texture1Address9 0x8B14 -#define REG_3D_Texture1Address10 0x8B18 -#define REG_3D_Texture1Address11 0x8B1C -#define REG_3D_Texture1Pitch0 0x8B20 -#define REG_3D_Texture1Pitch1 0x8B20 -#define REG_3D_Texture1Pitch2 0x8B24 -#define REG_3D_Texture1Pitch3 0x8B24 -#define REG_3D_Texture1Pitch4 0x8B28 -#define REG_3D_Texture1Pitch5 0x8B28 -#define REG_3D_Texture1Pitch6 0x8B2C -#define REG_3D_Texture1Pitch7 0x8B2C -#define REG_3D_Texture1Pitch8 0x8B30 -#define REG_3D_Texture1Pitch9 0x8B30 -#define REG_3D_Texture1Pitch10 0x8B34 - -#define REG_3D_TextureBlendFactor 0x8B3C -#define REG_3D_TextureColorBlendSet0 0x8B40 -#define REG_3D_TextureColorBlendSet1 0x8B44 -#define REG_3D_TextureAlphaBlendSet0 0x8B48 -#define REG_3D_TextureAlphaBlendSet1 0x8B4C -/* - * Define the End of Primitive List of 6326 - */ -#define REG_3D_EndPrimitiveList 0X8B50 - - -/* - * Define the Stipple Register Address of 6326 - */ -#define REG_3D_Stipple0 0X8B60 - -#define REG_3D_TexturePalette 0x8C00 - -/* - * REG_CommandQueue -- (8240h-8243h) - */ -#define MASK_QueueLen 0x0000ffff -#define SiS_EngIdle2d 0x80000000 -#define SiS_EngIdle 0xe0000000 -#define MASK_EngState 0xf0000000 - -/* - * REG_3D_ParsingSet -- Define Parsing Mask (89F4h-89F7h) - */ -#define MASK_VertexDWSize 0xf0000000 -#define MASK_VertexDataFormat 0x0fff0000 -/* Because the original MASK_PsVertex_* names of these bits appared to be - * wrong, new names SiS_PS_* based off of the 4.3.0 driver and research are - * below. - */ -#define SiS_PS_HAS_XYZ MASK_PsVertex_HAS_RHW -#define SiS_PS_HAS_W MASK_PsVertex_HAS_NORMALXYZ -#define SiS_PS_HAS_DIFFUSE MASK_PsVertex_HAS_SPECULAR -#define SiS_PS_HAS_SPECULAR MASK_PsVertex_HAS_DIFFUSE -#define SiS_PS_HAS_UV0 MASK_PsVertex_HAS_UVSet2 -#define SiS_PS_HAS_UV1 MASK_PsVertex_HAS_UVSet3 -#define MASK_PsVertex_HAS_RHW 0x08000000 -#define MASK_PsVertex_HAS_NORMALXYZ 0x04000000 -#define MASK_PsVertex_HAS_DIFFUSE 0x02000000 -#define MASK_PsVertex_HAS_SPECULAR 0x01000000 -#define MASK_PsUVSet 0x00ff0000 -#define MASK_PsVertex_HAS_1SetUV 0x00800000 -#define MASK_PsVertex_HAS_2SetUV 0x00c00000 -#define MASK_PsVertex_HAS_3SetUV 0x00e00000 -#define MASK_PsVertex_HAS_UVSet1 0x00800000 -#define MASK_PsVertex_HAS_UVSet2 0x00400000 -#define MASK_PsVertex_HAS_UVSet3 0x00200000 -#define MASK_PsCullDirection_CCW 0x00008000 -#define MASK_PsShadingMode 0x00007000 -/* XXX Shading modes just a guess, but seem to work*/ -#define MASK_PsShadingFlatA 0x00001000 -#define MASK_PsShadingFlatB 0x00002000 -#define MASK_PsShadingFlatC 0x00003000 -#define MASK_PsShadingSmooth 0x00004000 -#define MASK_PsTextureFrom 0x000003f0 -#define MASK_PsTexture0FromA 0x00000000 -#define MASK_PsTexture1FromA 0x00000000 -#define MASK_PsTexture1FromB 0x00000040 -#define MASK_PsBumpTextureFromA 0x00000000 -#define MASK_PsBumpTextureFromB 0x00000010 -#define MASK_PsBumpTextureFromC 0x00000020 -#define MASK_PsDataType 0x0000000f -#define MASK_PsPointList 0x00000000 -#define MASK_PsLineList 0x00000004 -#define MASK_PsLineStrip 0x00000005 -#define MASK_PsTriangleList 0x00000008 -#define MASK_PsTriangleStrip 0x00000009 -#define MASK_PsTriangleFan 0x0000000a - -/* - * REG_3D_PrimitiveSet -- Define Fire Primitive Mask (89F8h-89FBh) - */ -#define MASK_DrawPrimitiveCommand 0x00000007 -#define MASK_SetFirePosition 0x00001F00 -#define MASK_BumpTextureFrom 0x00030000 -#define MASK_Texture1From 0x000C0000 -#define MASK_Texture0From 0x00300000 -#define MASK_ShadingMode 0x07000000 -#define MASK_CullDirection 0x08000000 - -#define OP_3D_POINT_DRAW 0x00000000 -#define OP_3D_LINE_DRAW 0x00000001 -#define OP_3D_TRIANGLE_DRAW 0x00000002 - -#define OP_3D_DIRECTION_RIGHT 0x00000000 -#define OP_3D_DIRECTION_LEFT 0x00000100 -#define OP_3D_DIRECTION_HORIZONTAL 0x00000000 -#define OP_3D_DIRECTION_VERTICAL 0x00000100 - -#define OP_3D_FIRE_TFIRE 0x00000000 -#define OP_3D_FIRE_TSARGBa 0x00000100 -#define OP_3D_FIRE_TSWa 0x00000200 -#define OP_3D_FIRE_TSVAa 0x00000300 -#define OP_3D_FIRE_TSVBa 0x00000400 -#define OP_3D_FIRE_TSVCa 0x00000500 - -#define OP_3D_FIRE_TSARGBb 0x00000900 -#define OP_3D_FIRE_TSWb 0x00000a00 -#define OP_3D_FIRE_TSVAb 0x00000b00 -#define OP_3D_FIRE_TSVBb 0x00000c00 -#define OP_3D_FIRE_TSVCb 0x00000d00 - -#define OP_3D_FIRE_TSARGBc 0x00001100 -#define OP_3D_FIRE_TSWc 0x00001200 -#define OP_3D_FIRE_TSVAc 0x00001300 -#define OP_3D_FIRE_TSVBc 0x00001400 -#define OP_3D_FIRE_TSVCc 0x00001500 - -#define OP_3D_Texture0FromA 0x00000000 -#define OP_3D_Texture0FromB 0x00100000 -#define OP_3D_Texture0FromC 0x00200000 -#define OP_3D_Texture1FromA 0x00000000 -#define OP_3D_Texture1FromB 0x00040000 -#define OP_3D_Texture1FromC 0x00080000 -#define OP_3D_TextureBumpFromA 0x00000000 -#define OP_3D_TextureBumpFromB 0x00010000 -#define OP_3D_TextureBumpFromC 0x00020000 - -#define OP_3D_CullDirection_CCW 0x08000000 - -#define SHADE_FLAT_VertexA 0x01000000 -#define SHADE_FLAT_VertexB 0x02000000 -#define SHADE_FLAT_VertexC 0x03000000 -#define SHADE_GOURAUD 0x04000000 - -/* - * Define Command Queue Length Mask (89FCh-89FF) - */ -#define MASK_CmdQueueLen 0x0FFF0000 - -/* - * REG_3D_TEnable -- Define Capility Enable Mask (8A00h-8A03h) - */ -#define MASK_DitherEnable 0x00000001 -#define MASK_BlendEnable 0x00000002 -#define MASK_FogTestEnable 0x00000004 -#define MASK_FogEnable 0x00000008 -#define MASK_SpecularEnable 0x00000010 -#define MASK_FogPerspectiveEnable 0x00000020 -#define MASK_TextureCacheClear 0x00000040 -#define MASK_TextureCacheEnable 0x00000080 -#define MASK_BumpMapEnable 0x00000100 -#define MASK_TexturePerspectiveEnable 0x00000200 -#define MASK_TextureEnable 0x00000400 -#define MASK_CullEnable 0x00000800 -#define MASK_TextureNumUsed 0x0000F000 -#define MASK_AlphaBufferEnable 0x00010000 -#define MASK_AlphaTestEnable 0x00020000 -#define MASK_AlphaWriteEnable 0x00040000 -#define MASK_ZTestEnable 0x00080000 -#define MASK_ZWriteEnable 0x00100000 -#define MASK_StencilBufferEnable 0x00200000 -#define MASK_StencilTestEnable 0x00400000 -#define MASK_StencilWriteEnable 0x00800000 -#define MASK_Texture0TransparencyEnable 0x01000000 -#define MASK_Texture1TransparencyEnable 0x02000000 -#define MASK_TextureAWrapUCorrection 0x04000000 -#define MASK_TextureAWrapVCorrection 0x08000000 -#define MASK_TextureBWrapUCorrection 0x10000000 -#define MASK_TextureBWrapVCorrection 0x20000000 -#define MASK_TextureCWrapUCorrection 0x40000000 -#define MASK_TextureCWrapVCorrection 0x80000000 - -/* - * REG_3D_TEnable2 -- Define Capility Enable Mask2 (8A04h-8A07h) - */ -#define MASK_Texture0BlockTextureEnable 0x00000001 -#define MASK_Texture1BlockTextureEnable 0x00000002 -#define MASK_Texture0AnisotropicEnable 0x00000010 -#define MASK_Texture1AnisotropicEnable 0x00000020 -#define MASK_TextureMipmapBiasEnable 0x00000040 -#define MASK_LinePatternEnable 0x00000100 -#define MASK_StippleAlphaEnable 0x00000200 -#define MASK_StippleEnable 0x00000400 -#define MASK_AntiAliasEnable 0x00000800 -#define MASK_ZMaskWriteEnable 0x00001000 -#define MASK_StencilMaskWriteEnable 0x00002000 -#define MASK_AlphaMaskWriteEnable 0x00004000 -#define MASK_ColorMaskWriteEnable 0x00008000 -#define MASK_ZCacheClear 0x00010000 -#define MASK_ZCacheEnable 0x00020000 -#define MASK_StencilCacheClear 0x00040000 -#define MASK_StencilCacheEnable 0x00080000 -#define MASK_AlphaCacheClear 0x00100000 -#define MASK_AlphaCacheEnable 0x00200000 -#define MASK_ColorCacheClear 0x00400000 -#define MASK_ColorCacheEnable 0x00800000 - -/* - * REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh) - */ -#define MASK_ZBufferPitch 0x00000FFF -#define MASK_ZTestMode 0x00070000 -#define MASK_ZBufferInSystem 0x00080000 -#define MASK_ZBufferFormat 0x01F00000 - -#define SiS_Z_COMP_NEVER 0x00000000 -#define SiS_Z_COMP_S_LT_B 0x00010000 -#define SiS_Z_COMP_S_EQ_B 0x00020000 -#define SiS_Z_COMP_S_LE_B 0x00030000 -#define SiS_Z_COMP_S_GT_B 0x00040000 -#define SiS_Z_COMP_S_NE_B 0x00050000 -#define SiS_Z_COMP_S_GE_B 0x00060000 -#define SiS_Z_COMP_ALWAYS 0x00070000 - -#define SiS_ZFORMAT_Z16 0x00000000 -#define SiS_ZFORMAT_Z16_INT 0x00100000 -#define SiS_ZFORMAT_S1Z15 0x00400000 -#define SiS_ZFORMAT_S1Z15_INT 0x00500000 -#define SiS_ZFORMAT_Z32 0x00800000 -#define SiS_ZFORMAT_S1Z31 0x00C00000 -#define SiS_ZFORMAT_S2Z30 0x00D00000 -#define SiS_ZFORMAT_S4Z28 0x00E00000 -#define SiS_ZFORMAT_S8Z24 0x00F00000 -#define SiS_ZFORMAT_FZ30 0x01800000 -#define SiS_ZFORMAT_FS1Z30 0x01C00000 -#define SiS_ZFORMAT_FS2Z30 0x01D00000 - -/* - * REG_3D_ZBias -- Define Z Buffer Setting Mask (8A0Ch-8A0Fh) - */ -#define MASK_ZBias 0xFFFFFFFF - -/* - * REG_3D_ZStWriteMask -- Define Z and Stencil Buffer Mask (8A10h-8A13h) - */ -#define MASK_ZWriteMask 0x00FFFFFF - -/* - * REG_3D_ZAddress -- Define Z Buffer Base Address(8A14h-8A17h) - */ -#define MASK_ZAddress 0xFFFFFFFF - -/* - * REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A18h-8A1Bh) - */ -#define MASK_AlphaBufferPitch 0x000003FF -#define MASK_AlphaRefValue 0x00FF0000 -#define MASK_AlphaTestMode 0x07000000 -#define MASK_AlphaBufferInSystem 0x08000000 -#define MASK_AlphaBufferFormat 0x30000000 - -#define SiS_ALPHA_NEVER 0x00000000 -#define SiS_ALPHA_LESS 0x01000000 -#define SiS_ALPHA_EQUAL 0x02000000 -#define SiS_ALPHA_LEQUAL 0x03000000 -#define SiS_ALPHA_GREATER 0x04000000 -#define SiS_ALPHA_NOTEQUAL 0x05000000 -#define SiS_ALPHA_GEQUAL 0x06000000 -#define SiS_ALPHA_ALWAYS 0x07000000 - -/* - * REG_3D_AlphaAddress -- Define Alpha Buffer Base Address(8A1Ch-8A1Fh) - */ -#define MASK_AlphaAddress 0xFFFFFFFF - -/* - * REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A20h-8A23h) - */ -#define MASK_DstBufferPitch 0x00000FFF -#define MASK_DstBufferFormat 0x000F0000 -#define MASK_DstBufferBitDepth 0x00300000 -#define MASK_DstBufferRgbOrder 0x00400000 -#define MASK_DstBufferInSystem 0x00800000 -#define MASK_Dst7BitFormat 0x007F0000 -#define MASK_ROP2 0x0F000000 - -#define DST_FORMAT_RGB_555 0x00100000 -#define DST_FORMAT_RGB_565 0x00110000 -#define DST_FORMAT_ARGB_1555 0x00120000 -#define DST_FORMAT_ARGB_4444 0x00130000 -#define DST_FORMAT_ARGB_1888 0x00300000 -#define DST_FORMAT_ARGB_2888 0x00310000 -#define DST_FORMAT_ARGB_4888 0x00320000 -#define DST_FORMAT_ARGB_8888 0x00330000 -#define DST_FORMAT_ARGB_0888 0x00340000 - -#define DST_FORMAT_BGR_555 0x00500000 -#define DST_FORMAT_BGR_565 0x00510000 -#define DST_FORMAT_ABGR_1555 0x00520000 -#define DST_FORMAT_ABGR_4444 0x00530000 -#define DST_FORMAT_ABGR_1888 0x00700000 -#define DST_FORMAT_ABGR_2888 0x00710000 -#define DST_FORMAT_ABGR_4888 0x00720000 -#define DST_FORMAT_ABGR_8888 0x00730000 -#define DST_FORMAT_ABGR_0888 0x00740000 - -#define LOP_CLEAR 0x00000000 -#define LOP_NOR 0x01000000 -#define LOP_AND_INVERTED 0x02000000 -#define LOP_COPY_INVERTED 0x03000000 -#define LOP_AND_REVERSE 0x04000000 -#define LOP_INVERT 0x05000000 -#define LOP_XOR 0x06000000 -#define LOP_NAND 0x07000000 -#define LOP_AND 0x08000000 -#define LOP_EQUIV 0x09000000 -#define LOP_NOOP 0x0a000000 -#define LOP_OR_INVERTED 0x0b000000 -#define LOP_COPY 0x0c000000 -#define LOP_OR_REVERSE 0x0d000000 -#define LOP_OR 0x0e000000 -#define LOP_SET 0x0f000000 - -/* - * REG_3D_DstAlphaWriteMask -- Define Destination/Alpha Buffer Write Mask (8A24h-8A27h) - */ -#define MASK_ColorWriteMask 0x00FFFFFF -#define MASK_AlphaWriteMask 0xFF000000 - -/* - * REG_3D_DstAddress -- Define Destination Buffer Base Address(8A1Ch-8A1Fh) - */ -#define MASK_DstAddress 0xFFFFFFFF - -/* - * REG_3D_LinePattern -- Define Line Pattern (8A2Ch-8A2Fh) - */ -#define MASK_LinePatternRepeatFactor 0x00007FFF -#define MASK_LinePatternLastPixelFlag 0x00008000 -#define MASK_LinePattern 0xFFFF0000 - -/* - * REG_3D_FogSet -- Define Fog Mask (8A30h-8A33h) - */ -#define MASK_FogColor 0x00FFFFFF -#define MASK_FogMode 0x07000000 -#define MASK_FogZLookup 0x08000000 - -#define FOGMODE_CHEAP 0x04000000 -#define FOGMODE_LINEAR 0x05000000 -#define FOGMODE_EXP 0x06000000 -#define FOGMODE_EXP2 0x07000000 - -/* - * REG_3D_FogStartEnd -- Define Fog Start End Setting (0x8A34 - 0x8A37) - */ -#define MASK_FogFarDistance 0x0007FFFF - -/* - * REG_3D_FogStartEnd -- Define Fog End Setting (0x8A38 - 0x8A3B) - */ -#define MASK_FogInvFarDistance 0x0007FFFF - -/* - * REG_3D_FogFactorDensity (0x8A3C - 0x8A3F) - */ -#define MASK_FogDensity 0x0003FFFF -#define MASK_FogFactor 0xFF000000 - -/* - * REG_3D_StencilSet -- Define stencil test (8A44h-8A47h) - */ -#define MASK_StencilValueMask 0x000000ff -#define MASK_StencilRefMask 0x0000ff00 -#define MASK_StencilTestMode 0x07000000 -#define MASK_StencilBufferInSystem 0x08000000 -#define MASK_StencilFormat 0x30000000 - -#define SiS_STENCIL_NEVER 0x00000000 -#define SiS_STENCIL_LESS 0x01000000 -#define SiS_STENCIL_EQUAL 0x02000000 -#define SiS_STENCIL_LEQUAL 0x03000000 -#define SiS_STENCIL_GREATER 0x04000000 -#define SiS_STENCIL_NOTEQUAL 0x05000000 -#define SiS_STENCIL_GEQUAL 0x06000000 -#define SiS_STENCIL_ALWAYS 0x07000000 - -#define STENCIL_FORMAT_1 0x00000000 -#define STENCIL_FORMAT_2 0x10000000 -#define STENCIL_FORMAT_4 0x20000000 -#define STENCIL_FORMAT_8 0x30000000 - -/* - * REG_3D_StencilSet2 -- Define stencil test (8A4h-8A47h) - */ -#define MASK_StencilBufferPitch 0x00000FFF -#define MASK_StencilZPassOp 0x00007000 -#define MASK_StencilZFailOp 0x00070000 -#define MASK_StencilFailOp 0x00700000 -#define MASK_StencilWriteMask 0xFF000000 - -#define SiS_SFAIL_KEEP 0x00000000 -#define SiS_SFAIL_ZERO 0x00100000 -#define SiS_SFAIL_REPLACE 0x00200000 -#define SiS_SFAIL_INCR 0x00300000 /* guess -- was _WRAP */ -#define SiS_SFAIL_DECR 0x00400000 /* guess -- was _WRAP */ -#define SiS_SFAIL_INVERT 0x00500000 -#define SiS_SFAIL_INCR_WRAP 0x00600000 /* guess */ -#define SiS_SFAIL_DECR_WRAP 0x00700000 /* guess */ - -#define SiS_SPASS_ZFAIL_KEEP 0x00000000 -#define SiS_SPASS_ZFAIL_ZERO 0x00010000 -#define SiS_SPASS_ZFAIL_REPLACE 0x00020000 -#define SiS_SPASS_ZFAIL_INCR 0x00030000 /* guess -- was _WRAP */ -#define SiS_SPASS_ZFAIL_DECR 0x00040000 /* guess -- was _WRAP */ -#define SiS_SPASS_ZFAIL_INVERT 0x00050000 -#define SiS_SPASS_ZFAIL_INCR_WRAP 0x00060000 /* guess */ -#define SiS_SPASS_ZFAIL_DECR_WRAP 0x00070000 /* guess */ - -#define SiS_SPASS_ZPASS_KEEP 0x00000000 -#define SiS_SPASS_ZPASS_ZERO 0x00001000 -#define SiS_SPASS_ZPASS_REPLACE 0x00002000 -#define SiS_SPASS_ZPASS_INCR 0x00003000 /* guess -- was _WRAP */ -#define SiS_SPASS_ZPASS_DECR 0x00004000 /* guess -- was _WRAP */ -#define SiS_SPASS_ZPASS_INVERT 0x00005000 -#define SiS_SPASS_ZPASS_INCR_WRAP 0x00006000 /* guess */ -#define SiS_SPASS_ZPASS_DECR_WRAP 0x00007000 /* guess */ - -/* - * REG_3D_DstBlendMode (0x8A50 - 0x8A53) - */ -#define MASK_SrcBlendMode 0x0000000F -#define MASK_DstBlendMode 0x000000F0 - -#define SiS_D_ZERO 0x00000000 -#define SiS_D_ONE 0x00000010 -#define SiS_D_SRC_COLOR 0x00000020 -#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030 -#define SiS_D_SRC_ALPHA 0x00000040 -#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050 -#define SiS_D_DST_ALPHA 0x00000060 -#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070 -#define SiS_D_DST_COLOR 0x00000080 -#define SiS_D_ONE_MINUS_DST_COLOR 0x00000090 -#define SiS_D_SRC_ALPHA_SAT 0x000000a0 - -#define SiS_S_ZERO 0x00000000 -#define SiS_S_ONE 0x00000001 -#define SiS_S_SRC_COLOR 0x00000002 -#define SiS_S_ONE_MINUS_SRC_COLOR 0x00000003 -#define SiS_S_SRC_ALPHA 0x00000004 -#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005 -#define SiS_S_DST_ALPHA 0x00000006 -#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007 -#define SiS_S_DST_COLOR 0x00000008 -#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009 -#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a -#define SiS_S_BOTH_SRC_ALPHA 0x0000000b -#define SiS_S_BOTH_ONE_MINUS_SRC_ALPHA 0x0000000c - -/* - * REG_3D_ClipTopBottom (0x8A54 - 0x8A57) - */ -#define MASK_BottomClip 0x00001FFF -#define MASK_TopClip 0x03FFE000 - -/* - * REG_3D_ClipLeftRight (0x8A58 - 0x8A5B) - */ -#define MASK_RightClip 0x00001FFF -#define MASK_LeftClip 0x03FFE000 - -/* - * REG_3D_TextureSet (0x8A7C - 0x8A7F) - * REG_3D_Texture1Set (0x8ADC - 0x8ADF) - */ -#define MASK_TextureHeight 0x0000000F -#define MASK_TextureWidth 0x000000F0 -#define MASK_TextureLevel 0x00000F00 -#define MASK_TextureSignYUVFormat 0x00001000 -#define MASK_TextureMappingMode 0x00FF0000 -#define MASK_TextureWrapU 0x00010000 -#define MASK_TextureWrapV 0x00020000 -#define MASK_TextureMirrorU 0x00040000 -#define MASK_TextureMirrorV 0x00080000 -#define MASK_TextureClampU 0x00100000 -#define MASK_TextureClampV 0x00200000 -#define MASK_TextureBorderU 0x00400000 -#define MASK_TextureBorderV 0x00800000 -#define MASK_TextureFormat 0xFF000000 -#define MASK_TextureBitDepth 0x70000000 -#define MASK_TextureRgbOrder 0x80000000 - -#define TEXEL_INDEX1 0x00000000 -#define TEXEL_INDEX2 0x01000000 -#define TEXEL_INDEX4 0x02000000 -#define TEXEL_INDEX8 0x03000000 - -#define TEXEL_INDEX1WithAlpha 0x04000000 -#define TEXEL_INDEX2WithAlpha 0x05000000 -#define TEXEL_INDEX4WithAlpha 0x06000000 -#define TEXEL_INDEX8WithAlpha 0x07000000 - -#define TEXEL_I1 0x10000000 -#define TEXEL_I2 0x11000000 -#define TEXEL_I4 0x12000000 -#define TEXEL_I8 0x13000000 - -#define TEXEL_DXT1 0x19000000 -#define TEXEL_DXT2 0x1A000000 -#define TEXEL_DXT3 0x1B000000 - -#define TEXEL_YUV422 0x20000000 -#define TEXEL_YVU422 0x21000000 -#define TEXEL_UVY422 0x22000000 -#define TEXEL_VUY422 0x23000000 -#define TEXEL_YUV411 0x24000000 - -#define TEXEL_L1 0x30000000 -#define TEXEL_L2 0x31000000 -#define TEXEL_L4 0x32000000 -#define TEXEL_L8 0x33000000 - -#define TEXEL_AL11 0x34000000 -#define TEXEL_AL44 0x35000000 -#define TEXEL_AL26 0x37000000 -#define TEXEL_AL88 0x38000000 - -#define TEXEL_A1 0x40000000 -#define TEXEL_A2 0x41000000 -#define TEXEL_A4 0x42000000 -#define TEXEL_A8 0x43000000 - -#define TEXEL_RGB_332_8 0x50000000 -#define TEXEL_RGB_233_8 0x51000000 -#define TEXEL_RGB_232_8 0x52000000 -#define TEXEL_ARGB_1232_8 0x53000000 -#define TEXEL_ARGB_2222_8 0x54000000 - -#define TEXEL_RGB_555_16 0x60000000 -#define TEXEL_RGB_565_16 0x61000000 -#define TEXEL_ARGB_1555_16 0x62000000 -#define TEXEL_ARGB_4444_16 0x63000000 - -#define TEXEL_ARGB_1888_32 0x70000000 -#define TEXEL_ARGB_2888_32 0x71000000 -#define TEXEL_ARGB_4888_32 0x72000000 -#define TEXEL_ARGB_8888_32 0x73000000 -#define TEXEL_ARGB_0888_32 0x74000000 - -#define TEXEL_BGR_332_8 0xD0000000 -#define TEXEL_BGR_233_8 0xD1000000 -#define TEXEL_BGR_232_8 0xD2000000 -#define TEXEL_ABGR_1232_8 0xD3000000 -#define TEXEL_ABGR_2222_8 0xD4000000 - -#define TEXEL_BGR_555_16 0xE0000000 -#define TEXEL_BGR_565_16 0xE1000000 -#define TEXEL_ABGR_1555_16 0xE2000000 -#define TEXEL_ABGR_4444_16 0xE3000000 - -#define TEXEL_ABGR_1888_32 0xF0000000 -#define TEXEL_ABGR_2888_32 0xF1000000 -#define TEXEL_ABGR_4888_32 0xF2000000 -#define TEXEL_ABGR_8888_32 0xF3000000 -#define TEXEL_ABGR_0888_32 0xF4000000 - -#define TEXEL_VU88 0x00000000 -#define TEXEL_LVU655 0x00800000 -#define TEXEL_LVU888 0x01000000 -#define TEXEL_UV88 0x02000000 -#define TEXEL_LUV655 0x02800000 -#define TEXEL_LUV888 0x03000000 - -/* - * REG_3D_TextureMip (0x8A80 - 0x8A83) - * REG_3D_Texture1Mip (0x8AE0 - 0x8AE3) - */ -#define MASK_TextureAnisotropyRatio 0x0000000F -#define MASK_TextureMipmapLodBias 0x00003FF0 -#define MASK_TextureFilterMin 0x0001C000 -#define MASK_TextureFilterMag 0x00020000 -#define MASK_TextureFilter 0x0003C000 -#define MASK_TextureLevelInSystem 0x3FFC0000 -#define MASK_TextureLevel0InSystem 0x00040000 -#define MASK_TextureBlockLength 0xF0000000 - -#define TEXTURE_FILTER_NEAREST 0x00000000 -#define TEXTURE_FILTER_LINEAR 0x00004000 -#define TEXTURE_FILTER_NEAREST_MIP_NEAREST 0x00008000 -#define TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x00010000 -#define TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x0000c000 -#define TEXTURE_FILTER_LINEAR_MIP_LINEAR 0x00014000 - -/* - * REG_3D_TextureTransparencyColorHigh (0x8A84 - 0x8A87) - * REG_3D_Texture1TransparencyColorHigh (0x8AE4 - 0x8AE7) - */ -#define MASK_TextureTransparencyColorHighB 0x000000FF -#define MASK_TextureTransparencyColorHighG 0x0000FF00 -#define MASK_TextureTransparencyColorHighR 0x00FF0000 -#define MASK_TextureAlphaTransparencyMode 0x08000000 - -/* - * REG_3D_TextureTransparencyColorLow (0x8A88 - 0x8A8B) - * REG_3D_Texture1TransparencyColorLow (0x8AE8 - 0x8AEB) - */ -#define MASK_TextureTransparencyColorLowB 0x000000FF -#define MASK_TextureTransparencyColorLowG 0x0000FF00 -#define MASK_TextureTransparencyColorLowR 0x00FF0000 -#define MASK_TextureBlockHeight 0x07000000 -#define MASK_TextureBlockWidth 0x70000000 - -/* - * REG_3D_TextureTransparencyColorLow (0x8A8C - 0x8A8F) - * REG_3D_Texture1TransparencyColorLow (0x8AEC - 0x8AEF) - */ -#define MASK_TextureBorderColorB 0x000000FF -#define MASK_TextureBorderColorG 0x0000FF00 -#define MASK_TextureBorderColorR 0x00FF0000 -#define MASK_TextureBorderColorA 0xFF000000 - -/* - * REG_3D_TexturePitch0-10 (0x8AC0 - 0x8AD7) - * REG_3D_Texture1Pitch0-10 (0x8B20 - 0x8B37) - */ -#define MASK_TexturePitchOdd 0x000003FF -#define MASK_TexturePitchEven 0x03FF0000 -#define SHIFT_TexturePitchEven 16 - -/* - * REG_3D_TextureColorBlendSet0 (0x8B40 - 0x8B43) - * REG_3D_TextureColorBlendSet1 (0x8B44 - 0x8B46) - * REG_3D_TextureAlphaBlendSet0 (0x8B40 - 0x8B43) - * REG_3D_TextureAlphaBlendSet1 (0x8B44 - 0x8B46) - */ -#define STAGE0_C_CF 0xa1485000 -#define STAGE0_C_CS 0xc1485000 -#define STAGE0_C_CFCS 0xa1705000 -#define STAGE0_C_CFOMAS_CSAS 0xc534c001 -#define STAGE0_C_CFOMCS_CCCS 0x4530c001 - -#define STAGE0_A_AF 0x63230000 -#define STAGE0_A_AS 0xc3230000 -#define STAGE0_A_AFAS 0x63c30000 -#define STAGE0_A_AFOMAS_ACAS 0x46c60001 - -#define STAGE1_C_CF 0xa1485000 -#define STAGE1_C_CS 0xe1485000 -#define STAGE1_C_CFCS 0xa1785000 -#define STAGE1_C_CFOMAS_CSAS 0xe5394001 -#define STAGE1_C_CFOMCS_CCCS 0x45394001 - -#define STAGE1_A_AF 0xa3230000 -#define STAGE1_A_AS 0xe3230000 -#define STAGE1_A_AFAS 0xa3e30000 -#define STAGE1_A_AFOMAS_ACAS 0x4aea0001 - -/* What registers are these associated with? */ -#define MASK_BMMemoryInSystem 0x00000080 -#define MASK_BMHeight 0x00000F00 -#define MASK_BMWidth 0x0000F000 -#define MASK_BMFilter 0x00010000 -#define MASK_BMMappingMode 0x007E0000 -#define MASK_BMFormat 0x07800000 -#define MASK_BMTxBumpmap 0x08000000 - -#define MASK_BMAddress 0xFFFFFFFC - -#define MASK_BMOffset 0xFF800000 -#define MASK_BMScale 0x007FE000 -#define MASK_BMPitch 0x00001FFF - -#define MASK_BMMatrix00 0x000007FF -#define MASK_BMMatrix01 0x07FF0000 -#define MASK_BMMatrix10 0x000007FF -#define MASK_BMMatrix11 0x07FF0000 - -#define MASK_TextureRealInSystem 0x00000001 -#define MASK_TextureDowngrade 0x00000002 - -#define ALPHA_BUFFER_FORMAT_1 0x00000000 -#define ALPHA_BUFFER_FORMAT_2 0x10000000 -#define ALPHA_BUFFER_FORMAT_4 0x20000000 -#define ALPHA_BUFFER_FORMAT_8 0x30000000 - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c deleted file mode 100644 index 75f6fcf2116..00000000000 --- a/src/mesa/drivers/dri/sis/sis_screen.c +++ /dev/null @@ -1,333 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#include "dri_util.h" - -#include "main/context.h" -#include "utils.h" -#include "main/imports.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" - -#include "sis_context.h" -#include "sis_dri.h" -#include "sis_lock.h" - -#include "xmlpool.h" - -#include "GL/internal/dri_interface.h" - -#define SIS_AGP_DISABLE(def) \ -DRI_CONF_OPT_BEGIN(agp_disable,bool,def) \ - DRI_CONF_DESC(en,"Disable AGP vertex dispatch") \ -DRI_CONF_OPT_END - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_QUALITY - DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - SIS_AGP_DISABLE(true) - DRI_CONF_NO_RAST(false) - DRI_CONF_SECTION_END -DRI_CONF_END; -static const GLuint __driNConfigOptions = 3; - -extern const struct dri_extension card_extensions[]; - -static const __DRIconfig ** -sisFillInModes(__DRIscreen *psp, int bpp) -{ - __DRIconfig **configs; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML - }; - uint8_t depth_bits_array[4]; - uint8_t stencil_bits_array[4]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = 0; - stencil_bits_array[0] = 0; - depth_bits_array[1] = 16; - stencil_bits_array[1] = 0; - depth_bits_array[2] = 24; - stencil_bits_array[2] = 8; - depth_bits_array[3] = 32; - stencil_bits_array[3] = 0; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = 4; - back_buffer_factor = 2; - - if (bpp == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, depth_bits_array, - stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__); - return NULL; - } - - return (const __DRIconfig **) configs; -} - - -/* Create the device specific screen private data struct. - */ -static sisScreenPtr -sisCreateScreen( __DRIscreen *sPriv ) -{ - sisScreenPtr sisScreen; - SISDRIPtr sisDRIPriv = (SISDRIPtr)sPriv->pDevPriv; - - if (sPriv->devPrivSize != sizeof(SISDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(SISDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - sisScreen = (sisScreenPtr)CALLOC( sizeof(*sisScreen) ); - if ( sisScreen == NULL ) - return NULL; - - sisScreen->screenX = sisDRIPriv->width; - sisScreen->screenY = sisDRIPriv->height; - sisScreen->cpp = sisDRIPriv->bytesPerPixel; - sisScreen->deviceID = sisDRIPriv->deviceID; - sisScreen->AGPCmdBufOffset = sisDRIPriv->AGPCmdBufOffset; - sisScreen->AGPCmdBufSize = sisDRIPriv->AGPCmdBufSize; - sisScreen->sarea_priv_offset = sizeof(drm_sarea_t); - - sisScreen->mmio.handle = sisDRIPriv->regs.handle; - sisScreen->mmio.size = sisDRIPriv->regs.size; - if ( drmMap( sPriv->fd, sisScreen->mmio.handle, sisScreen->mmio.size, - &sisScreen->mmio.map ) ) - { - FREE( sisScreen ); - return NULL; - } - - if (sisDRIPriv->agp.size) { - sisScreen->agp.handle = sisDRIPriv->agp.handle; - sisScreen->agpBaseOffset = drmAgpBase(sPriv->fd); - sisScreen->agp.size = sisDRIPriv->agp.size; - if ( drmMap( sPriv->fd, sisScreen->agp.handle, sisScreen->agp.size, - &sisScreen->agp.map ) ) - { - sisScreen->agp.size = 0; - } - } - - sisScreen->driScreen = sPriv; - - /* parse information in __driConfigOptions */ - driParseOptionInfo(&sisScreen->optionCache, - __driConfigOptions, __driNConfigOptions); - - return sisScreen; -} - -/* Destroy the device specific screen private data struct. - */ -static void -sisDestroyScreen( __DRIscreen *sPriv ) -{ - sisScreenPtr sisScreen = (sisScreenPtr)sPriv->private; - - if ( sisScreen == NULL ) - return; - - if (sisScreen->agp.size != 0) - drmUnmap( sisScreen->agp.map, sisScreen->agp.size ); - drmUnmap( sisScreen->mmio.map, sisScreen->mmio.size ); - - FREE( sisScreen ); - sPriv->private = NULL; -} - - -/* Create and initialize the Mesa and driver specific pixmap buffer - * data. - */ -static GLboolean -sisCreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap ) -{ - /*sisScreenPtr screen = (sisScreenPtr) driScrnPriv->private;*/ - struct gl_framebuffer *fb; - - if (isPixmap) - return GL_FALSE; /* not implemented */ - - fb = _mesa_create_framebuffer(mesaVis); - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); -} - - -static void -sisDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -static void sisCopyBuffer( __DRIdrawable *dPriv ) -{ - sisContextPtr smesa = (sisContextPtr)dPriv->driContextPriv->driverPrivate; - int i; - - while ((*smesa->FrameCountPtr) - MMIO_READ(0x8a2c) > SIS_MAX_FRAME_LENGTH) - ; - - LOCK_HARDWARE(); - - for (i = 0; i < dPriv->numClipRects; i++) { - drm_clip_rect_t *box = &dPriv->pClipRects[i]; - - mWait3DCmdQueue(10); - MMIO(REG_SRC_ADDR, smesa->back.offset); - MMIO(REG_SRC_PITCH, smesa->back.pitch | ((smesa->bytesPerPixel == 4) ? - BLIT_DEPTH_32 : BLIT_DEPTH_16)); - MMIO(REG_SRC_X_Y, ((box->x1 - dPriv->x) << 16) | (box->y1 - dPriv->y)); - MMIO(REG_DST_X_Y, ((box->x1 - dPriv->x) << 16) | (box->y1 - dPriv->y)); - MMIO(REG_DST_ADDR, smesa->front.offset); - MMIO(REG_DST_PITCH_HEIGHT, (smesa->virtualY << 16) | smesa->front.pitch); - MMIO(REG_WIDTH_HEIGHT, ((box->y2 - box->y1) << 16) | (box->x2 - box->x1)); - MMIO(REG_BLIT_CMD, CMD_DIR_X_INC | CMD_DIR_Y_INC | CMD_ROP_SRC); - MMIO(REG_CommandQueue, -1); - } - - *(GLint *)(smesa->IOBase+0x8a2c) = *smesa->FrameCountPtr; - (*smesa->FrameCountPtr)++; - - UNLOCK_HARDWARE (); -} - - -/* Copy the back color buffer to the front color buffer */ -static void -sisSwapBuffers(__DRIdrawable *dPriv) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - sisContextPtr smesa = (sisContextPtr) dPriv->driContextPriv->driverPrivate; - struct gl_context *ctx = smesa->glCtx; - - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - sisCopyBuffer( dPriv ); - } - } else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__); - } -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -sisInitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = {0, 8, 0}; - static const __DRIversion dri_expected = {4, 0, 0}; - static const __DRIversion drm_expected = {1, 0, 0}; - static const char *driver_name = "SiS"; - SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv; - - if (!driCheckDriDdxDrmVersions2(driver_name, - &psp->dri_version, &dri_expected, - &psp->ddx_version, &ddx_expected, - &psp->drm_version, &drm_expected)) - return NULL; - - psp->private = sisCreateScreen(psp); - - if (!psp->private) { - sisDestroyScreen(psp); - return NULL; - } - - return sisFillInModes(psp, dri_priv->bytesPerPixel * 8); -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = sisInitScreen, - .DestroyScreen = sisDestroyScreen, - .CreateContext = sisCreateContext, - .DestroyContext = sisDestroyContext, - .CreateBuffer = sisCreateBuffer, - .DestroyBuffer = sisDestroyBuffer, - .SwapBuffers = sisSwapBuffers, - .MakeCurrent = sisMakeCurrent, - .UnbindContext = sisUnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = NULL, - .WaitForMSC = NULL, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL - -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/sis/sis_screen.h b/src/mesa/drivers/dri/sis/sis_screen.h deleted file mode 100644 index 8009fecc31f..00000000000 --- a/src/mesa/drivers/dri/sis/sis_screen.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_SCREEN_H -#define __SIS_SCREEN_H - -typedef struct { - drm_handle_t handle; /* Handle to the DRM region */ - drmSize size; /* Size of the DRM region */ - drmAddress map; /* Mapping of the DRM region */ -} sisRegionRec2, *sisRegionPtr2; - -typedef struct { - sisRegionRec2 mmio; - sisRegionRec2 agp; - unsigned long agpBaseOffset; - - unsigned int AGPCmdBufOffset; - unsigned int AGPCmdBufSize; - - int deviceID; - - int cpp; - unsigned int screenX, screenY; - - __DRIscreen *driScreen; - unsigned int sarea_priv_offset; - - /* Configuration cache with default values for all contexts */ - driOptionCache optionCache; - -} sisScreenRec, *sisScreenPtr; - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_span.c b/src/mesa/drivers/dri/sis/sis_span.c deleted file mode 100644 index 01c1fc428da..00000000000 --- a/src/mesa/drivers/dri/sis/sis_span.c +++ /dev/null @@ -1,197 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_context.h" -#include "sis_span.h" -#include "sis_lock.h" -#include "sis_tris.h" - -#include "swrast/swrast.h" - -#define DBG 0 - -#define LOCAL_VARS \ - sisContextPtr smesa = SIS_CONTEXT(ctx); \ - __DRIdrawable *dPriv = smesa->driDrawable; \ - struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \ - GLuint pitch = srb->pitch; \ - char *buf = srb->map; \ - GLuint p; \ - (void) buf; (void) p; - - -#define LOCAL_DEPTH_VARS \ - sisContextPtr smesa = SIS_CONTEXT(ctx); \ - __DRIdrawable *dPriv = smesa->driDrawable; \ - struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \ - char *buf = srb->map; - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define HW_LOCK() do {} while(0); - -#define HW_UNLOCK() do {} while(0); - -/* RGB565 */ -#define SPANTMP_PIXEL_FMT GL_RGB -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 - -#define TAG(x) sis##x##_RGB565 -#define TAG2(x,y) sis##x##_RGB565##y -#include "spantmp2.h" - - -/* ARGB8888 */ -/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque. - Was there a reason to do so ? If so that'll won't work with that template... */ -#define SPANTMP_PIXEL_FMT GL_BGRA -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV - -#define TAG(x) sis##x##_ARGB8888 -#define TAG2(x,y) sis##x##_ARGB8888##y -#include "spantmp2.h" - - -/* 16 bit depthbuffer functions. - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d; - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch); - -#define TAG(x) sis##x##_z16 -#include "depthtmp.h" - - -/* 32 bit depthbuffer functions. - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d; - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch); - -#define TAG(x) sis##x##_z32 -#include "depthtmp.h" - - -/* 8/24 bit interleaved depth/stencil functions - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch); \ - tmp &= 0xff000000; \ - tmp |= (d & 0x00ffffff); \ - *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \ -} - -#define READ_DEPTH( d, _x, _y ) { \ - d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0x00ffffff; \ -} - -#define TAG(x) sis##x##_z24_s8 -#include "depthtmp.h" - -#define WRITE_STENCIL( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depth.pitch); \ - tmp &= 0x00ffffff; \ - tmp |= (d << 24); \ - *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \ -} - -#define READ_STENCIL( d, _x, _y ) \ - d = (*(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0xff000000) >> 24; - -#define TAG(x) sis##x##_z24_s8 -#include "stenciltmp.h" - - - -void sisSpanRenderStart( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - SIS_FIREVERTICES(smesa); - LOCK_HARDWARE(); - WaitEngIdle( smesa ); -} - -void sisSpanRenderFinish( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - _swrast_flush( ctx ); - UNLOCK_HARDWARE(); -} - -void -sisDDInitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = sisSpanRenderStart; - swdd->SpanRenderFinish = sisSpanRenderFinish; -} - - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -sisSetSpanFunctions(struct sis_renderbuffer *srb, const struct gl_config *vis) -{ - if (srb->Base.Format == MESA_FORMAT_RGB565) { - sisInitPointers_RGB565( &srb->Base ); - } - else if (srb->Base.Format == MESA_FORMAT_ARGB8888) { - sisInitPointers_ARGB8888( &srb->Base ); - } - else if (srb->Base.Format == MESA_FORMAT_Z16) { - sisInitDepthPointers_z16(&srb->Base); - } - else if (srb->Base.Format == MESA_FORMAT_S8_Z24) { - sisInitDepthPointers_z24_s8(&srb->Base); - } - else if (srb->Base.Format == MESA_FORMAT_Z32) { - sisInitDepthPointers_z32(&srb->Base); - } - else if (srb->Base.Format == MESA_FORMAT_S8) { - sisInitStencilPointers_z24_s8(&srb->Base); - } -} diff --git a/src/mesa/drivers/dri/sis/sis_span.h b/src/mesa/drivers/dri/sis/sis_span.h deleted file mode 100644 index cbe4bbdc551..00000000000 --- a/src/mesa/drivers/dri/sis/sis_span.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_SPAN_H__ -#define __SIS_SPAN_H__ - -#include "drirenderbuffer.h" - - -extern void sisSpanRenderStart( struct gl_context *ctx ); -extern void sisSpanRenderFinish( struct gl_context *ctx ); - -extern void sisDDInitSpanFuncs( struct gl_context *ctx ); - -extern void -sisSetSpanFunctions(struct sis_renderbuffer *srb, const struct gl_config *vis); - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c deleted file mode 100644 index 828772ed6ef..00000000000 --- a/src/mesa/drivers/dri/sis/sis_state.c +++ /dev/null @@ -1,864 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_context.h" -#include "sis_state.h" -#include "sis_tris.h" -#include "sis_lock.h" - -#include "main/context.h" -#include "main/macros.h" -#include "main/state.h" -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "swrast_setup/swrast_setup.h" - - -/* ============================================================= - * Alpha blending - */ - -static void -sisDDAlphaFunc( struct gl_context * ctx, GLenum func, GLfloat ref ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLubyte refbyte; - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - CLAMPED_FLOAT_TO_UBYTE(refbyte, ref); - current->hwAlpha = refbyte << 16; - - /* Alpha Test function */ - switch (func) - { - case GL_NEVER: - current->hwAlpha |= SiS_ALPHA_NEVER; - break; - case GL_LESS: - current->hwAlpha |= SiS_ALPHA_LESS; - break; - case GL_EQUAL: - current->hwAlpha |= SiS_ALPHA_EQUAL; - break; - case GL_LEQUAL: - current->hwAlpha |= SiS_ALPHA_LEQUAL; - break; - case GL_GREATER: - current->hwAlpha |= SiS_ALPHA_GREATER; - break; - case GL_NOTEQUAL: - current->hwAlpha |= SiS_ALPHA_NOTEQUAL; - break; - case GL_GEQUAL: - current->hwAlpha |= SiS_ALPHA_GEQUAL; - break; - case GL_ALWAYS: - current->hwAlpha |= SiS_ALPHA_ALWAYS; - break; - } - - prev->hwAlpha = current->hwAlpha; - smesa->GlobalFlag |= GFLAG_ALPHASETTING; -} - -static void -sisDDBlendFuncSeparate( struct gl_context *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - current->hwDstSrcBlend = 0; - - switch (dfactorRGB) - { - case GL_ZERO: - current->hwDstSrcBlend |= SiS_D_ZERO; - break; - case GL_ONE: - current->hwDstSrcBlend |= SiS_D_ONE; - break; - case GL_SRC_COLOR: - current->hwDstSrcBlend |= SiS_D_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_COLOR; - break; - case GL_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_D_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_COLOR: - current->hwDstSrcBlend |= SiS_D_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_COLOR; - break; - case GL_DST_ALPHA: - current->hwDstSrcBlend |= SiS_D_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_ALPHA; - break; - default: - fprintf(stderr, "Unknown dst blend function 0x%x\n", dfactorRGB); - break; - } - - switch (sfactorRGB) - { - case GL_ZERO: - current->hwDstSrcBlend |= SiS_S_ZERO; - break; - case GL_ONE: - current->hwDstSrcBlend |= SiS_S_ONE; - break; - case GL_SRC_COLOR: - current->hwDstSrcBlend |= SiS_S_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_COLOR; - break; - case GL_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_S_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_COLOR: - current->hwDstSrcBlend |= SiS_S_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_COLOR; - break; - case GL_DST_ALPHA: - current->hwDstSrcBlend |= SiS_S_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - current->hwDstSrcBlend |= SiS_S_SRC_ALPHA_SATURATE; - break; - default: - fprintf(stderr, "Unknown src blend function 0x%x\n", sfactorRGB); - break; - } - - if (current->hwDstSrcBlend != prev->hwDstSrcBlend) { - prev->hwDstSrcBlend = current->hwDstSrcBlend; - smesa->GlobalFlag |= GFLAG_DSTBLEND; - } -} - -/* ============================================================= - * Depth testing - */ - -static void -sisDDDepthFunc( struct gl_context * ctx, GLenum func ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - current->hwZ &= ~MASK_ZTestMode; - switch (func) - { - case GL_LESS: - current->hwZ |= SiS_Z_COMP_S_LT_B; - break; - case GL_GEQUAL: - current->hwZ |= SiS_Z_COMP_S_GE_B; - break; - case GL_LEQUAL: - current->hwZ |= SiS_Z_COMP_S_LE_B; - break; - case GL_GREATER: - current->hwZ |= SiS_Z_COMP_S_GT_B; - break; - case GL_NOTEQUAL: - current->hwZ |= SiS_Z_COMP_S_NE_B; - break; - case GL_EQUAL: - current->hwZ |= SiS_Z_COMP_S_EQ_B; - break; - case GL_ALWAYS: - current->hwZ |= SiS_Z_COMP_ALWAYS; - break; - case GL_NEVER: - current->hwZ |= SiS_Z_COMP_NEVER; - break; - } - - if (current->hwZ != prev->hwZ) { - prev->hwZ = current->hwZ; - smesa->GlobalFlag |= GFLAG_ZSETTING; - } -} - -void -sisDDDepthMask( struct gl_context * ctx, GLboolean flag ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if (!ctx->Depth.Test) - flag = GL_FALSE; - - if (ctx->Visual.stencilBits) { - if (flag || (ctx->Stencil.WriteMask[0] != 0)) { - current->hwCapEnable |= MASK_ZWriteEnable; - if (flag && ((ctx->Stencil.WriteMask[0] & 0xff) == 0xff)) { - current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable; - } else { - current->hwCapEnable2 |= MASK_ZMaskWriteEnable; - current->hwZMask = (ctx->Stencil.WriteMask[0] << 24) | - ((flag) ? 0x00ffffff : 0); - - if (current->hwZMask ^ prev->hwZMask) { - prev->hwZMask = current->hwZMask; - smesa->GlobalFlag |= GFLAG_ZSETTING; - } - } - } else { - current->hwCapEnable &= ~MASK_ZWriteEnable; - } - } else { - if (flag) { - current->hwCapEnable |= MASK_ZWriteEnable; - current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable; - } else { - current->hwCapEnable &= ~MASK_ZWriteEnable; - } - } -} - -/* ============================================================= - * Clipping - */ - -void -sisUpdateClipping( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - GLint x1, y1, x2, y2; - - if (smesa->is6326) { - /* XXX: 6326 has its own clipping for now. Should be fixed */ - sis6326UpdateClipping(ctx); - return; - } - - x1 = 0; - y1 = 0; - x2 = smesa->width - 1; - y2 = smesa->height - 1; - - if (ctx->Scissor.Enabled) { - if (ctx->Scissor.X > x1) - x1 = ctx->Scissor.X; - if (ctx->Scissor.Y > y1) - y1 = ctx->Scissor.Y; - if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2) - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2) - y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1; - } - - y1 = Y_FLIP(y1); - y2 = Y_FLIP(y2); - - current->clipTopBottom = (y2 << 13) | y1; - current->clipLeftRight = (x1 << 13) | x2; - - if ((current->clipTopBottom ^ prev->clipTopBottom) || - (current->clipLeftRight ^ prev->clipLeftRight)) - { - prev->clipTopBottom = current->clipTopBottom; - prev->clipLeftRight = current->clipLeftRight; - smesa->GlobalFlag |= GFLAG_CLIPPING; - } -} - -static void -sisDDScissor( struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) -{ - if (ctx->Scissor.Enabled) - sisUpdateClipping( ctx ); -} - -/* ============================================================= - * Culling - */ - -static void -sisUpdateCull( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLint cullflag, frontface; - - cullflag = ctx->Polygon.CullFaceMode; - frontface = ctx->Polygon.FrontFace; - - smesa->AGPParseSet &= ~(MASK_PsCullDirection_CCW); - smesa->dwPrimitiveSet &= ~(MASK_CullDirection); - - if((cullflag == GL_FRONT && frontface == GL_CCW) || - (cullflag == GL_BACK && frontface == GL_CW)) - { - smesa->AGPParseSet |= MASK_PsCullDirection_CCW; - smesa->dwPrimitiveSet |= OP_3D_CullDirection_CCW; - } -} - - -static void -sisDDCullFace( struct gl_context *ctx, GLenum mode ) -{ - sisUpdateCull( ctx ); -} - -static void -sisDDFrontFace( struct gl_context *ctx, GLenum mode ) -{ - sisUpdateCull( ctx ); -} - -/* ============================================================= - * Masks - */ - -static void sisDDColorMask( struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if (r && g && b && ((ctx->Visual.alphaBits == 0) || a)) { - current->hwCapEnable2 &= ~(MASK_AlphaMaskWriteEnable | - MASK_ColorMaskWriteEnable); - } else { - current->hwCapEnable2 |= (MASK_AlphaMaskWriteEnable | - MASK_ColorMaskWriteEnable); - - current->hwDstMask = (r) ? smesa->redMask : 0 | - (g) ? smesa->greenMask : 0 | - (b) ? smesa->blueMask : 0 | - (a) ? smesa->alphaMask : 0; - } - - if (current->hwDstMask != prev->hwDstMask) { - prev->hwDstMask = current->hwDstMask; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } -} - -/* ============================================================= - * Rendering attributes - */ - -static void sisUpdateSpecular(struct gl_context *ctx) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &smesa->current; - - if (_mesa_need_secondary_color(ctx)) - current->hwCapEnable |= MASK_SpecularEnable; - else - current->hwCapEnable &= ~MASK_SpecularEnable; -} - -static void sisDDLightModelfv(struct gl_context *ctx, GLenum pname, - const GLfloat *param) -{ - if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { - sisUpdateSpecular(ctx); - } -} - -static void sisDDShadeModel( struct gl_context *ctx, GLenum mode ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */ - smesa->hw_primitive = -1; -} - -/* ============================================================= - * Window position - */ - -/* ============================================================= - * Viewport - */ - -static void sisCalcViewport( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = smesa->hw_viewport; - - /* See also sis_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] + smesa->driDrawable->h + SUBPIXEL_Y; - m[MAT_SZ] = v[MAT_SZ] * smesa->depth_scale; - m[MAT_TZ] = v[MAT_TZ] * smesa->depth_scale; -} - -static void sisDDViewport( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - sisCalcViewport( ctx ); -} - -static void sisDDDepthRange( struct gl_context *ctx, - GLclampd nearval, GLclampd farval ) -{ - sisCalcViewport( ctx ); -} - -/* ============================================================= - * Miscellaneous - */ - -static void -sisDDLogicOpCode( struct gl_context *ctx, GLenum opcode ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - current->hwDstSet &= ~MASK_ROP2; - switch (opcode) - { - case GL_CLEAR: - current->hwDstSet |= LOP_CLEAR; - break; - case GL_SET: - current->hwDstSet |= LOP_SET; - break; - case GL_COPY: - current->hwDstSet |= LOP_COPY; - break; - case GL_COPY_INVERTED: - current->hwDstSet |= LOP_COPY_INVERTED; - break; - case GL_NOOP: - current->hwDstSet |= LOP_NOOP; - break; - case GL_INVERT: - current->hwDstSet |= LOP_INVERT; - break; - case GL_AND: - current->hwDstSet |= LOP_AND; - break; - case GL_NAND: - current->hwDstSet |= LOP_NAND; - break; - case GL_OR: - current->hwDstSet |= LOP_OR; - break; - case GL_NOR: - current->hwDstSet |= LOP_NOR; - break; - case GL_XOR: - current->hwDstSet |= LOP_XOR; - break; - case GL_EQUIV: - current->hwDstSet |= LOP_EQUIV; - break; - case GL_AND_REVERSE: - current->hwDstSet |= LOP_AND_REVERSE; - break; - case GL_AND_INVERTED: - current->hwDstSet |= LOP_AND_INVERTED; - break; - case GL_OR_REVERSE: - current->hwDstSet |= LOP_OR_REVERSE; - break; - case GL_OR_INVERTED: - current->hwDstSet |= LOP_OR_INVERTED; - break; - } - - if (current->hwDstSet ^ prev->hwDstSet) { - prev->hwDstSet = current->hwDstSet; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } -} - -void sisDDDrawBuffer( struct gl_context *ctx, GLenum mode ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - current->hwDstSet &= ~MASK_DstBufferPitch; - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); - current->hwOffsetDest = smesa->front.offset >> 1; - current->hwDstSet |= smesa->front.pitch >> 2; - break; - case BUFFER_BACK_LEFT: - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); - current->hwOffsetDest = smesa->back.offset >> 1; - current->hwDstSet |= smesa->back.pitch >> 2; - break; - default: - FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - if (current->hwDstSet != prev->hwDstSet) { - prev->hwDstSet = current->hwDstSet; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } - - if (current->hwOffsetDest != prev->hwOffsetDest) { - prev->hwOffsetDest = current->hwOffsetDest; - smesa->GlobalFlag |= GFLAG_DESTSETTING; - } -} - -/* ============================================================= - * Polygon stipple - */ - -/* ============================================================= - * Render mode - */ - -/* ============================================================= - * State enable/disable - */ - -static void -sisDDEnable( struct gl_context * ctx, GLenum cap, GLboolean state ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *current = &smesa->current; - - switch (cap) - { - case GL_ALPHA_TEST: - if (state) - current->hwCapEnable |= MASK_AlphaTestEnable; - else - current->hwCapEnable &= ~MASK_AlphaTestEnable; - break; - case GL_BLEND: - /* TODO: */ - if (state) - /* if (state & !ctx->Color.ColorLogicOpEnabled) */ - current->hwCapEnable |= MASK_BlendEnable; - else - current->hwCapEnable &= ~MASK_BlendEnable; - break; - case GL_CULL_FACE: - if (state) - current->hwCapEnable |= MASK_CullEnable; - else - current->hwCapEnable &= ~MASK_CullEnable; - break; - case GL_DEPTH_TEST: - if (state && smesa->depth.offset != 0) - current->hwCapEnable |= MASK_ZTestEnable; - else - current->hwCapEnable &= ~MASK_ZTestEnable; - sisDDDepthMask( ctx, ctx->Depth.Mask ); - break; - case GL_DITHER: - if (state) - current->hwCapEnable |= MASK_DitherEnable; - else - current->hwCapEnable &= ~MASK_DitherEnable; - break; - case GL_FOG: - if (state) - current->hwCapEnable |= MASK_FogEnable; - else - current->hwCapEnable &= ~MASK_FogEnable; - break; - case GL_COLOR_LOGIC_OP: - if (state) - sisDDLogicOpCode( ctx, ctx->Color.LogicOp ); - else - sisDDLogicOpCode( ctx, GL_COPY ); - break; - case GL_SCISSOR_TEST: - sisUpdateClipping( ctx ); - break; - case GL_STENCIL_TEST: - if (state) { - if (smesa->zFormat != SiS_ZFORMAT_S8Z24) - FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1); - else - current->hwCapEnable |= (MASK_StencilTestEnable | - MASK_StencilWriteEnable); - } else { - FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0); - current->hwCapEnable &= ~(MASK_StencilTestEnable | - MASK_StencilWriteEnable); - } - break; - case GL_LIGHTING: - case GL_COLOR_SUM_EXT: - sisUpdateSpecular(ctx); - break; - } -} - - -/* ============================================================= - * State initialization, management - */ - -/* Called before beginning of rendering. */ -void -sisUpdateHWState( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - /* enable setting 1 */ - if (current->hwCapEnable ^ prev->hwCapEnable) { - prev->hwCapEnable = current->hwCapEnable; - smesa->GlobalFlag |= GFLAG_ENABLESETTING; - } - - /* enable setting 2 */ - if (current->hwCapEnable2 ^ prev->hwCapEnable2) { - prev->hwCapEnable2 = current->hwCapEnable2; - smesa->GlobalFlag |= GFLAG_ENABLESETTING2; - } - - if (smesa->GlobalFlag & GFLAG_RENDER_STATES) - sis_update_render_state( smesa ); - - if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES) - sis_update_texture_state( smesa ); -} - -static void -sisDDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - smesa->NewGLState |= new_state; -} - -/* Initialize the context's hardware state. - */ -void sisDDInitState( sisContextPtr smesa ) -{ - __GLSiSHardware *current = &smesa->current; - __GLSiSHardware *prev = &(smesa->prev); - struct gl_context *ctx = smesa->glCtx; - - /* add Texture Perspective Enable */ - prev->hwCapEnable = MASK_FogPerspectiveEnable | MASK_TextureCacheEnable | - MASK_TexturePerspectiveEnable | MASK_DitherEnable; - - /* - prev->hwCapEnable2 = 0x00aa0080; - */ - /* if multi-texture enabled, disable Z pre-test */ - prev->hwCapEnable2 = MASK_TextureMipmapBiasEnable; - - /* Z test mode is LESS */ - prev->hwZ = SiS_Z_COMP_S_LT_B; - - /* Depth mask */ - prev->hwZMask = 0xffffffff; - - /* Alpha test mode is ALWAYS, alpha ref value is 0 */ - prev->hwAlpha = SiS_ALPHA_ALWAYS; - - /* ROP2 is COPYPEN */ - prev->hwDstSet = LOP_COPY; - - /* color mask */ - prev->hwDstMask = 0xffffffff; - - /* LinePattern is 0, Repeat Factor is 0 */ - prev->hwLinePattern = 0x00008000; - - /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */ - prev->hwDstSrcBlend = SiS_S_ONE | SiS_D_ZERO; - - /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */ - prev->hwStSetting = STENCIL_FORMAT_8 | SiS_STENCIL_ALWAYS | 0xff; - /* Op is KEEP for all three operations */ - prev->hwStSetting2 = SiS_SFAIL_KEEP | SiS_SPASS_ZFAIL_KEEP | - SiS_SPASS_ZPASS_KEEP; - - /* Texture mapping mode is Tile */ -#if 0 - prev->texture[0].hwTextureSet = 0x00030000; -#endif - /* Magnified & minified texture filter is NEAREST */ -#if 0 - prev->texture[0].hwTextureMip = 0; -#endif - - /* Texture Blending setting -- use fragment color/alpha*/ - prev->hwTexBlendColor0 = STAGE0_C_CF; - prev->hwTexBlendColor1 = STAGE1_C_CF; - prev->hwTexBlendAlpha0 = STAGE0_A_AF; - prev->hwTexBlendAlpha1 = STAGE1_A_AF; - - switch (smesa->bytesPerPixel) - { - case 2: - prev->hwDstSet |= DST_FORMAT_RGB_565; - break; - case 4: - prev->hwDstSet |= DST_FORMAT_ARGB_8888; - break; - } - - switch (ctx->Visual.depthBits) - { - case 0: - prev->hwCapEnable &= ~MASK_ZWriteEnable; - case 16: - smesa->zFormat = SiS_ZFORMAT_Z16; - prev->hwCapEnable |= MASK_ZWriteEnable; - smesa->depth_scale = 1.0 / (GLfloat)0xffff; - break; - case 32: - smesa->zFormat = SiS_ZFORMAT_Z32; - prev->hwCapEnable |= MASK_ZWriteEnable; - smesa->depth_scale = 1.0 / (GLfloat)0xffffffff; - break; - case 24: - assert (ctx->Visual.stencilBits); - smesa->zFormat = SiS_ZFORMAT_S8Z24; - prev->hwCapEnable |= MASK_StencilBufferEnable; - prev->hwCapEnable |= MASK_ZWriteEnable; - smesa->depth_scale = 1.0 / (GLfloat)0xffffff; - break; - } - - prev->hwZ |= smesa->zFormat; - - /* TODO: need to clear cache? */ - smesa->clearTexCache = GL_TRUE; - - smesa->clearColorPattern = 0; - - smesa->AGPParseSet = MASK_PsTexture1FromB | MASK_PsBumpTextureFromC; - smesa->dwPrimitiveSet = OP_3D_Texture1FromB | OP_3D_TextureBumpFromC; - - sisUpdateZStencilPattern( smesa, 1.0, 0 ); - sisUpdateCull( ctx ); - - memcpy( current, prev, sizeof (__GLSiSHardware) ); - - /* Set initial fog settings. Start and end are the same case. */ - sisDDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); - sisDDFogfv( ctx, GL_FOG_END, &ctx->Fog.End ); - sisDDFogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL ); - sisDDFogfv( ctx, GL_FOG_MODE, NULL ); -} - -/* Initialize the driver's state functions. - */ -void sisDDInitStateFuncs( struct gl_context *ctx ) -{ - ctx->Driver.UpdateState = sisDDInvalidateState; - - ctx->Driver.Clear = sisDDClear; - ctx->Driver.ClearColor = sisDDClearColor; - ctx->Driver.ClearDepth = sisDDClearDepth; - ctx->Driver.ClearStencil = sisDDClearStencil; - - ctx->Driver.AlphaFunc = sisDDAlphaFunc; - ctx->Driver.BlendFuncSeparate = sisDDBlendFuncSeparate; - ctx->Driver.ColorMask = sisDDColorMask; - ctx->Driver.CullFace = sisDDCullFace; - ctx->Driver.DepthMask = sisDDDepthMask; - ctx->Driver.DepthFunc = sisDDDepthFunc; - ctx->Driver.DepthRange = sisDDDepthRange; - ctx->Driver.DrawBuffer = sisDDDrawBuffer; - ctx->Driver.Enable = sisDDEnable; - ctx->Driver.FrontFace = sisDDFrontFace; - ctx->Driver.Fogfv = sisDDFogfv; - ctx->Driver.Hint = NULL; - ctx->Driver.Lightfv = NULL; - ctx->Driver.LogicOpcode = sisDDLogicOpCode; - ctx->Driver.PolygonMode = NULL; - ctx->Driver.PolygonStipple = NULL; - ctx->Driver.ReadBuffer = NULL; - ctx->Driver.RenderMode = NULL; - ctx->Driver.Scissor = sisDDScissor; - ctx->Driver.ShadeModel = sisDDShadeModel; - ctx->Driver.LightModelfv = sisDDLightModelfv; - ctx->Driver.Viewport = sisDDViewport; - - /* XXX this should go away */ - ctx->Driver.ResizeBuffers = sisReAllocateBuffers; -} diff --git a/src/mesa/drivers/dri/sis/sis_state.h b/src/mesa/drivers/dri/sis/sis_state.h deleted file mode 100644 index dcade4a9796..00000000000 --- a/src/mesa/drivers/dri/sis/sis_state.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_STATE_H__ -#define __SIS_STATE_H__ - -#include "sis_context.h" - -/* sis6326_clear.c */ -extern void sis6326DDClear( struct gl_context *ctx, GLbitfield mask ); -extern void sis6326DDClearColor( struct gl_context * ctx, const GLfloat color[4] ); -extern void sis6326DDClearDepth( struct gl_context * ctx, GLclampd d ); -extern void sis6326UpdateZPattern(sisContextPtr smesa, GLclampd z); - -/* sis_clear.c */ -extern void sisDDClear( struct gl_context *ctx, GLbitfield mask ); -extern void sisDDClearColor( struct gl_context * ctx, const GLfloat color[4] ); -extern void sisDDClearDepth( struct gl_context * ctx, GLclampd d ); -extern void sisDDClearStencil( struct gl_context * ctx, GLint s ); -extern void sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z, - int stencil ); - -/* sis_fog.c */ -extern void sisDDFogfv( struct gl_context * ctx, GLenum pname, const GLfloat * params ); - -/* sis6326_state.c */ -extern void sis6326DDInitState( sisContextPtr smesa ); -extern void sis6326DDInitStateFuncs( struct gl_context *ctx ); -extern void sis6326UpdateClipping( struct gl_context * gc ); -extern void sis6326DDDrawBuffer( struct gl_context *ctx, GLenum mode ); -extern void sis6326UpdateHWState( struct gl_context *ctx ); - -/* sis_state.c */ -extern void sisDDInitState( sisContextPtr smesa ); -extern void sisDDInitStateFuncs( struct gl_context *ctx ); -extern void sisDDDepthMask( struct gl_context * ctx, GLboolean flag ); -extern void sisUpdateClipping( struct gl_context * gc ); -extern void sisDDDrawBuffer( struct gl_context *ctx, GLenum mode ); -extern void sisUpdateHWState( struct gl_context *ctx ); - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_stencil.c b/src/mesa/drivers/dri/sis/sis_stencil.c deleted file mode 100644 index 92eb08f31fb..00000000000 --- a/src/mesa/drivers/dri/sis/sis_stencil.c +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "sis_context.h" -#include "sis_state.h" -#include "sis_stencil.h" - -static void -sisDDStencilFuncSeparate( struct gl_context * ctx, GLenum face, - GLenum func, GLint ref, GLuint mask ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - /* set reference */ - current->hwStSetting = (STENCIL_FORMAT_8 | - ((ctx->Stencil.Ref[0] & 0xff) << 8) | - (ctx->Stencil.ValueMask[0] & 0xff)); - - switch (func) - { - case GL_NEVER: - current->hwStSetting |= SiS_STENCIL_NEVER; - break; - case GL_LESS: - current->hwStSetting |= SiS_STENCIL_LESS; - break; - case GL_EQUAL: - current->hwStSetting |= SiS_STENCIL_EQUAL; - break; - case GL_LEQUAL: - current->hwStSetting |= SiS_STENCIL_LEQUAL; - break; - case GL_GREATER: - current->hwStSetting |= SiS_STENCIL_GREATER; - break; - case GL_NOTEQUAL: - current->hwStSetting |= SiS_STENCIL_NOTEQUAL; - break; - case GL_GEQUAL: - current->hwStSetting |= SiS_STENCIL_GEQUAL; - break; - case GL_ALWAYS: - current->hwStSetting |= SiS_STENCIL_ALWAYS; - break; - } - - if (current->hwStSetting != prev->hwStSetting) - { - prev->hwStSetting = current->hwStSetting; - - smesa->GlobalFlag |= GFLAG_STENCILSETTING; - } -} - -static void -sisDDStencilMaskSeparate( struct gl_context * ctx, GLenum face, GLuint mask ) -{ - if (!ctx->Visual.stencilBits) - return; - - /* set Z buffer Write Enable */ - sisDDDepthMask (ctx, ctx->Depth.Mask); -} - -static void -sisDDStencilOpSeparate( struct gl_context * ctx, GLenum face, GLenum fail, - GLenum zfail, GLenum zpass ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - current->hwStSetting2 &= ~(MASK_StencilZPassOp | MASK_StencilZFailOp | - MASK_StencilFailOp); - - switch (fail) - { - case GL_KEEP: - current->hwStSetting2 |= SiS_SFAIL_KEEP; - break; - case GL_ZERO: - current->hwStSetting2 |= SiS_SFAIL_ZERO; - break; - case GL_REPLACE: - current->hwStSetting2 |= SiS_SFAIL_REPLACE; - break; - case GL_INVERT: - current->hwStSetting2 |= SiS_SFAIL_INVERT; - break; - case GL_INCR: - current->hwStSetting2 |= SiS_SFAIL_INCR; - break; - case GL_DECR: - current->hwStSetting2 |= SiS_SFAIL_DECR; - break; - case GL_INCR_WRAP: - current->hwStSetting2 |= SiS_SFAIL_INCR_WRAP; - break; - case GL_DECR_WRAP: - current->hwStSetting2 |= SiS_SFAIL_DECR_WRAP; - break; - } - - switch (zfail) - { - case GL_KEEP: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_KEEP; - break; - case GL_ZERO: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_ZERO; - break; - case GL_REPLACE: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_REPLACE; - break; - case GL_INVERT: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_INVERT; - break; - case GL_INCR: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_INCR; - break; - case GL_DECR: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_DECR; - break; - case GL_INCR_WRAP: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_INCR_WRAP; - break; - case GL_DECR_WRAP: - current->hwStSetting2 |= SiS_SPASS_ZFAIL_DECR_WRAP; - break; - } - - switch (zpass) - { - case GL_KEEP: - current->hwStSetting2 |= SiS_SPASS_ZPASS_KEEP; - break; - case GL_ZERO: - current->hwStSetting2 |= SiS_SPASS_ZPASS_ZERO; - break; - case GL_REPLACE: - current->hwStSetting2 |= SiS_SPASS_ZPASS_REPLACE; - break; - case GL_INVERT: - current->hwStSetting2 |= SiS_SPASS_ZPASS_INVERT; - break; - case GL_INCR: - current->hwStSetting2 |= SiS_SPASS_ZPASS_INCR; - break; - case GL_DECR: - current->hwStSetting2 |= SiS_SPASS_ZPASS_DECR; - break; - case GL_INCR_WRAP: - current->hwStSetting2 |= SiS_SPASS_ZPASS_INCR_WRAP; - break; - case GL_DECR_WRAP: - current->hwStSetting2 |= SiS_SPASS_ZPASS_DECR_WRAP; - break; - } - - if (current->hwStSetting2 != prev->hwStSetting2) - { - prev->hwStSetting2 = current->hwStSetting2; - smesa->GlobalFlag |= GFLAG_STENCILSETTING; - } -} - -void -sisDDInitStencilFuncs( struct gl_context *ctx ) -{ - ctx->Driver.StencilFuncSeparate = sisDDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = sisDDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = sisDDStencilOpSeparate; -} diff --git a/src/mesa/drivers/dri/sis/sis_stencil.h b/src/mesa/drivers/dri/sis/sis_stencil.h deleted file mode 100644 index 9d061e87fd7..00000000000 --- a/src/mesa/drivers/dri/sis/sis_stencil.h +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_STENCIL_H__ -#define __SIS_STENCIL_H__ - -extern void sisDDInitStencilFuncs( struct gl_context *ctx ); - -#endif diff --git a/src/mesa/drivers/dri/sis/sis_tex.c b/src/mesa/drivers/dri/sis/sis_tex.c deleted file mode 100644 index bb4896d9bdf..00000000000 --- a/src/mesa/drivers/dri/sis/sis_tex.c +++ /dev/null @@ -1,568 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#include "swrast/swrast.h" -#include "main/imports.h" -#include "main/texstore.h" -#include "main/texobj.h" - -#include "sis_context.h" -#include "sis_alloc.h" -#include "sis_tex.h" -#include "xmlpool.h" - -#define ALIGN(value, align) (GLubyte *)((long)(value + align - 1) & ~(align - 1)) - -#define TEXTURE_HW_ALIGNMENT 4 -#define TEXTURE_HW_PLUS (4 + 4) - -static sisTexObjPtr -sisAllocTexObj( struct gl_texture_object *texObj ) -{ - sisTexObjPtr t; - - t = (sisTexObjPtr) CALLOC_STRUCT( sis_tex_obj ); - texObj->DriverData = t; - return t; -} - -static void -sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level, - const struct gl_texture_image *image ) -{ - char *addr; - int size, texel_size; - - if (t->format == 0) { - t->format = image->_BaseFormat; - switch (image->TexFormat) - { - case MESA_FORMAT_ARGB8888: - t->hwformat = TEXEL_ARGB_8888_32; - break; - case MESA_FORMAT_ARGB4444: - t->hwformat = TEXEL_ARGB_4444_16; - break; - case MESA_FORMAT_ARGB1555: - t->hwformat = TEXEL_ARGB_1555_16; - break; - case MESA_FORMAT_RGB565: - t->hwformat = TEXEL_RGB_565_16; - break; - case MESA_FORMAT_RGB332: - t->hwformat = TEXEL_RGB_332_8; - break; - case MESA_FORMAT_I8: - t->hwformat = TEXEL_I8; - break; - case MESA_FORMAT_A8: - t->hwformat = TEXEL_A8; - break; - case MESA_FORMAT_L8: - t->hwformat = TEXEL_L8; - break; - case MESA_FORMAT_AL88: - t->hwformat = TEXEL_AL88; - break; - case MESA_FORMAT_YCBCR: - t->hwformat = TEXEL_YUV422; - break; - case MESA_FORMAT_YCBCR_REV: - t->hwformat = TEXEL_VUY422; - break; - default: - sis_fatal_error("Bad texture format 0x%x.\n", image->TexFormat); - } - } - assert(t->format == image->_BaseFormat); - - texel_size = _mesa_get_format_bytes(image->TexFormat); - size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS; - - addr = sisAllocFB( smesa, size, &t->image[level].handle ); - if (addr == NULL) { - addr = sisAllocAGP( smesa, size, &t->image[level].handle ); - if (addr == NULL) - sis_fatal_error("Failure to allocate texture memory.\n"); - t->image[level].memType = AGP_TYPE; - } - else - t->image[level].memType = VIDEO_TYPE; - - t->image[level].Data = ALIGN(addr, TEXTURE_HW_ALIGNMENT); - t->image[level].pitch = image->Width * texel_size; - t->image[level].size = image->Width * image->Height * texel_size; - t->numImages++; -} - -static void -sisFreeTexImage( sisContextPtr smesa, sisTexObjPtr t, int level ) -{ - assert(level >= 0); - assert(level < SIS_MAX_TEXTURE_LEVELS); - if (t->image[level].Data == NULL) - return; - - switch (t->image[level].memType) - { - case VIDEO_TYPE: - sisFreeFB( smesa, t->image[level].handle ); - break; - case AGP_TYPE: - sisFreeAGP( smesa, t->image[level].handle ); - break; - } - t->image[level].Data = NULL; - t->image[level].handle = NULL; - /* If there are no textures loaded any more, reset the hw format so the - * object can be reused for new formats - */ - t->numImages--; - if (t->numImages == 0) { - t->format = 0; - t->hwformat = 0; - } -} - -static void -sisTexEnv( struct gl_context *ctx, GLenum target, GLenum pname, const GLfloat *param ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; -} - -static void -sisTexParameter( struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj, GLenum pname, - const GLfloat *params ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - -static void -sisBindTexture( struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - sisTexObjPtr t; - - if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) { - if ( texObj->DriverData == NULL ) { - sisAllocTexObj( texObj ); - } - } - - t = texObj->DriverData; - if (!t) - return; - - if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) { - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format; - } - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - -static void -sisDeleteTexture( struct gl_context * ctx, struct gl_texture_object *texObj ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - sisTexObjPtr t; - int i; - - smesa->clearTexCache = GL_TRUE; - - t = texObj->DriverData; - if (t == NULL) { - /* - * this shows the texture is default object and never be a - * argument of sisTexImage* - */ - return; - } - for (i = 0; i < SIS_MAX_TEXTURE_LEVELS; i++) { - sisFreeTexImage( smesa, t, i ); - } - - FREE(t); - texObj->DriverData = NULL; - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, texObj); -} - -static GLboolean sisIsTextureResident( struct gl_context * ctx, - struct gl_texture_object *texObj ) -{ - return (texObj->DriverData != NULL); -} - -static gl_format -sisChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - const GLboolean do32bpt = - (smesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32); - const GLboolean force16bpt = - (smesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16); - - switch ( internalFormat ) { - case 4: - case GL_RGBA: - case GL_COMPRESSED_RGBA: - switch ( type ) { - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555; - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return MESA_FORMAT_ARGB4444; - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return MESA_FORMAT_ARGB1555; - default: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - } - - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - switch ( type ) { - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return MESA_FORMAT_ARGB4444; - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return MESA_FORMAT_ARGB1555; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - return MESA_FORMAT_RGB565; - default: - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - } - - case GL_RGBA8: - case GL_RGBA12: - case GL_RGBA16: - return !force16bpt ? - MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - - case GL_RGB10_A2: - return !force16bpt ? - MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555; - - case GL_RGBA4: - case GL_RGBA2: - return MESA_FORMAT_ARGB4444; - - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - - case GL_RGB5: - case GL_RGB4: - return MESA_FORMAT_RGB565; - - case GL_R3_G3_B2: - return MESA_FORMAT_RGB332; - - case GL_ALPHA: - case GL_ALPHA4: /* FIXME: This could use its own texstore */ - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - return MESA_FORMAT_A8; - - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: /* FIXME: This could use its own texstore */ - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - return MESA_FORMAT_L8; - - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: /* FIXME: This could use its own texstore */ - case GL_LUMINANCE6_ALPHA2: /* FIXME: This could use its own texstore */ - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: /* FIXME: This could use its own texstore */ - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_COMPRESSED_LUMINANCE_ALPHA: - return MESA_FORMAT_AL88; - - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return MESA_FORMAT_I8; - - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_APPLE || - type == GL_UNSIGNED_BYTE) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - - default: - _mesa_problem(ctx, "unexpected format in sisDDChooseTextureFormat: %d", - internalFormat); - return MESA_FORMAT_NONE; - } -} - -static void sisTexImage1D( struct gl_context *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 ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - sisTexObjPtr t; - - if ( texObj->DriverData == NULL ) - sisAllocTexObj( texObj ); - t = texObj->DriverData; - - /* Note, this will call sisChooseTextureFormat */ - _mesa_store_teximage1d( ctx, target, level, internalFormat, - width, border, format, type, - pixels, packing, texObj, texImage ); - - /* Allocate offscreen space for the texture */ - sisFreeTexImage(smesa, t, level); - sisAllocTexImage(smesa, t, level, texImage); - - /* Upload the texture */ - WaitEngIdle(smesa); - memcpy(t->image[level].Data, texImage->Data, t->image[level].size); - - if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) - { - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format; - } - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - - -static void sisTexSubImage1D( struct gl_context *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 ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - sisTexObjPtr t; - GLuint copySize; - GLint texelBytes; - const char *src; - GLubyte *dst; - - if ( texObj->DriverData == NULL ) - sisAllocTexObj( texObj ); - t = texObj->DriverData; - - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, packing, texObj, - texImage); - - /* Allocate offscreen space for the texture */ - sisFreeTexImage(smesa, t, level); - sisAllocTexImage(smesa, t, level, texImage); - - /* Upload the texture */ - WaitEngIdle(smesa); - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - - copySize = width * texelBytes; - src = (char *)texImage->Data + xoffset * texelBytes; - dst = t->image[level].Data + xoffset * texelBytes; - - memcpy( dst, src, copySize ); - - smesa->clearTexCache = GL_TRUE; - - if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) - { - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format; - } - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - -static void sisTexImage2D( struct gl_context *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 ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - sisTexObjPtr t; - - if ( texObj->DriverData == NULL ) - sisAllocTexObj( texObj ); - t = texObj->DriverData; - - /* Note, this will call sisChooseTextureFormat */ - _mesa_store_teximage2d(ctx, target, level, internalFormat, - width, height, border, format, type, pixels, - &ctx->Unpack, texObj, texImage); - - /* Allocate offscreen space for the texture */ - sisFreeTexImage(smesa, t, level); - sisAllocTexImage(smesa, t, level, texImage); - - /* Upload the texture */ - WaitEngIdle(smesa); - memcpy(t->image[level].Data, texImage->Data, t->image[level].size); - - if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) - { - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format; - } - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - -static void sisTexSubImage2D( struct gl_context *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 ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - sisTexObjPtr t; - GLuint copySize; - GLint texelBytes; - const char *src; - GLubyte *dst; - int j; - GLuint soffset; - - if ( texObj->DriverData == NULL ) - sisAllocTexObj( texObj ); - t = texObj->DriverData; - - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); - - /* Allocate offscreen space for the texture */ - sisFreeTexImage(smesa, t, level); - sisAllocTexImage(smesa, t, level, texImage); - - /* Upload the texture */ - WaitEngIdle(smesa); - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - - copySize = width * texelBytes; - src = (char *)texImage->Data + (xoffset + yoffset * texImage->Width) * - texelBytes; - dst = t->image[level].Data + (xoffset + yoffset * texImage->Width) * - texelBytes; - soffset = texImage->Width * texelBytes; - - for (j = yoffset; j < yoffset + height; j++) { - memcpy( dst, src, copySize ); - src += soffset; - dst += soffset; - } - - smesa->clearTexCache = GL_TRUE; - - if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) - { - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format; - } - smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -sisNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - return obj; -} - - -void sisInitTextureFuncs( struct dd_function_table *functions ) -{ - functions->TexEnv = sisTexEnv; - functions->ChooseTextureFormat = sisChooseTextureFormat; - functions->TexImage1D = sisTexImage1D; - functions->TexSubImage1D = sisTexSubImage1D; - functions->TexImage2D = sisTexImage2D; - functions->TexSubImage2D = sisTexSubImage2D; - functions->TexParameter = sisTexParameter; - functions->BindTexture = sisBindTexture; - functions->NewTextureObject = sisNewTextureObject; - functions->DeleteTexture = sisDeleteTexture; - functions->IsTextureResident = sisIsTextureResident; -} diff --git a/src/mesa/drivers/dri/sis/sis_tex.h b/src/mesa/drivers/dri/sis/sis_tex.h deleted file mode 100644 index f467b7dca9e..00000000000 --- a/src/mesa/drivers/dri/sis/sis_tex.h +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_TEX_H__ -#define __SIS_TEX_H__ - -extern void sisInitTextureFuncs( struct dd_function_table *table ); -extern void sisUpdateTextureState( struct gl_context *ctx ); - -#endif /* __SIS_TEX_H__ */ diff --git a/src/mesa/drivers/dri/sis/sis_texstate.c b/src/mesa/drivers/dri/sis/sis_texstate.c deleted file mode 100644 index 6580f155bae..00000000000 --- a/src/mesa/drivers/dri/sis/sis_texstate.c +++ /dev/null @@ -1,712 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/colormac.h" -#include "main/context.h" -#include "main/macros.h" - -#include "sis_context.h" -#include "sis_tex.h" -#include "sis_tris.h" -#include "sis_alloc.h" - -static GLint TransferTexturePitch (GLint dwPitch); - -/* Handle texenv stuff, called from validate_texture (renderstart) */ -static void -sis_set_texture_env0( struct gl_context *ctx, struct gl_texture_object *texObj, - int unit ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLubyte c[4]; - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; - - sisTexObjPtr t = texObj->DriverData; - - switch (texture_unit->EnvMode) - { - case GL_REPLACE: - switch (t->format) - { - case GL_ALPHA: - current->hwTexBlendColor0 = STAGE0_C_CF; - current->hwTexBlendAlpha0 = STAGE0_A_AS; - break; - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor0 = STAGE0_C_CS; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - break; - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - current->hwTexBlendColor0 = STAGE0_C_CS; - current->hwTexBlendAlpha0 = STAGE0_A_AS; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - case GL_MODULATE: - switch (t->format) - { - case GL_ALPHA: - current->hwTexBlendColor0 = STAGE0_C_CF; - current->hwTexBlendAlpha0 = STAGE0_A_AFAS; - break; - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor0 = STAGE0_C_CFCS; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - break; - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - current->hwTexBlendColor0 = STAGE0_C_CFCS; - current->hwTexBlendAlpha0 = STAGE0_A_AFAS; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - case GL_DECAL: - switch (t->format) - { - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor0 = STAGE0_C_CS; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - break; - case GL_RGBA: - current->hwTexBlendColor0 = STAGE0_C_CFOMAS_CSAS; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - break; - case GL_ALPHA: - case GL_LUMINANCE: - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - current->hwTexBlendColor0 = STAGE0_C_CF; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - case GL_BLEND: - UNCLAMPED_FLOAT_TO_RGBA_CHAN(c, texture_unit->EnvColor); - current->hwTexEnvColor = ((GLint) (c[3])) << 24 | - ((GLint) (c[0])) << 16 | - ((GLint) (c[1])) << 8 | - ((GLint) (c[2])); - switch (t->format) - { - case GL_ALPHA: - current->hwTexBlendColor0 = STAGE0_C_CF; - current->hwTexBlendAlpha0 = STAGE0_A_AFAS; - break; - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - break; - case GL_INTENSITY: - current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS; - current->hwTexBlendAlpha0 = STAGE0_A_AFOMAS_ACAS; - break; - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS; - current->hwTexBlendAlpha0 = STAGE0_A_AFAS; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - default: - sis_fatal_error("unknown env mode 0x%x\n", texture_unit->EnvMode); - } - - if ((current->hwTexBlendColor0 != prev->hwTexBlendColor0) || - (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) || - (current->hwTexEnvColor != prev->hwTexEnvColor)) - { - prev->hwTexEnvColor = current->hwTexEnvColor; - prev->hwTexBlendColor0 = current->hwTexBlendColor0; - prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; - smesa->GlobalFlag |= GFLAG_TEXTUREENV; - } -} - -/* Handle texenv stuff, called from validate_texture (renderstart) */ -static void -sis_set_texture_env1( struct gl_context *ctx, struct gl_texture_object *texObj, - int unit) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLubyte c[4]; - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; - - sisTexObjPtr t = texObj->DriverData; - - switch (texture_unit->EnvMode) - { - case GL_REPLACE: - switch (t->format) - { - case GL_ALPHA: - current->hwTexBlendColor1 = STAGE1_C_CF; - current->hwTexBlendAlpha1 = STAGE1_A_AS; - break; - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor1 = STAGE1_C_CS; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - break; - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - current->hwTexBlendColor1 = STAGE1_C_CS; - current->hwTexBlendAlpha1 = STAGE1_A_AS; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - case GL_MODULATE: - switch (t->format) - { - case GL_ALPHA: - current->hwTexBlendColor1 = STAGE1_C_CF; - current->hwTexBlendAlpha1 = STAGE1_A_AFAS; - break; - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor1 = STAGE1_C_CFCS; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - break; - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - current->hwTexBlendColor1 = STAGE1_C_CFCS; - current->hwTexBlendAlpha1 = STAGE1_A_AFAS; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - case GL_DECAL: - switch (t->format) - { - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor1 = STAGE1_C_CS; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - break; - case GL_RGBA: - current->hwTexBlendColor1 = STAGE1_C_CFOMAS_CSAS; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - break; - case GL_ALPHA: - case GL_LUMINANCE: - case GL_INTENSITY: - case GL_LUMINANCE_ALPHA: - current->hwTexBlendColor1 = STAGE1_C_CF; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - case GL_BLEND: - UNCLAMPED_FLOAT_TO_RGBA_CHAN(c, texture_unit->EnvColor); - current->hwTexEnvColor = ((GLint) (c[3])) << 24 | - ((GLint) (c[0])) << 16 | - ((GLint) (c[1])) << 8 | - ((GLint) (c[2])); - switch (t->format) - { - case GL_ALPHA: - current->hwTexBlendColor1 = STAGE1_C_CF; - current->hwTexBlendAlpha1 = STAGE1_A_AFAS; - break; - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - break; - case GL_INTENSITY: - current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS; - current->hwTexBlendAlpha1 = STAGE1_A_AFOMAS_ACAS; - break; - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS; - current->hwTexBlendAlpha1 = STAGE1_A_AFAS; - break; - default: - sis_fatal_error("unknown base format 0x%x\n", t->format); - } - break; - - default: - sis_fatal_error("unknown env mode 0x%x\n", texture_unit->EnvMode); - } - - if ((current->hwTexBlendColor1 != prev->hwTexBlendColor1) || - (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) || - (current->hwTexEnvColor != prev->hwTexEnvColor)) - { - prev->hwTexBlendColor1 = current->hwTexBlendColor1; - prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; - prev->hwTexEnvColor = current->hwTexEnvColor; - smesa->GlobalFlag |= GFLAG_TEXTUREENV_1; - } -} - -/* Returns 0 if a software fallback is necessary */ -static GLboolean -sis_set_texobj_parm( struct gl_context *ctx, struct gl_texture_object *texObj, - int hw_unit ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - int ok = 1; - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - sisTexObjPtr t = texObj->DriverData; - - GLint firstLevel, lastLevel; - GLint i; - - current->texture[hw_unit].hwTextureMip = 0UL; - current->texture[hw_unit].hwTextureSet = t->hwformat; - - if ((texObj->Sampler.MinFilter == GL_NEAREST) || (texObj->Sampler.MinFilter == GL_LINEAR)) { - firstLevel = lastLevel = texObj->BaseLevel; - } else { - /* 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 = texObj->BaseLevel + (GLint)(texObj->Sampler.MinLod + 0.5); - firstLevel = MAX2(firstLevel, texObj->BaseLevel); - lastLevel = texObj->BaseLevel + (GLint)(texObj->Sampler.MaxLod + 0.5); - lastLevel = MAX2(lastLevel, texObj->BaseLevel); - lastLevel = MIN2(lastLevel, texObj->BaseLevel + - texObj->Image[0][texObj->BaseLevel]->MaxLog2); - lastLevel = MIN2(lastLevel, texObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ - } - - current->texture[hw_unit].hwTextureSet |= (lastLevel << 8); - - switch (texObj->Sampler.MagFilter) - { - case GL_NEAREST: - current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST; - break; - case GL_LINEAR: - current->texture[hw_unit].hwTextureMip |= (TEXTURE_FILTER_LINEAR << 3); - break; - } - - { - GLint b; - - /* The mipmap lod biasing is based on experiment. It seems there's a - * limit of around +4/-4 to the bias value; we're being conservative. - */ - b = (GLint) (ctx->Texture.Unit[hw_unit].LodBias * 32.0); - if (b > 127) - b = 127; - else if (b < -128) - b = -128; - - current->texture[hw_unit].hwTextureMip |= ((b << 4) & - MASK_TextureMipmapLodBias); - } - - switch (texObj->Sampler.MinFilter) - { - case GL_NEAREST: - current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST; - break; - case GL_LINEAR: - current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_NEAREST_MIP_NEAREST; - break; - case GL_NEAREST_MIPMAP_LINEAR: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_NEAREST_MIP_LINEAR; - break; - case GL_LINEAR_MIPMAP_NEAREST: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_LINEAR_MIP_NEAREST; - break; - case GL_LINEAR_MIPMAP_LINEAR: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_LINEAR_MIP_LINEAR; - break; - } - - switch (texObj->Sampler.WrapS) - { - case GL_REPEAT: - current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapU; - break; - case GL_MIRRORED_REPEAT: - current->texture[hw_unit].hwTextureSet |= MASK_TextureMirrorU; - break; - case GL_CLAMP: - current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU; - /* XXX: GL_CLAMP isn't conformant, but falling back makes the situation - * worse in other programs at the moment. - */ - /*ok = 0;*/ - break; - case GL_CLAMP_TO_EDGE: - current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU; - break; - case GL_CLAMP_TO_BORDER: - current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU; - break; - } - - switch (texObj->Sampler.WrapT) - { - case GL_REPEAT: - current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapV; - break; - case GL_MIRRORED_REPEAT: - current->texture[hw_unit].hwTextureSet |= MASK_TextureMirrorV; - break; - case GL_CLAMP: - current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV; - /* XXX: GL_CLAMP isn't conformant, but falling back makes the situation - * worse in other programs at the moment. - */ - /*ok = 0;*/ - break; - case GL_CLAMP_TO_EDGE: - current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV; - break; - case GL_CLAMP_TO_BORDER: - current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV; - break; - } - - { - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], texObj->Sampler.BorderColor.f[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], texObj->Sampler.BorderColor.f[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], texObj->Sampler.BorderColor.f[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], texObj->Sampler.BorderColor.f[3]); - - current->texture[hw_unit].hwTextureBorderColor = - PACK_COLOR_8888(c[3], c[0], c[1], c[2]); - } - - if (current->texture[hw_unit].hwTextureBorderColor != - prev->texture[hw_unit].hwTextureBorderColor) - { - prev->texture[hw_unit].hwTextureBorderColor = - current->texture[hw_unit].hwTextureBorderColor; - if (hw_unit == 1) - smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1; - else - smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR; - } - - current->texture[hw_unit].hwTextureSet |= - texObj->Image[0][firstLevel]->WidthLog2 << 4; - current->texture[hw_unit].hwTextureSet |= - texObj->Image[0][firstLevel]->HeightLog2; - - if (hw_unit == 0) - smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS; - else - smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS_1; - - for (i = firstLevel; i <= lastLevel; i++) - { - GLuint texOffset = 0; - GLuint texPitch = TransferTexturePitch( t->image[i].pitch ); - - switch (t->image[i].memType) - { - case VIDEO_TYPE: - texOffset = ((unsigned long)t->image[i].Data - (unsigned long)smesa->FbBase); - break; - case AGP_TYPE: - texOffset = ((unsigned long)t->image[i].Data - (unsigned long)smesa->AGPBase) + - (unsigned long) smesa->AGPAddr; - current->texture[hw_unit].hwTextureMip |= - (MASK_TextureLevel0InSystem << i); - break; - } - - switch (i) - { - case 0: - prev->texture[hw_unit].texOffset0 = texOffset; - prev->texture[hw_unit].texPitch01 = texPitch << 16; - break; - case 1: - prev->texture[hw_unit].texOffset1 = texOffset; - prev->texture[hw_unit].texPitch01 |= texPitch; - break; - case 2: - prev->texture[hw_unit].texOffset2 = texOffset; - prev->texture[hw_unit].texPitch23 = texPitch << 16; - break; - case 3: - prev->texture[hw_unit].texOffset3 = texOffset; - prev->texture[hw_unit].texPitch23 |= texPitch; - break; - case 4: - prev->texture[hw_unit].texOffset4 = texOffset; - prev->texture[hw_unit].texPitch45 = texPitch << 16; - break; - case 5: - prev->texture[hw_unit].texOffset5 = texOffset; - prev->texture[hw_unit].texPitch45 |= texPitch; - break; - case 6: - prev->texture[hw_unit].texOffset6 = texOffset; - prev->texture[hw_unit].texPitch67 = texPitch << 16; - break; - case 7: - prev->texture[hw_unit].texOffset7 = texOffset; - prev->texture[hw_unit].texPitch67 |= texPitch; - break; - case 8: - prev->texture[hw_unit].texOffset8 = texOffset; - prev->texture[hw_unit].texPitch89 = texPitch << 16; - break; - case 9: - prev->texture[hw_unit].texOffset9 = texOffset; - prev->texture[hw_unit].texPitch89 |= texPitch; - break; - case 10: - prev->texture[hw_unit].texOffset10 = texOffset; - prev->texture[hw_unit].texPitch10 = texPitch << 16; - break; - case 11: - prev->texture[hw_unit].texOffset11 = texOffset; - prev->texture[hw_unit].texPitch10 |= texPitch; - break; - } - } - - if (current->texture[hw_unit].hwTextureSet != - prev->texture[hw_unit].hwTextureSet) - { - prev->texture[hw_unit].hwTextureSet = - current->texture[hw_unit].hwTextureSet; - if (hw_unit == 1) - smesa->GlobalFlag |= CFLAG_TEXTURERESET_1; - else - smesa->GlobalFlag |= CFLAG_TEXTURERESET; - } - if (current->texture[hw_unit].hwTextureMip != - prev->texture[hw_unit].hwTextureMip) - { - prev->texture[hw_unit].hwTextureMip = - current->texture[hw_unit].hwTextureMip; - if (hw_unit == 1) - smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1; - else - smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP; - } - - return ok; -} - -/* Disable a texture unit, called from validate_texture */ -static void -sis_reset_texture_env (struct gl_context *ctx, int hw_unit) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - __GLSiSHardware *prev = &smesa->prev; - __GLSiSHardware *current = &smesa->current; - - if (hw_unit == 1) - { - current->hwTexBlendColor1 = STAGE1_C_CF; - current->hwTexBlendAlpha1 = STAGE1_A_AF; - - if ((current->hwTexBlendColor1 != prev->hwTexBlendColor1) || - (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) || - (current->hwTexEnvColor != prev->hwTexEnvColor)) - { - prev->hwTexBlendColor1 = current->hwTexBlendColor1; - prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; - prev->hwTexEnvColor = current->hwTexEnvColor; - smesa->GlobalFlag |= GFLAG_TEXTUREENV_1; - } - } else { - current->hwTexBlendColor0 = STAGE0_C_CF; - current->hwTexBlendAlpha0 = STAGE0_A_AF; - - if ((current->hwTexBlendColor0 != prev->hwTexBlendColor0) || - (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) || - (current->hwTexEnvColor != prev->hwTexEnvColor)) - { - prev->hwTexBlendColor0 = current->hwTexBlendColor0; - prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; - prev->hwTexEnvColor = current->hwTexEnvColor; - smesa->GlobalFlag |= GFLAG_TEXTUREENV; - } - } -} - -static void updateTextureUnit( struct gl_context *ctx, int unit ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - struct gl_texture_object *texObj = texUnit->_Current; - GLint fallbackbit; - - if (unit == 0) - fallbackbit = SIS_FALLBACK_TEXTURE0; - else - fallbackbit = SIS_FALLBACK_TEXTURE1; - - if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) { - if (smesa->TexStates[unit] & NEW_TEXTURING) { - GLboolean ok; - - ok = sis_set_texobj_parm (ctx, texObj, unit); - FALLBACK( smesa, fallbackbit, !ok ); - } - if (smesa->TexStates[unit] & NEW_TEXTURE_ENV) { - if (unit == 0) - sis_set_texture_env0( ctx, texObj, unit ); - else - sis_set_texture_env1( ctx, texObj, unit ); - } - smesa->TexStates[unit] = 0; - } else if ( texUnit->_ReallyEnabled ) { - /* fallback */ - FALLBACK( smesa, fallbackbit, 1 ); - } else { - sis_reset_texture_env( ctx, unit ); - FALLBACK( smesa, fallbackbit, 0 ); - } -} - - -void sisUpdateTextureState( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - int i; - __GLSiSHardware *current = &smesa->current; - -#if 1 - /* TODO : if unmark these, error in multitexture */ /* XXX */ - for (i = 0; i < SIS_MAX_TEXTURES; i++) - smesa->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV); -#endif - - updateTextureUnit( ctx, 0 ); - updateTextureUnit( ctx, 1 ); - - /* XXX Issues with the 2nd unit but not the first being enabled? */ - if ( ctx->Texture.Unit[0]._ReallyEnabled & - (TEXTURE_1D_BIT | TEXTURE_2D_BIT) || - ctx->Texture.Unit[1]._ReallyEnabled & - (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ) - { - current->hwCapEnable |= MASK_TextureEnable; - current->hwCapEnable &= ~MASK_TextureNumUsed; - if (ctx->Texture.Unit[1]._ReallyEnabled) - current->hwCapEnable |= 0x00002000; - else - current->hwCapEnable |= 0x00001000; - } else { - current->hwCapEnable &= ~MASK_TextureEnable; - } -} - -static GLint -BitScanForward( GLshort w ) -{ - GLint i; - - for (i = 0; i < 16; i++) { - if (w & (1 << i)) - break; - } - return i; -} - -static GLint -TransferTexturePitch( GLint dwPitch ) -{ - GLint dwRet, i; - - i = BitScanForward( (GLshort)dwPitch ); - dwRet = dwPitch >> i; - dwRet |= i << 9; - return dwRet; -} diff --git a/src/mesa/drivers/dri/sis/sis_tris.c b/src/mesa/drivers/dri/sis/sis_tris.c deleted file mode 100644 index 8db593fb9c7..00000000000 --- a/src/mesa/drivers/dri/sis/sis_tris.c +++ /dev/null @@ -1,1154 +0,0 @@ -/* $XFree86*/ /* -*- c-basic-offset: 3 -*- */ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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: - * Sung-Ching Lin <[email protected]> - * Eric Anholt <[email protected]> - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/macros.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "sis_context.h" -#include "sis_tris.h" -#include "sis_state.h" -#include "sis_lock.h" -#include "sis_span.h" -#include "sis_tex.h" - -/* 6326 and 300-series shared */ -static const GLuint hw_prim[GL_POLYGON+1] = { - OP_3D_POINT_DRAW, /* GL_POINTS */ - OP_3D_LINE_DRAW, /* GL_LINES */ - OP_3D_LINE_DRAW, /* GL_LINE_LOOP */ - OP_3D_LINE_DRAW, /* GL_LINE_STRIP */ - OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLES */ - OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLE_STRIP */ - OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLE_FAN */ - OP_3D_TRIANGLE_DRAW, /* GL_QUADS */ - OP_3D_TRIANGLE_DRAW, /* GL_QUAD_STRIP */ - OP_3D_TRIANGLE_DRAW /* GL_POLYGON */ -}; - -static const GLuint hw_prim_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = { - OP_3D_FIRE_TSARGBa, - OP_3D_FIRE_TSARGBb, - OP_3D_FIRE_TSARGBc -}; -static const GLuint hw_prim_6326_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = { - OP_6326_3D_FIRE_TSARGBa, - OP_6326_3D_FIRE_TSARGBb, - OP_6326_3D_FIRE_TSARGBc -}; - -static const GLuint hw_prim_mmio_shade[OP_3D_TRIANGLE_DRAW+1] = { - SHADE_FLAT_VertexA, - SHADE_FLAT_VertexB, - SHADE_FLAT_VertexC -}; - -static const GLuint hw_prim_agp_type[OP_3D_TRIANGLE_DRAW+1] = { - MASK_PsPointList, - MASK_PsLineList, - MASK_PsTriangleList -}; - -static const GLuint hw_prim_agp_shade[OP_3D_TRIANGLE_DRAW+1] = { - MASK_PsShadingFlatA, - MASK_PsShadingFlatB, - MASK_PsShadingFlatC -}; - -static void sisRasterPrimitive( struct gl_context *ctx, GLuint hwprim ); -static void sisRenderPrimitive( struct gl_context *ctx, GLenum prim ); - -/*********************************************************************** - * Emit primitives as inline vertices * - ***********************************************************************/ - -#define HAVE_QUADS 0 -#define HAVE_LINES 1 -#define HAVE_POINTS 1 -#define CTX_ARG sisContextPtr smesa -#define GET_VERTEX_DWORDS() smesa->vertex_size -#define ALLOC_VERTS( n, size ) sisAllocDmaLow( smesa, n * size * sizeof(int) ) -#undef LOCAL_VARS -#define LOCAL_VARS \ - sisContextPtr smesa = SIS_CONTEXT(ctx); \ - const char *vertptr = smesa->verts; -#define VERT(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int))) -#define VERTEX sisVertex -#undef TAG -#define TAG(x) sis_##x -#include "tnl_dd/t_dd_triemit.h" -#undef TAG -#undef LOCAL_VARS - -/*********************************************************************** - * Dispatch vertices to hardware through MMIO * - ***********************************************************************/ - -/* The ARGB write of the last vertex of the primitive fires the 3d engine, so - * save it until the end. - */ -#define SIS_MMIO_WRITE_VERTEX(_v, i, lastvert) \ -do { \ - GLuint __color, __i = 0; \ - MMIO(REG_3D_TSXa+(i)*0x30, _v->ui[__i++]); \ - MMIO(REG_3D_TSYa+(i)*0x30, _v->ui[__i++]); \ - MMIO(REG_3D_TSZa+(i)*0x30, _v->ui[__i++]); \ - if (SIS_STATES & VERT_W) \ - MMIO(REG_3D_TSWGa+(i)*0x30, _v->ui[__i++]); \ - __color = _v->ui[__i++]; \ - if (SIS_STATES & VERT_SPEC) \ - MMIO(REG_3D_TSFSa+(i)*0x30, _v->ui[__i++]); \ - if (SIS_STATES & VERT_UV0) { \ - MMIO(REG_3D_TSUAa+(i)*0x30, _v->ui[__i++]); \ - MMIO(REG_3D_TSVAa+(i)*0x30, _v->ui[__i++]); \ - } \ - if (SIS_STATES & VERT_UV1) { \ - MMIO(REG_3D_TSUBa+(i)*0x30, _v->ui[__i++]); \ - MMIO(REG_3D_TSVBa+(i)*0x30, _v->ui[__i++]); \ - } \ - if (lastvert || (SIS_STATES & VERT_SMOOTH)) \ - MMIO(REG_3D_TSARGBa+(i)*0x30, __color); \ -} while (0) - -#define SIS6326_MMIO_WRITE_VERTEX(_v, i, lastvert) \ -do { \ - GLuint __color, __i = 0; \ - MMIO(REG_6326_3D_TSXa+(i)*0x20, _v->ui[__i++]); \ - MMIO(REG_6326_3D_TSYa+(i)*0x20, _v->ui[__i++]); \ - MMIO(REG_6326_3D_TSZa+(i)*0x20, _v->ui[__i++]); \ - if (SIS_STATES & VERT_W) \ - MMIO(REG_6326_3D_TSWa+(i)*0x20, _v->ui[__i++]); \ - __color = _v->ui[__i++]; \ - if (SIS_STATES & VERT_SPEC) \ - MMIO(REG_6326_3D_TSFSa+(i)*0x20, _v->ui[__i++]); \ - if (SIS_STATES & VERT_UV0) { \ - MMIO(REG_6326_3D_TSUa+(i)*0x20, _v->ui[__i++]); \ - MMIO(REG_6326_3D_TSVa+(i)*0x20, _v->ui[__i++]); \ - } \ - if (lastvert || (SIS_STATES & VERT_SMOOTH)) \ - MMIO(REG_6326_3D_TSARGBa+(i)*0x30, __color); \ -} while (0) - -#define MMIO_VERT_REG_COUNT 10 - -#define VERT_SMOOTH 0x01 -#define VERT_W 0x02 -#define VERT_SPEC 0x04 -#define VERT_UV0 0x08 -#define VERT_UV1 0x10 -#define VERT_6326 0x20 /* Right after UV1, but won't have a UV1 set */ - -typedef void (*mmio_draw_func)(sisContextPtr smesa, char *verts); -static mmio_draw_func sis_tri_func_mmio[48]; -static mmio_draw_func sis_line_func_mmio[48]; -static mmio_draw_func sis_point_func_mmio[48]; - -#define SIS_STATES (0) -#define TAG(x) x##_none -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH) -#define TAG(x) x##_g -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W) -#define TAG(x) x##_w -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W) -#define TAG(x) x##_gw -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SPEC) -#define TAG(x) x##_s -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_SPEC) -#define TAG(x) x##_gs -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_SPEC) -#define TAG(x) x##_ws -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC) -#define TAG(x) x##_gws -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_UV0) -#define TAG(x) x##_t0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_UV0) -#define TAG(x) x##_gt0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_UV0) -#define TAG(x) x##_wt0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0) -#define TAG(x) x##_gwt0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SPEC | VERT_UV0) -#define TAG(x) x##_st0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0) -#define TAG(x) x##_gst0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0) -#define TAG(x) x##_wst0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0) -#define TAG(x) x##_gwst0 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_UV1) -#define TAG(x) x##_t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_UV1) -#define TAG(x) x##_gt1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_UV1) -#define TAG(x) x##_wt1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV1) -#define TAG(x) x##_gwt1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SPEC | VERT_UV1) -#define TAG(x) x##_st1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV1) -#define TAG(x) x##_gst1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV1) -#define TAG(x) x##_wst1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV1) -#define TAG(x) x##_gwst1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_UV0 | VERT_UV1) -#define TAG(x) x##_t0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_gt0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_wt0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_gwt0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SPEC | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_st0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_gst0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_wst0t1 -#include "sis_tritmp.h" - -#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1) -#define TAG(x) x##_gwst0t1 -#include "sis_tritmp.h" - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( a, b, c ) \ -do { \ - if (DO_FALLBACK) \ - smesa->draw_tri( smesa, a, b, c ); \ - else \ - sis_triangle( smesa, a, b, c ); \ -} while (0) - -#define QUAD( a, b, c, d ) \ -do { \ - if (DO_FALLBACK) { \ - smesa->draw_tri( smesa, a, b, d ); \ - smesa->draw_tri( smesa, b, c, d ); \ - } else \ - sis_quad( smesa, a, b, c, d ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - smesa->draw_line( smesa, v0, v1 ); \ - else \ - sis_line( smesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - smesa->draw_point( smesa, v0 ); \ - else \ - sis_point( smesa, v0 ); \ -} while (0) - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define SIS_OFFSET_BIT 0x01 -#define SIS_TWOSIDE_BIT 0x02 -#define SIS_UNFILLED_BIT 0x04 -#define SIS_FALLBACK_BIT 0x08 -#define SIS_MAX_TRIFUNC 0x10 - - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[SIS_MAX_TRIFUNC]; - - -#define DO_FALLBACK (IND & SIS_FALLBACK_BIT) -#define DO_OFFSET (IND & SIS_OFFSET_BIT) -#define DO_UNFILLED (IND & SIS_UNFILLED_BIT) -#define DO_TWOSIDE (IND & SIS_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_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX sisVertex -#define TAB rast_tab - -#define DEPTH_SCALE smesa->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) (smesa->verts + (e * smesa->vertex_size * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - sis_color_t *color = (sis_color_t *)&((v)->ui[coloroffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] - -#define VERT_SET_SPEC( v, c ) \ -do { \ - if (specoffset != 0) { \ - sis_color_t *spec = (sis_color_t *)&((v)->ui[specoffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ - } \ -} while (0) -#define VERT_COPY_SPEC( v0, v1 ) \ -do { \ - if (specoffset != 0) { \ - sis_color_t *spec0 = (sis_color_t *)&((v0)->ui[specoffset]); \ - sis_color_t *spec1 = (sis_color_t *)&((v1)->ui[specoffset]); \ - spec0->red = spec1->red; \ - spec0->green = spec1->green; \ - spec0->blue = spec1->blue; \ - } \ -} while (0) - -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] -#define VERT_SAVE_SPEC( idx ) if (specoffset != 0) spec[idx] = v[idx]->ui[specoffset] -#define VERT_RESTORE_SPEC( idx ) if (specoffset != 0) v[idx]->ui[specoffset] = spec[idx] - -#define LOCAL_VARS(n) \ - sisContextPtr smesa = SIS_CONTEXT(ctx); \ - GLuint color[n] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - GLuint coloroffset = smesa->coloroffset; \ - GLuint specoffset = smesa->specoffset; \ - (void) color; (void) spec; (void) coloroffset; (void) specoffset; - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (smesa->hw_primitive != hw_prim[x]) \ - sisRasterPrimitive( ctx, hw_prim[x] ) -#define RENDER_PRIMITIVE smesa->render_primitive -#define IND SIS_FALLBACK_BIT -#define TAG(x) x -#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 (SIS_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_OFFSET_BIT|SIS_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_OFFSET_BIT|SIS_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_UNFILLED_BIT|SIS_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_OFFSET_BIT|SIS_UNFILLED_BIT|SIS_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_UNFILLED_BIT|SIS_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_UNFILLED_BIT| \ - SIS_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_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(); -} - - - -/*********************************************************************** - * 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 -sis_fallback_tri( sisContextPtr smesa, - sisVertex *v0, - sisVertex *v1, - sisVertex *v2 ) -{ - struct gl_context *ctx = smesa->glCtx; - SWvertex v[3]; - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - _swsetup_Translate( ctx, v2, &v[2] ); - sisSpanRenderStart( ctx ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); - sisSpanRenderFinish( ctx ); - _swrast_flush( ctx ); -} - - -static void -sis_fallback_line( sisContextPtr smesa, - sisVertex *v0, - sisVertex *v1 ) -{ - struct gl_context *ctx = smesa->glCtx; - SWvertex v[2]; - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - sisSpanRenderStart( ctx ); - _swrast_Line( ctx, &v[0], &v[1] ); - sisSpanRenderFinish( ctx ); - _swrast_flush( ctx ); -} - - -static void -sis_fallback_point( sisContextPtr smesa, - sisVertex *v0 ) -{ - struct gl_context *ctx = smesa->glCtx; - SWvertex v[1]; - _swsetup_Translate( ctx, v0, &v[0] ); - sisSpanRenderStart( ctx ); - _swrast_Point( ctx, &v[0] ); - sisSpanRenderFinish( ctx ); - _swrast_flush( ctx ); -} - - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define IND 0 -#define V(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int))) -#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) sisRenderPrimitive( ctx, x ) -#undef LOCAL_VARS -#define LOCAL_VARS \ - sisContextPtr smesa = SIS_CONTEXT(ctx); \ - const GLuint vertsize = smesa->vertex_size; \ - const char *vertptr = (char *)smesa->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) sis_##x##_verts -#include "tnl/t_vb_rendertmp.h" -#undef ELT -#undef TAG -#define TAG(x) sis_##x##_elts -#define ELT(x) elt[x] -#include "tnl/t_vb_rendertmp.h" - - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - -#define POINT_FALLBACK (DD_POINT_SMOOTH) -#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH) -#define TRI_FALLBACK (DD_TRI_STIPPLE|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) -#define _SIS_NEW_RENDER_STATE (ANY_RASTER_FLAGS | ANY_FALLBACK_FLAGS) - -static void sisChooseRenderState(struct gl_context *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - sisContextPtr smesa = SIS_CONTEXT( ctx ); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (smesa->Fallback) - return; - - if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { - - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= SIS_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= SIS_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= SIS_UNFILLED_BIT; - } - - smesa->draw_point = sis_point; - smesa->draw_line = sis_line; - smesa->draw_tri = sis_triangle; - /* Hook in fallbacks for specific primitives. - */ - if (flags & ANY_FALLBACK_FLAGS) { - if (flags & POINT_FALLBACK) - smesa->draw_point = sis_fallback_point; - if (flags & LINE_FALLBACK) - smesa->draw_line = sis_fallback_line; - if (flags & TRI_FALLBACK) - smesa->draw_tri = sis_fallback_tri; - index |= SIS_FALLBACK_BIT; - } - } - - if (index != smesa->RenderIndex) { - smesa->RenderIndex = index; - - 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 = sis_render_tab_verts; - tnl->Driver.Render.PrimTabElts = sis_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = sis_fast_clipped_poly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; - } - } -} - -/**********************************************************************/ -/* Multipass rendering for front buffering */ -/**********************************************************************/ -static GLboolean multipass_cliprect( struct gl_context *ctx, GLuint pass ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - - if (pass >= smesa->driDrawable->numClipRects) { - return GL_FALSE; - } else { - GLint x1, y1, x2, y2; - - x1 = smesa->driDrawable->pClipRects[pass].x1 - smesa->driDrawable->x; - y1 = smesa->driDrawable->pClipRects[pass].y1 - smesa->driDrawable->y; - x2 = smesa->driDrawable->pClipRects[pass].x2 - smesa->driDrawable->x; - y2 = smesa->driDrawable->pClipRects[pass].y2 - smesa->driDrawable->y; - - if (ctx->Scissor.Enabled) { - GLint scisy1 = Y_FLIP(ctx->Scissor.Y + ctx->Scissor.Height - 1); - GLint scisy2 = Y_FLIP(ctx->Scissor.Y); - - if (ctx->Scissor.X > x1) - x1 = ctx->Scissor.X; - if (scisy1 > y1) - y1 = scisy1; - if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2) - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - if (scisy2 < y2) - y2 = scisy2; - } - - MMIO(REG_3D_ClipTopBottom, y1 << 13 | y2); - MMIO(REG_3D_ClipLeftRight, x1 << 13 | x2); - /* Mark that we clobbered these registers */ - smesa->GlobalFlag |= GFLAG_CLIPPING; - return GL_TRUE; - } -} - - - -/**********************************************************************/ -/* Validate state at pipeline start */ -/**********************************************************************/ - -static void sisRunPipeline( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - - if (smesa->NewGLState) { - SIS_FIREVERTICES(smesa); - if (smesa->NewGLState & _NEW_TEXTURE) { - sisUpdateTextureState(ctx); - } - - if (smesa->NewGLState & _SIS_NEW_RENDER_STATE) - sisChooseRenderState( ctx ); - - smesa->NewGLState = 0; - } - - _tnl_run_pipeline( ctx ); - - /* XXX: If we put flushing in sis_state.c and friends, we can avoid this. - * Is it worth it? - */ - SIS_FIREVERTICES(smesa); -} - -/**********************************************************************/ -/* 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. - */ - -static void sisRasterPrimitive( struct gl_context *ctx, GLuint hwprim ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - if (smesa->hw_primitive != hwprim) { - SIS_FIREVERTICES(smesa); - smesa->hw_primitive = hwprim; - - smesa->AGPParseSet &= ~(MASK_PsDataType | MASK_PsShadingMode); - smesa->AGPParseSet |= hw_prim_agp_type[hwprim]; - - if (smesa->is6326) { - smesa->dwPrimitiveSet &= ~(MASK_6326_DrawPrimitiveCommand | - MASK_6326_SetFirePosition | MASK_6326_ShadingMode); - smesa->dwPrimitiveSet |= hwprim | hw_prim_6326_mmio_fire[hwprim]; - } else { - smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand | - MASK_SetFirePosition | MASK_ShadingMode); - smesa->dwPrimitiveSet |= hwprim | hw_prim_mmio_fire[hwprim]; - } - - if (ctx->Light.ShadeModel == GL_FLAT) { - smesa->AGPParseSet |= hw_prim_agp_shade[hwprim]; - smesa->dwPrimitiveSet |= hw_prim_mmio_shade[hwprim]; - } else { - smesa->AGPParseSet |= MASK_PsShadingSmooth; - if (smesa->is6326) { - smesa->dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_GOURAUD; - } else { - smesa->dwPrimitiveSet |= SHADE_GOURAUD; - } - } - } -} - -static void sisRenderPrimitive( struct gl_context *ctx, GLenum prim ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - smesa->render_primitive = prim; - - if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - sisRasterPrimitive( ctx, hw_prim[prim] ); -} - -#define EMIT_ATTR( ATTR, STYLE) \ -do { \ - smesa->vertex_attrs[smesa->vertex_attr_count].attrib = (ATTR); \ - smesa->vertex_attrs[smesa->vertex_attr_count].format = (STYLE); \ - smesa->vertex_attr_count++; \ -} while (0) - -#define EMIT_PAD( N ) \ -do { \ - smesa->vertex_attrs[smesa->vertex_attr_count].attrib = 0; \ - smesa->vertex_attrs[smesa->vertex_attr_count].format = EMIT_PAD; \ - smesa->vertex_attrs[smesa->vertex_attr_count].offset = (N); \ - smesa->vertex_attr_count++; \ -} while (0) - -static void sisRenderStart( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - sisContextPtr smesa = SIS_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - GLuint AGPParseSet = smesa->AGPParseSet; - GLboolean tex_fallback = GL_FALSE; - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - - if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT && - smesa->driDrawable->numClipRects != 0) - { - multipass_cliprect(ctx, 0); - if (smesa->driDrawable->numClipRects > 1) - tnl->Driver.Render.Multipass = multipass_cliprect; - else - tnl->Driver.Render.Multipass = NULL; - } else { - tnl->Driver.Render.Multipass = NULL; - } - - /* Important: - */ - VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; - smesa->vertex_attr_count = 0; - - /* EMIT_ATTR's must be in order as they tell t_vertex.c how to build up a - * hardware vertex. - */ - - AGPParseSet &= ~(MASK_VertexDWSize | MASK_VertexDataFormat); - AGPParseSet |= SiS_PS_HAS_XYZ | SiS_PS_HAS_DIFFUSE; - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { - EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT); - AGPParseSet |= SiS_PS_HAS_W; - smesa->coloroffset = 4; - } else { - EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT); - smesa->coloroffset = 3; - } - - EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA); - - smesa->specoffset = 0; - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || - RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - AGPParseSet |= SiS_PS_HAS_SPECULAR; - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { - EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR); - smesa->specoffset = smesa->coloroffset + 1; - } else { - EMIT_PAD(3); - } - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F); - } else { - EMIT_PAD(1); - } - } - - /* projective textures are not supported by the hardware */ - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) { - if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size > 2) - tex_fallback = GL_TRUE; - EMIT_ATTR(_TNL_ATTRIB_TEX0, EMIT_2F); - AGPParseSet |= SiS_PS_HAS_UV0; - } - /* Will only hit tex1 on SiS300 */ - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 )) { - if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size > 2) - tex_fallback = GL_TRUE; - EMIT_ATTR(_TNL_ATTRIB_TEX1, EMIT_2F); - AGPParseSet |= SiS_PS_HAS_UV1; - } - FALLBACK(smesa, SIS_FALLBACK_TEXTURE, tex_fallback); - - if (!RENDERINPUTS_EQUAL( smesa->last_tcl_state_bitset, index_bitset )) { - smesa->AGPParseSet = AGPParseSet; - - smesa->vertex_size = _tnl_install_attrs( ctx, smesa->vertex_attrs, - smesa->vertex_attr_count, smesa->hw_viewport, 0 ); - - smesa->vertex_size >>= 2; - smesa->AGPParseSet |= smesa->vertex_size << 28; - } -} - -static void sisRenderFinish( struct gl_context *ctx ) -{ -} - -/**********************************************************************/ -/* AGP/PCI vertex submission */ -/**********************************************************************/ - -void -sisFlushPrimsLocked(sisContextPtr smesa) -{ - if (smesa->vb_cur == smesa->vb_last) - return; - - if (smesa->is6326) - sis6326UpdateHWState(smesa->glCtx); - else - sisUpdateHWState(smesa->glCtx); - - if (smesa->using_agp) { - mWait3DCmdQueue(8); - mEndPrimitive(); - MMIO(REG_3D_AGPCmBase, (smesa->vb_last - smesa->vb) + - smesa->vb_agp_offset); - MMIO(REG_3D_AGPTtDwNum, ((smesa->vb_cur - smesa->vb_last) / 4) | - 0x50000000); - MMIO(REG_3D_ParsingSet, smesa->AGPParseSet); - MMIO(REG_3D_AGPCmFire, (GLint)(-1)); - mEndPrimitive(); - } else { - int mmio_index = 0, incr = 0; - void (*sis_emit_func)(sisContextPtr smesa, char *verts) = NULL; - - if (smesa->AGPParseSet & MASK_PsShadingSmooth) - mmio_index |= VERT_SMOOTH; - if (smesa->AGPParseSet & SiS_PS_HAS_SPECULAR) - mmio_index |= VERT_SPEC; - if (smesa->AGPParseSet & SiS_PS_HAS_W) - mmio_index |= VERT_W; - if (smesa->AGPParseSet & SiS_PS_HAS_UV0) - mmio_index |= VERT_UV0; - if (smesa->AGPParseSet & SiS_PS_HAS_UV1) - mmio_index |= VERT_UV1; - if (smesa->is6326) - mmio_index |= VERT_6326; - - switch (smesa->AGPParseSet & MASK_PsDataType) { - case MASK_PsPointList: - incr = smesa->vertex_size * 4; - sis_emit_func = sis_point_func_mmio[mmio_index]; - break; - case MASK_PsLineList: - incr = smesa->vertex_size * 4 * 2; - sis_emit_func = sis_line_func_mmio[mmio_index]; - break; - case MASK_PsTriangleList: - incr = smesa->vertex_size * 4 * 3; - sis_emit_func = sis_tri_func_mmio[mmio_index]; - break; - } - - if (!smesa->is6326) { - mWait3DCmdQueue(1); - MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet); - } - while (smesa->vb_last < smesa->vb_cur) { - assert(sis_emit_func); - sis_emit_func(smesa, (char *)smesa->vb_last); - smesa->vb_last += incr; - } - mWait3DCmdQueue(1); - mEndPrimitive(); - - /* With PCI, we can just start writing to the start of the VB again. */ - smesa->vb_cur = smesa->vb; - } - smesa->vb_last = smesa->vb_cur; -} - -void sisFlushPrims(sisContextPtr smesa) -{ - LOCK_HARDWARE(); - sisFlushPrimsLocked(smesa); - UNLOCK_HARDWARE(); -} - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - -static const char * const fallbackStrings[] = { - "Texture mode", - "Texture 0 mode", - "Texture 1 mode", - "Texture 0 env", /* Note: unused */ - "Texture 1 env", /* Note: unused */ - "glDrawBuffer(GL_FRONT_AND_BACK)", - "glEnable(GL_STENCIL) without hw stencil buffer", - "write mask", - "no_rast", -}; - -static const char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - -void sisFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - sisContextPtr smesa = SIS_CONTEXT(ctx); - GLuint oldfallback = smesa->Fallback; - - if (mode) { - smesa->Fallback |= bit; - if (oldfallback == 0) { - SIS_FIREVERTICES(smesa); - _swsetup_Wakeup( ctx ); - smesa->RenderIndex = ~0; - if (SIS_DEBUG & DEBUG_FALLBACKS) { - fprintf(stderr, "SiS begin rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } - else { - smesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - tnl->Driver.Render.Start = sisRenderStart; - tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; - tnl->Driver.Render.Finish = sisRenderFinish; - - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_invalidate_vertex_state( ctx, ~0 ); - _tnl_invalidate_vertices( ctx, ~0 ); - _tnl_install_attrs( ctx, - smesa->vertex_attrs, - smesa->vertex_attr_count, - smesa->hw_viewport, 0 ); - - smesa->NewGLState |= _SIS_NEW_RENDER_STATE; - if (SIS_DEBUG & DEBUG_FALLBACKS) { - fprintf(stderr, "SiS end rasterization fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - -void sisInitTriFuncs( struct gl_context *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - - sis_vert_init_none(); - sis_vert_init_g(); - sis_vert_init_w(); - sis_vert_init_gw(); - sis_vert_init_s(); - sis_vert_init_gs(); - sis_vert_init_ws(); - sis_vert_init_gws(); - sis_vert_init_t0(); - sis_vert_init_gt0(); - sis_vert_init_wt0(); - sis_vert_init_gwt0(); - sis_vert_init_st0(); - sis_vert_init_gst0(); - sis_vert_init_wst0(); - sis_vert_init_gwst0(); - sis_vert_init_t1(); - sis_vert_init_gt1(); - sis_vert_init_wt1(); - sis_vert_init_gwt1(); - sis_vert_init_st1(); - sis_vert_init_gst1(); - sis_vert_init_wst1(); - sis_vert_init_gwst1(); - sis_vert_init_t0t1(); - sis_vert_init_gt0t1(); - sis_vert_init_wt0t1(); - sis_vert_init_gwt0t1(); - sis_vert_init_st0t1(); - sis_vert_init_gst0t1(); - sis_vert_init_wst0t1(); - sis_vert_init_gwst0t1(); - } - - smesa->RenderIndex = ~0; - smesa->NewGLState |= _SIS_NEW_RENDER_STATE; - - tnl->Driver.RunPipeline = sisRunPipeline; - tnl->Driver.Render.Start = sisRenderStart; - tnl->Driver.Render.Finish = sisRenderFinish; - tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) ); - - smesa->verts = (char *)tnl->clipspace.vertex_buf; -} diff --git a/src/mesa/drivers/dri/sis/sis_tris.h b/src/mesa/drivers/dri/sis/sis_tris.h deleted file mode 100644 index d454090607b..00000000000 --- a/src/mesa/drivers/dri/sis/sis_tris.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** - -Copyright 2003 Eric Anholt -All Rights Reserved. - -Permission is hereby granted, free of charge, to 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 -ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_TRIS_H__ -#define __SIS_TRIS_H__ - -#include "sis_lock.h" -#include "main/mtypes.h" - -extern void sisInitTriFuncs( struct gl_context *ctx ); -extern void sisFlushPrims( sisContextPtr smesa ); -extern void sisFlushPrimsLocked( sisContextPtr smesa ); -extern void sisFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ); - -#define FALLBACK( smesa, bit, mode ) sisFallback( smesa->glCtx, bit, mode ) - -#define SIS_FIREVERTICES(smesa) \ -do { \ - if (smesa->vb_cur != smesa->vb_last) \ - sisFlushPrims(smesa); \ -} while (0) - -static INLINE GLuint *sisAllocDmaLow(sisContextPtr smesa, int bytes) -{ - GLuint *start; - - if (smesa->vb_cur + bytes >= smesa->vb_end) { - LOCK_HARDWARE(); - sisFlushPrimsLocked(smesa); - if (smesa->using_agp) { - WaitEngIdle(smesa); - smesa->vb_cur = smesa->vb; - smesa->vb_last = smesa->vb_cur; - } - UNLOCK_HARDWARE(); - } - - start = (GLuint *)smesa->vb_cur; - smesa->vb_cur += bytes; - return start; -} - -#endif /* __SIS_TRIS_H__ */ diff --git a/src/mesa/drivers/dri/sis/sis_tritmp.h b/src/mesa/drivers/dri/sis/sis_tritmp.h deleted file mode 100644 index f75e17318fc..00000000000 --- a/src/mesa/drivers/dri/sis/sis_tritmp.h +++ /dev/null @@ -1,250 +0,0 @@ -/* $XFree86*/ /* -*- c-basic-offset: 3 -*- */ -/* - * Copyright 2005 Eric Anholt - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION 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: - * Eric Anholt <[email protected]> - * Jim Duchek <[email protected]> -- Utah GLX 6326 code - * Alan Cox <[email protected]> -- 6326 Debugging - * - */ - -static void TAG(sis_draw_tri_mmio)(sisContextPtr smesa, char *verts) -{ - sisVertexPtr v0 = (sisVertexPtr)verts; - sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4); - sisVertexPtr v2 = (sisVertexPtr)(verts + smesa->vertex_size * 4 * 2); - - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 3); - SIS_MMIO_WRITE_VERTEX(v0, 0, 0); - SIS_MMIO_WRITE_VERTEX(v1, 1, 0); - SIS_MMIO_WRITE_VERTEX(v2, 2, 1); -} - -static void TAG(sis_draw_line_mmio)(sisContextPtr smesa, char *verts) -{ - sisVertexPtr v0 = (sisVertexPtr)verts; - sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4); - - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2); - SIS_MMIO_WRITE_VERTEX(v0, 0, 0); - SIS_MMIO_WRITE_VERTEX(v1, 1, 1); -} - -static void TAG(sis_draw_point_mmio)(sisContextPtr smesa, char *verts) -{ - sisVertexPtr v0 = (sisVertexPtr)verts; - - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1); - SIS_MMIO_WRITE_VERTEX(v0, 1, 1); -} - -#if !(SIS_STATES & VERT_UV1) -static void TAG(sis6326_draw_tri_mmio)(sisContextPtr smesa, char *verts) -{ - sisVertexPtr v0 = (sisVertexPtr)verts; - sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4); - sisVertexPtr v2 = (sisVertexPtr)(verts + smesa->vertex_size * 4 * 2); - GLfloat x0, x1, x2; - GLfloat y0, y1, y2; - GLfloat delt02, diffx02, diffy02, diffy12; - GLint dwPrimitiveSet = smesa->dwPrimitiveSet; - sisVertex tv0, tv1, tv2; - - /* XXX Culling? */ - - tv0 = *v0; - tv1 = *v1; - tv2 = *v2; - tv0.v.y = Y_FLIP(tv0.v.y); - tv1.v.y = Y_FLIP(tv1.v.y); - tv2.v.y = Y_FLIP(tv2.v.y); - v0 = &tv0; - v1 = &tv1; - v2 = &tv2; - - /* Cull polygons we won't draw. The hardware draws funky things if it - is fed these */ - if((((v1->v.x - v0->v.x) * (v0->v.y - v2->v.y)) + - ((v1->v.y - v0->v.y) * (v2->v.x - v0->v.x))) < 0) - return; - y0 = v0->v.y; - y1 = v1->v.y; - y2 = v2->v.y; - - - if (y0 > y1) { - if (y1 > y2) { - x0 = v0->v.x; - x1 = v1->v.x; - x2 = v2->v.x; - dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_BMID | OP_6326_3D_CBOT; - if ((SIS_STATES & VERT_SMOOTH) == 0) - dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_BOT; - } else { - if (y0 > y2) { - x0 = v0->v.x; - x1 = v2->v.x; - y1 = v2->v.y; - dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_CMID | - OP_6326_3D_BBOT; - if ((SIS_STATES & VERT_SMOOTH) == 0) - dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_MID; - } else { - x0 = v2->v.x; - y0 = v2->v.y; - x1 = v0->v.x; - y1 = v0->v.y; - dwPrimitiveSet |= OP_6326_3D_CTOP | OP_6326_3D_AMID | - OP_6326_3D_BBOT; - if ((SIS_STATES & VERT_SMOOTH) == 0) - dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_TOP; - } - x2 = v1->v.x; - y2 = v1->v.y; - } - } else { - if (y0 > y2) { - x0 = v1->v.x; - y0 = v1->v.y; - x1 = v0->v.x; - y1 = v0->v.y; - x2 = v2->v.x; - dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_AMID | OP_6326_3D_CBOT; - if ((SIS_STATES & VERT_SMOOTH) == 0) - dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_BOT; - } else { - if (y1 > y2) { - x0 = v1->v.x; - y0 = v1->v.y; - x1 = v2->v.x; - y1 = v2->v.y; - dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_CMID | - OP_6326_3D_ABOT; - if ((SIS_STATES & VERT_SMOOTH) == 0) - dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_MID; - } else { - x0 = v2->v.x; - y0 = v2->v.y; - x1 = v1->v.x; - dwPrimitiveSet |= OP_6326_3D_CTOP | OP_6326_3D_BMID | - OP_6326_3D_ABOT; - if ((SIS_STATES & VERT_SMOOTH) == 0) - dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_TOP; - } - x2 = v0->v.x; - y2 = v0->v.y; - } - } - - if (x1 <= x0 && x1 <= x2) { - dwPrimitiveSet |= OP_3D_DIRECTION_LEFT; - } else if (x1 < x0 || x1 < x2) { - GLfloat tmp; - - diffx02 = x0 - x2; - diffy02 = y0 - y2; - diffy12 = y1 - y2; - - delt02 = diffx02 / diffy02; - tmp = x1 - (diffy12 * delt02 + x2); - - if (tmp <= 0.0) - dwPrimitiveSet |= OP_3D_DIRECTION_LEFT; - } - - tv0 = *v0; - tv1 = *v1; - tv2 = *v2; - tv0.v.y = Y_FLIP(tv0.v.y); - tv1.v.y = Y_FLIP(tv1.v.y); - tv2.v.y = Y_FLIP(tv2.v.y); - v0 = &tv0; - v1 = &tv1; - v2 = &tv2; - - y0 = v0->v.y; - y1 = v1->v.y; - y2 = v2->v.y; - -/* fprintf(stderr, "Vertex0 %f %f %f\n", v0->v.x, v0->v.y, v0->v.z); - fprintf(stderr, "Vertex1 %f %f %f\n", v1->v.x, v1->v.y, v1->v.z); - fprintf(stderr, "Vertex2 %f %f %f\n", v2->v.x, v2->v.y, v2->v.z);*/ - mWait3DCmdQueue(MMIO_VERT_REG_COUNT * 3 + 1); - MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet); - SIS_MMIO_WRITE_VERTEX(v0, 0, 0); - SIS_MMIO_WRITE_VERTEX(v1, 1, 0); - SIS_MMIO_WRITE_VERTEX(v2, 2, 1); - mEndPrimitive(); -} - -static void TAG(sis6326_draw_line_mmio)(sisContextPtr smesa, char *verts) -{ - sisVertexPtr v0 = (sisVertexPtr)verts; - sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4); - GLint dwPrimitiveSet = smesa->dwPrimitiveSet; - - if (abs(v0->v.y - v1->v.y) > abs(v0->v.x - v1->v.x)) - { - dwPrimitiveSet |= OP_3D_DIRECTION_VERTICAL; - if (v0->v.y > v1->v.y) - dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_BBOT; - else - dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_ABOT; - } else { - if (v0->v.y > v1->v.y) - dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_ABOT; - else - dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_BBOT; - } - - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2 + 1); - MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet); - SIS_MMIO_WRITE_VERTEX(v0, 0, 0); - SIS_MMIO_WRITE_VERTEX(v1, 1, 1); -} - -static void TAG(sis6326_draw_point_mmio)(sisContextPtr smesa, char *verts) -{ - sisVertexPtr v0 = (sisVertexPtr)verts; - - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1 + 1); - MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet | OP_6326_3D_ATOP); - SIS_MMIO_WRITE_VERTEX(v0, 1, 1); -} -#endif - -static INLINE void TAG(sis_vert_init)( void ) -{ - sis_tri_func_mmio[SIS_STATES] = TAG(sis_draw_tri_mmio); - sis_line_func_mmio[SIS_STATES] = TAG(sis_draw_line_mmio); - sis_point_func_mmio[SIS_STATES] = TAG(sis_draw_point_mmio); -#if !(SIS_STATES & VERT_UV1) - sis_tri_func_mmio[SIS_STATES | VERT_6326] = TAG(sis6326_draw_tri_mmio); - sis_line_func_mmio[SIS_STATES | VERT_6326] = TAG(sis6326_draw_line_mmio); - sis_point_func_mmio[SIS_STATES | VERT_6326] = TAG(sis6326_draw_point_mmio); -#endif -} - -#undef TAG -#undef SIS_STATES diff --git a/src/mesa/drivers/dri/tdfx/BUGS b/src/mesa/drivers/dri/tdfx/BUGS deleted file mode 100644 index b15f6a91ed8..00000000000 --- a/src/mesa/drivers/dri/tdfx/BUGS +++ /dev/null @@ -1,64 +0,0 @@ -REMOVE THIS FILE BEFORE MERGING WITH TRUNK ------------------------------------------- - -OUTSTANDING BUGS - -demos/reflect - reading back Z on Voodoo3, image offset to right - Fixed in latest Glide. - -Q3 - some polygons drawn as vertical strips, similar to bug that was - seen in demos/fire. Voodoo3 only. May be related to glDepthMask - or glColorMask. - -book/fog - not fogging - Fog in orthograph mode still not implemented. Checking with - 3dfx engineers for ideas. - -Q3 demo crashes after changing display settings - but the full Q3 game version seems OK. - - - -MORE OUTSTANDING BUGS - -private context was NULL! causing immediate failure of any glx prog. cant -reproduce after restarting the X server. putting it down as halluc. - -texture object image was NULL, causing segmentation failure. happens with -prboom. ive put a check in tdfx_texstate.c but this isn't a fix. - -prboom, wall textures near first chainsaw aren't bound properly. sideways -movements causes the wall textures to move with you. prboom busted? - -16bpp mode, quake3, windowed, q3dm1, floor under rocketlauncher bands. it -looks like multitexturing gone wrong. i'll disable a tmu and test. - -sof, polygons appear at wrong x,y,z positions, intermittent, have not yet -found reliable way of reproducing. culling? sometimes polys disappear. - -descent3 is all black in 16bpp mode - FIXED (palette problems) - -smeared pixels in quake3 - FIXED (texture memory overlapped FB) - - - -PERFORMANCE COMPARISON (Brian / Alan) - - V3/16 is Voodoo3 in 16bpp on a P3/500 - V5/16 is Voodoo5 in 16bpp on a P3/600 - V5/32 is Voodoo5 in 32bpp on a P3/600 - V5A/16 is Voodoo5 in 16bpp on an Alpha AXP/600 - V5A/32 is Voodoo5 in 32bpp on an Alpha AXP/600 - - tdfx-2-1-branch tdfx-3-0-0-branch -demo V3/16 V5/16 V5/32 V3/16 V5/16 V5/32 V5A/16 V5A/32 ------------------------------------------------------------------------- -gloss 257 183 174 320 308 177 313 167 -fire 42 39 52 41 -fire (no help) 98 80 50 106 113 73 124 80 -tunnel 61 50 70 58 -tunnel (no help) 167 142 57 138 152 113 171 122 -gears 663 554 540 881 1232 776 1484 830 -teapot 20 21 37 36 -teapot (no help) 22 14 14 24 30 30 43 42 - diff --git a/src/mesa/drivers/dri/tdfx/Makefile b/src/mesa/drivers/dri/tdfx/Makefile deleted file mode 100644 index ed84df20925..00000000000 --- a/src/mesa/drivers/dri/tdfx/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# src/mesa/drivers/dri/tdfx/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = tdfx_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - tdfx_context.c \ - tdfx_dd.c \ - tdfx_lock.c \ - tdfx_pixels.c \ - tdfx_render.c \ - tdfx_screen.c \ - tdfx_span.c \ - tdfx_state.c \ - tdfx_tex.c \ - tdfx_texman.c \ - tdfx_texstate.c \ - tdfx_tris.c \ - tdfx_vb.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - - -ASM_SOURCES = - -include ../Makefile.targets - - diff --git a/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S b/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S deleted file mode 100644 index 500c97c536a..00000000000 --- a/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S +++ /dev/null @@ -1,83 +0,0 @@ - -#include "../../X86/assyntax.h" - -#define SETUP_RGBA 0x1 -#define SETUP_TMU0 0x2 -#define SETUP_TMU1 0x4 - - -/* Pack either rgba or texture into the remaining half of a 32 byte vertex. - */ -#define CLIP_R 24 -#define CLIP_G 16 -#define CLIP_B 20 -#define CLIP_A 28 /* defined inf fxdrv.h */ - -#define CLIP_S0 16 -#define CLIP_T0 20 -#define CLIP_S1 24 -#define CLIP_T1 28 - -#define SIZE 4 -#define TYPE (0) -#define TAG(x) x -#include "fx_3dnow_fasttmp.h" - -#define SIZE 8 -#define TYPE (SETUP_RGBA) -#define TAG(x) x##_RGBA -#include "fx_3dnow_fasttmp.h" - -#define SIZE 6 -#define TYPE (SETUP_TMU0) -#define TAG(x) x##_TMU0 -#include "fx_3dnow_fasttmp.h" - -#define SIZE 8 -#define TYPE (SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_TMU0_TMU1 -#include "fx_3dnow_fasttmp.h" - -#undef CLIP_S1 -#undef CLIP_T1 -#define CLIP_S1 16 -#define CLIP_T1 20 - -#define SIZE 6 -#define TYPE (SETUP_TMU1) -#define TAG(x) x##_TMU1 -#include "fx_3dnow_fasttmp.h" - -/* These three need to use a full 64 byte clip-space vertex. - */ -#undef CLIP_S0 -#undef CLIP_T0 -#undef CLIP_S1 -#undef CLIP_T1 - -#define CLIP_S0 32 -#define CLIP_T0 36 -#define CLIP_S1 40 -#define CLIP_T1 44 - -#define SIZE 10 -#define TYPE (SETUP_RGBA|SETUP_TMU0) -#define TAG(x) x##_RGBA_TMU0 -#include "fx_3dnow_fasttmp.h" - -#define SIZE 12 -#define TYPE (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_RGBA_TMU0_TMU1 -#include "fx_3dnow_fasttmp.h" - -#undef CLIP_S1 -#undef CLIP_T1 -#define CLIP_S1 32 -#define CLIP_T1 36 - -#define SIZE 10 -#define TYPE (SETUP_RGBA|SETUP_TMU1) -#define TAG(x) x##_RGBA_TMU1 -#include "fx_3dnow_fasttmp.h" - - diff --git a/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h b/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h deleted file mode 100644 index 78c5fef7469..00000000000 --- a/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h +++ /dev/null @@ -1,313 +0,0 @@ - -#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER) -#define TAGLLBL(a) TAG(.L##a) -#else -#define TAGLLBL(a) TAG(a) -#endif - -#if !GLIDE3 - -#define GR_VERTEX_X_OFFSET 0 -#define GR_VERTEX_Y_OFFSET 4 -#define GR_VERTEX_Z_OFFSET 8 -#define GR_VERTEX_R_OFFSET 12 -#define GR_VERTEX_G_OFFSET 16 -#define GR_VERTEX_B_OFFSET 20 -#define GR_VERTEX_OOZ_OFFSET 24 -#define GR_VERTEX_A_OFFSET 28 -#define GR_VERTEX_OOW_OFFSET 32 - -#else /* GLIDE3 */ - -#define GR_VERTEX_X_OFFSET 0 -#define GR_VERTEX_Y_OFFSET 4 -#define GR_VERTEX_OOZ_OFFSET 8 -#define GR_VERTEX_OOW_OFFSET 12 -#define GR_VERTEX_R_OFFSET 16 -#define GR_VERTEX_G_OFFSET 20 -#define GR_VERTEX_B_OFFSET 24 -#define GR_VERTEX_A_OFFSET 28 -#define GR_VERTEX_Z_OFFSET 32 - -#endif /* GLIDE3 */ - -#define GR_VERTEX_SOW_TMU0_OFFSET 36 -#define GR_VERTEX_TOW_TMU0_OFFSET 40 -#define GR_VERTEX_OOW_TMU0_OFFSET 44 -#define GR_VERTEX_SOW_TMU1_OFFSET 48 -#define GR_VERTEX_TOW_TMU1_OFFSET 52 -#define GR_VERTEX_OOW_TMU1_OFFSET 56 - - - - -/*#define MAT_SX 0 /* accessed by REGIND !! */ -#define MAT_SY 20 -#define MAT_SZ 40 -#define MAT_TX 48 -#define MAT_TY 52 -#define MAT_TZ 56 - - - - -/* Do viewport map, device scale and perspective projection. - * - * void project_verts( GLfloat *first, - * GLfloat *last, - * const GLfloat *m, - * GLuint stride ) - * - * - * Rearrange fxVertices to look like grVertices. - */ - -GLOBL GLNAME( TAG(fx_3dnow_project_vertices) ) -GLNAME( TAG(fx_3dnow_project_vertices) ): - - PUSH_L ( EBP ) - - MOV_L ( REGOFF(8, ESP), ECX ) /* first_vert */ - MOV_L ( REGOFF(12, ESP), EDX ) /* last_vert */ - - CMP_L ( ECX, EDX ) - JE ( TAGLLBL(FXPV_end) ) - - FEMMS - - PREFETCH ( REGIND(ECX) ) /* fetch the first vertex */ - - MOV_L ( REGOFF(16, ESP), EBP ) /* matrix */ - MOV_L ( REGOFF(20, ESP), EAX ) /* stride */ - - MOVD ( REGOFF(MAT_TX, EBP), MM6 ) /* | tx */ - PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 ) /* ty | tx */ - -#if !defined(FX_V2) - MOV_L ( CONST(0x49400000), REGOFF(-8, ESP) ) /* snapper */ - MOV_L ( CONST(0x49400000), REGOFF(-4, ESP) ) /* snapper */ -#endif - - MOVQ ( REGOFF(-8, ESP), MM4 ) /* snapper | snapper */ - PFADD ( MM4, MM6 ) /* ty+snapper | tx+snapper */ - - MOVD ( REGIND(EBP), MM5 ) - PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 ) /* vsy | vsx */ - - MOVD ( REGOFF(MAT_SZ, EBP), MM1 ) /* | vsz */ - - -ALIGNTEXT32 -TAGLLBL(FXPV_loop_start): - - PREFETCH ( REGOFF(64, ECX) ) /* fetch the next-ish vertex */ - - - MOVD ( REGOFF(12, ECX), MM0 ) /* | f[3] */ - PFRCP ( MM0, MM0 ) /* oow = 1/f[3] */ - - MOVD ( REGOFF(12, ECX), MM7 ) /* | f[3] */ - PFRCPIT1 ( MM0, MM7 ) - PFRCPIT2 ( MM0, MM7 ) /* oow | oow */ - - PUNPCKLDQ ( MM7, MM7 ) - - -#if (TYPE & SETUP_RGBA) - MOVD ( REGOFF(CLIP_R, ECX ), MM0 ) /* f[RCOORD] = f[CLIP_R]; */ - MOVD ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) ) -#endif - -#if (TYPE & SETUP_TMU1) - MOVQ ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow */ - PFMUL ( MM7, MM0 ) /* f[T1COORD] = f[CLIP_T1] * oow */ - MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) ) -#endif - - -#if (TYPE & SETUP_TMU0) - MOVQ ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow */ - PFMUL ( MM7, MM0 ) /* f[T0COORD] = f[CLIP_T0] * oow */ - MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) ) -#endif - - - - - -/* DO_SETUP_XYZ */ - - MOVQ ( REGIND(ECX), MM2 ) /* f[1] | f[0] */ - PFMUL ( MM7, MM2 ) /* f[1] * oow | f[0] * oow */ - - MOVD ( REGOFF(8, ECX), MM3 ) /* | f[2] */ - PFMUL ( MM7, MM3 ) /* | f[2] * oow */ - - MOVD ( REGOFF(MAT_TZ, EBP), MM0 ) /* | vtz */ - PFMUL ( MM1, MM3 ) /* | f[2] *= vsz */ - - PFADD ( MM0, MM3 ) /* | f[2] += vtz */ - PFMUL ( MM5, MM2 ) /* f[1] *= vsy | f[0] *= vsx */ - - PFADD ( MM6, MM2 ) /* f[1] += vty | f[0] += vtx */ - -#if !defined(FX_V2) - PFSUB ( MM4, MM2 ) /* f[0,1] -= snapper */ -#endif - - MOVQ ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) ) - MOVD ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) ) - - -/* end of DO_SETUP_XYZ */ - - MOVD ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */ - ADD_L ( EAX, ECX ) /* f += stride */ - - CMP_L ( ECX, EDX ) /* stall??? */ - JA ( TAGLLBL(FXPV_loop_start) ) - -TAGLLBL(FXPV_end): - FEMMS - POP_L ( EBP ) - RET - - - - - - - -/* void project_verts( GLfloat *first, - * GLfloat *last, - * const GLfloat *m, - * GLuint stride, - * const GLubyte *mask ) - * - */ - -GLOBL GLNAME( TAG(fx_3dnow_project_clipped_vertices) ) -GLNAME( TAG(fx_3dnow_project_clipped_vertices) ): - - PUSH_L ( EBP ) - - MOV_L ( REGOFF(8, ESP), ECX ) /* first FXDRIVER(VB)->verts*/ - MOV_L ( REGOFF(12, ESP), EDX ) /* last FXDRIVER(VB)->last_vert */ - - FEMMS - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - - PREFETCH ( REGIND(ECX) ) /* fetch the first vertex */ - - MOV_L ( REGOFF(24, ESP), EBP ) /* mat ctx->Viewport.WindowMap.M */ - MOV_L ( REGOFF(28, ESP), EAX ) /* stride */ - MOV_L ( REGOFF(32, ESP), ESI ) /* VB->ClipMask */ - - MOVD ( REGOFF(MAT_TX, EBP), MM6 ) /* | tx */ - PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 ) /* ty | tx */ - -#if !defined(FX_V2) - MOV_L ( CONST(0x49400000), REGOFF(-8, ESP) ) /* snapper */ - MOV_L ( CONST(0x49400000), REGOFF(-4, ESP) ) /* snapper */ -#endif - - MOVQ ( REGOFF(-8, ESP), MM4 ) /* snapper | snapper */ - PFADD ( MM4, MM6 ) /* ty+snapper | tx+snapper */ - - MOVD ( REGIND(EBP), MM5 ) - PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 ) /* vsy | vsx */ - - MOVD ( REGOFF(MAT_SZ, EBP), MM1 ) /* | vsz */ - - - -ALIGNTEXT32 -TAGLLBL(FXPCV_loop_start): - - PREFETCH ( REGOFF(64, ECX) ) /* fetch the next-ish vertex */ - - CMP_B ( CONST(0), REGIND(ESI) ) - JNE ( TAGLLBL(FXPCV_skip) ) - - MOVD ( REGOFF(12, ECX), MM0) /* | f[3] */ - PFRCP ( MM0, MM0 ) /* oow = 1/f[3] */ - - MOVD ( REGOFF(12, ECX), MM7) /* | f[3] */ - PFRCPIT1 ( MM0, MM7 ) - PFRCPIT2 ( MM0, MM7 ) /* oow | oow */ - - PUNPCKLDQ ( MM7, MM7 ) - - -#if (TYPE & SETUP_RGBA) - MOVD ( REGOFF(CLIP_R, ECX ), MM0 ) /* f[RCOORD] = f[CLIP_R]; */ - MOVD ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) ) -#endif - -#if (TYPE & SETUP_TMU1) - MOVQ ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow */ - PFMUL ( MM7, MM0 ) /* f[T1COORD] = f[CLIP_T1] * oow */ - MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) ) -#endif - - -#if (TYPE & SETUP_TMU0) - MOVQ ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow */ - PFMUL ( MM7, MM0 ) /* f[T0COORD] = f[CLIP_T0] * oow */ - MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) ) -#endif - - - - -/* DO_SETUP_XYZ */ - - MOVQ ( REGIND(ECX), MM2 ) /* f[1] | f[0] */ - PFMUL ( MM7, MM2 ) /* f[1] * oow | f[0] * oow */ - - MOVD ( REGOFF(8, ECX), MM3 ) /* | f[2] */ - PFMUL ( MM7, MM3 ) /* | f[2] * oow */ - - MOVD ( REGOFF(MAT_TZ, EBP), MM0 ) /* | vtz */ - PFMUL ( MM1, MM3 ) /* | f[2] *= vsz */ - - PFADD ( MM0, MM3 ) /* | f[2] += vtz */ - PFMUL ( MM5, MM2 ) /* f[1] *= vsy | f[0] *= vsx */ - - PFADD ( MM6, MM2 ) /* f[1] += vty | f[0] += vtx */ - -#if !defined(FX_V2) - PFSUB ( MM4, MM2 ) /* f[0,1] -= snapper */ -#endif - - MOVQ ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) ) - MOVD ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) ) - - -/* end of DO_SETUP_XYZ */ - - MOVD ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */ - -TAGLLBL(FXPCV_skip): - ADD_L ( EAX, ECX ) /* f += stride */ - - INC_L ( ESI ) /* next ClipMask */ - CMP_L ( ECX, EDX ) - JA ( TAGLLBL(FXPCV_loop_start) ) - - POP_L ( ESI ) - POP_L ( EDI ) - -TAGLLBL(FXPCV_end): - FEMMS - POP_L ( EBP ) - RET - - - -#undef TYPE -#undef TAG -#undef SIZE - diff --git a/src/mesa/drivers/dri/tdfx/dri_glide.h b/src/mesa/drivers/dri/tdfx/dri_glide.h deleted file mode 100644 index 3ad2bf68c6e..00000000000 --- a/src/mesa/drivers/dri/tdfx/dri_glide.h +++ /dev/null @@ -1,59 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __DRI_GLIDE_H__ -#define __DRI_GLIDE_H__ - -#include <glide.h> -#include "dri_mesaint.h" - -/* - * This is the private interface between Glide and the DRI. - */ -extern void grDRIOpen( char *pFB, char *pRegs, int deviceID, - int width, int height, - int mem, int cpp, int stride, - int fifoOffset, int fifoSize, - int fbOffset, int backOffset, int depthOffset, - int textureOffset, int textureSize, - volatile int *fifoPtr, volatile int *fifoRead ); -extern void grDRIPosition( int x, int y, int w, int h, - int numClip, drm_clip_rect_t *pClip ); -extern void grDRILostContext( void ); -extern void grDRIImportFifo( int fifoPtr, int fifoRead ); -extern void grDRIInvalidateAll( void ); -extern void grDRIResetSAREA( void ); -extern void grDRIBufferSwap( FxU32 swapInterval ); -#endif diff --git a/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h b/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h deleted file mode 100644 index dc29984a272..00000000000 --- a/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef _TDFX_DRI_ -#define _TDFX_DRI_ - -#include "xf86drm.h" -#include "drm.h" - -typedef struct { - drm_handle_t regs; - drmSize regsSize; - int deviceID; - int width; - int height; - int mem; - int cpp; - int stride; - int fifoOffset; - int fifoSize; - int fbOffset; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; - unsigned int sarea_priv_offset; -} TDFXDRIRec, *TDFXDRIPtr; - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c deleted file mode 100644 index ad151359e67..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.c +++ /dev/null @@ -1,1013 +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. - */ - -/** - * \file tdfx_context.c - * Context management functions for 3Dfx hardware. - * - * \author Gareth Hughes <[email protected]> (original rewrite 29 Sep - 1 Oct 2000) - * \author Brian Paul <[email protected]> - * \author Daniel Borca <[email protected]> (new fixes 19 Jul 2004) - */ - -#include <dlfcn.h> -#include "tdfx_context.h" -#include "tdfx_dd.h" -#include "tdfx_state.h" -#include "tdfx_vb.h" -#include "tdfx_tex.h" -#include "tdfx_tris.h" -#include "tdfx_render.h" -#include "tdfx_span.h" -#include "tdfx_texman.h" -#include "main/extensions.h" -#include "main/hash.h" -#include "main/texobj.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "utils.h" - -/* #define need_GL_ARB_point_parameters */ -#define need_GL_ARB_occlusion_query -/* #define need_GL_ARB_vertex_program */ -#define need_GL_EXT_blend_equation_separate -#define need_GL_EXT_blend_func_separate -#define need_GL_EXT_blend_minmax -#define need_GL_EXT_fog_coord -#define need_GL_EXT_paletted_texture -/* #define need_GL_EXT_secondary_color */ -/* #define need_GL_NV_vertex_program */ -#include "main/remap_helper.h" - - -/** - * Common extension strings exported by all cards - */ -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - - { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions }, - { "GL_EXT_shared_texture_palette", NULL }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_EXT_texture_env_add", NULL }, - { "GL_EXT_texture_lod_bias", NULL }, - -#ifdef need_GL_ARB_point_parameters - { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, - { "GL_ARB_point_sprite", NULL }, -#endif -#ifdef need_GL_EXT_secondary_color - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, -#endif -#ifdef need_GL_ARB_vertex_program - { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions } -#endif -#ifdef need_GL_NV_vertex_program - { "GL_NV_vertex_program", GL_NV_vertex_program_functions } - { "GL_NV_vertex_program1_1", NULL }, -#endif - { NULL, NULL } -}; - -/** - * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards. - */ -static const struct dri_extension napalm_extensions[] = -{ - { "GL_ARB_texture_env_combine", NULL }, - { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions }, - { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions }, - { "GL_EXT_texture_compression_s3tc", NULL }, - { "GL_EXT_texture_env_combine", NULL }, - - { "GL_3DFX_texture_compression_FXT1", NULL }, - { "GL_NV_blend_square", NULL }, - { "GL_S3_s3tc", NULL }, - { NULL, NULL } -}; - -/* - * Enable/Disable the extensions for this context. - */ -static void tdfxDDInitExtensions( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - driInitExtensions( ctx, card_extensions, GL_FALSE ); - - if ( fxMesa->haveTwoTMUs ) { - _mesa_enable_extension( ctx, "GL_ARB_multitexture" ); - } - - if ( TDFX_IS_NAPALM( fxMesa ) ) { - driInitExtensions( ctx, napalm_extensions, GL_FALSE ); - } -} - - - -static const struct tnl_pipeline_stage *tdfx_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_point_attenuation_stage, - &_tnl_render_stage, - 0, -}; - -static const struct dri_debug_control debug_control[] = -{ - { "dri", DEBUG_VERBOSE_DRI }, - { "sync", DEBUG_ALWAYS_SYNC }, - { "api", DEBUG_VERBOSE_API }, - { "fall", DEBUG_VERBOSE_FALL }, - { NULL, 0 } -}; - -GLboolean tdfxCreateContext( gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ) -{ - tdfxContextPtr fxMesa; - struct gl_context *ctx, *shareCtx; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private; - TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA + - sizeof(drm_sarea_t)); - struct dd_function_table functions; - - /* Allocate tdfx context */ - fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) ); - if (!fxMesa) - return GL_FALSE; - - /* Init default driver functions then plug in our tdfx-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions(&functions); - tdfxDDInitDriverFuncs(mesaVis, &functions); - tdfxInitTextureFuncs(&functions); - tdfxInitRenderFuncs(&functions); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - fxMesa->glCtx = _mesa_create_context(api, mesaVis, shareCtx, - &functions, (void *) fxMesa); - if (!fxMesa->glCtx) { - FREE(fxMesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = fxMesa; - - /* Mirror some important DRI state - */ - fxMesa->hHWContext = driContextPriv->hHWContext; - fxMesa->driHwLock = &sPriv->pSAREA->lock; - fxMesa->driFd = sPriv->fd; - - fxMesa->driScreen = sPriv; - fxMesa->driContext = driContextPriv; - fxMesa->fxScreen = fxScreen; - fxMesa->sarea = saPriv; - - /*JJJ - really?*/ - fxMesa->haveHwAlpha = ( mesaVis->alphaBits && - ((mesaVis->greenBits == 8) || - (mesaVis->depthBits == 0)) ); - fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) && - 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; - - /* Parse configuration files */ - driParseConfigFiles (&fxMesa->optionCache, &fxScreen->optionCache, - fxMesa->driScreen->myNum, "tdfx"); - - /* NOTE: This must be here before any Glide calls! */ - if (!tdfxInitGlide( fxMesa )) { - FREE(fxMesa); - return GL_FALSE; - } - - fxMesa->Glide.grDRIOpen( (char*) sPriv->pFB, fxScreen->regs.map, fxScreen->deviceID, - fxScreen->width, fxScreen->height, fxScreen->mem, fxScreen->cpp, - fxScreen->stride, fxScreen->fifoOffset, fxScreen->fifoSize, - fxScreen->fbOffset, fxScreen->backOffset, fxScreen->depthOffset, - fxScreen->textureOffset, fxScreen->textureSize, &saPriv->fifoPtr, - &saPriv->fifoRead ); - - if ( getenv( "FX_GLIDE_SWAPINTERVAL" ) ) { - fxMesa->Glide.SwapInterval = atoi( getenv( "FX_GLIDE_SWAPINTERVAL" ) ); - } else { - fxMesa->Glide.SwapInterval = 0; - } - if ( getenv( "FX_MAX_PENDING_SWAPS" ) ) { - fxMesa->Glide.MaxPendingSwaps = atoi( getenv( "FX_MAX_PENDING_SWAPS" ) ); - } else { - fxMesa->Glide.MaxPendingSwaps = 2; - } - - fxMesa->Glide.Initialized = GL_FALSE; - fxMesa->Glide.Board = 0; - - - 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; - fxMesa->stats.reqTexUpload = 0; - fxMesa->stats.texUpload = 0; - fxMesa->stats.memTexUpload = 0; - - fxMesa->tmuSrc = TDFX_TMU_NONE; - - ctx = fxMesa->glCtx; - if ( TDFX_IS_NAPALM( fxMesa ) ) { - ctx->Const.MaxTextureLevels = 12; - } else { - ctx->Const.MaxTextureLevels = 9; - } - ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2; - ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; - ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; - - /* No wide points. - */ - ctx->Const.MinPointSize = 1.0; - ctx->Const.MinPointSizeAA = 1.0; - ctx->Const.MaxPointSize = 1.0; - ctx->Const.MaxPointSizeAA = 1.0; - - /* 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; - - ctx->Const.MaxDrawBuffers = 1; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, tdfx_pipeline ); - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_TRUE ); - _swrast_allow_vertex_fog( ctx, GL_FALSE ); - _tnl_allow_pixel_fog( ctx, GL_TRUE ); - _tnl_allow_vertex_fog( ctx, GL_FALSE ); - - tdfxDDInitExtensions( ctx ); - /* XXX these should really go right after _mesa_init_driver_functions() */ - tdfxDDInitSpanFuncs( ctx ); - tdfxDDInitStateFuncs( ctx ); - tdfxDDInitTriFuncs( ctx ); - tdfxInitVB( ctx ); - tdfxInitState( fxMesa ); - -#if DO_DEBUG - TDFX_DEBUG = driParseDebugString( getenv( "TDFX_DEBUG" ), debug_control ); -#endif - - if (driQueryOptionb(&fxMesa->optionCache, "no_rast")) { - fprintf(stderr, "disabling 3D acceleration\n"); - FALLBACK(fxMesa, TDFX_FALLBACK_DISABLE, 1); - } - - return GL_TRUE; -} - - -static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa ) -{ - FxI32 result; - int i; - - LOCK_HARDWARE( fxMesa ); - - fxMesa->Glide.grGet( GR_GLIDE_VERTEXLAYOUT_SIZE, sizeof(FxI32), &result ); - for ( i = 0 ; i < TDFX_NUM_LAYOUTS ; i++ ) { - fxMesa->layout[i] = MALLOC( result ); - if ( !fxMesa->layout[i] ) { - UNLOCK_HARDWARE( fxMesa ); - return GL_FALSE; - } - } - - /* 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_ARGB_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.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 ); - 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 ); - 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.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] ); - - /* Projected texture vertex format - 36 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_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ1] ); - - /* Projected multitexture 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_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 ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ2] ); - - UNLOCK_HARDWARE( fxMesa ); - - return GL_TRUE; -} - - -/* - * Initialize the state in an tdfxContextPtr struct. - */ -static GLboolean -tdfxInitContext( __DRIdrawable *driDrawPriv, tdfxContextPtr fxMesa ) -{ - /* KW: Would be nice to make one of these a member of the other. - */ - FxI32 result[2]; - const char *gext; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa ); - } - -#if DEBUG_LOCKING - fprintf(stderr, "Debug locking enabled\n"); -#endif - - if ( fxMesa->Glide.Initialized ) - return GL_TRUE; - - fxMesa->width = driDrawPriv->w; - fxMesa->height = driDrawPriv->h; - - /* We have to use a light lock here, because we can't do any glide - * operations yet. No use of FX_* functions in this function. - */ - DRM_LIGHT_LOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); - - fxMesa->Glide.grGlideInit(); - fxMesa->Glide.grSstSelect( fxMesa->Glide.Board ); - - fxMesa->Glide.Context = fxMesa->Glide.grSstWinOpen( (FxU32) -1, - GR_RESOLUTION_NONE, - GR_REFRESH_NONE, - fxMesa->Glide.ColorFormat, - fxMesa->Glide.Origin, - 2, 1 ); - - fxMesa->Glide.grDRIResetSAREA(); - - DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); - - if ( !fxMesa->Glide.Context ) - return GL_FALSE; - - - /* Perform the Glide-dependant part of the context initialization. - */ - FX_grColorMaskv( fxMesa->glCtx, true4 ); - - tdfxTMInit( fxMesa ); - - LOCK_HARDWARE( fxMesa ); - - /* JJJ - COMMAND_TRANSPORT, PALETTE6666 */ - gext = fxMesa->Glide.grGetString( GR_EXTENSION ); - fxMesa->Glide.HaveCombineExt = strstr(gext, "COMBINE") && !getenv("MESA_FX_IGNORE_CMBEXT"); - fxMesa->Glide.HaveCommandTransportExt = GL_FALSE; - fxMesa->Glide.HaveFogCoordExt = GL_TRUE; - fxMesa->Glide.HavePixelExt = strstr(gext, "PIXEXT") && !getenv("MESA_FX_IGNORE_PIXEXT"); - fxMesa->Glide.HaveTextureBufferExt = GL_TRUE; - fxMesa->Glide.HaveTexFmtExt = strstr(gext, "TEXFMT") && !getenv("MESA_FX_IGNORE_TEXFMT"); - fxMesa->Glide.HaveTexUMAExt = strstr(gext, "TEXUMA") && !getenv("MESA_FX_IGNORE_TEXUMA"); - fxMesa->Glide.HaveMirrorExt = strstr(gext, "TEXMIRROR") && !getenv("MESA_FX_IGNORE_MIREXT"); - fxMesa->Glide.HaveTexus2 = GL_FALSE; - - if ( fxMesa->glCtx->Visual.depthBits > 0 ) { - fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); - } else { - fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_DISABLE); - } - - fxMesa->Glide.grLfbWriteColorFormat( GR_COLORFORMAT_ABGR ); - - fxMesa->Glide.grGet( GR_TEXTURE_ALIGN, sizeof(FxI32), result ); - fxMesa->Glide.TextureAlign = result[0]; - - fxMesa->Glide.State = NULL; - fxMesa->Glide.grGet( GR_GLIDE_STATE_SIZE, sizeof(FxI32), result ); - fxMesa->Glide.State = MALLOC( result[0] ); - - fxMesa->Fog.Table = NULL; - fxMesa->Glide.grGet( GR_FOG_TABLE_ENTRIES, sizeof(FxI32), result ); - fxMesa->Fog.Table = MALLOC( result[0] * sizeof(GrFog_t) ); - - UNLOCK_HARDWARE( fxMesa ); - - if ( !fxMesa->Glide.State || !fxMesa->Fog.Table ) { - if ( fxMesa->Glide.State ) - FREE( fxMesa->Glide.State ); - if ( fxMesa->Fog.Table ) - FREE( fxMesa->Fog.Table ); - return GL_FALSE; - } - - if ( !tdfxInitVertexFormats( fxMesa ) ) { - return GL_FALSE; - } - - LOCK_HARDWARE( fxMesa ); - - fxMesa->Glide.grGlideGetState( fxMesa->Glide.State ); - - if ( getenv( "FX_GLIDE_INFO" ) ) { - printf( "GR_RENDERER = %s\n", (char *) fxMesa->Glide.grGetString( GR_RENDERER ) ); - printf( "GR_VERSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_VERSION ) ); - printf( "GR_VENDOR = %s\n", (char *) fxMesa->Glide.grGetString( GR_VENDOR ) ); - printf( "GR_HARDWARE = %s\n", (char *) fxMesa->Glide.grGetString( GR_HARDWARE ) ); - printf( "GR_EXTENSION = %s\n", (char *) gext ); - } - - UNLOCK_HARDWARE( fxMesa ); - - fxMesa->numClipRects = 0; - fxMesa->pClipRects = NULL; - fxMesa->scissoredClipRects = GL_FALSE; - - fxMesa->Glide.Initialized = GL_TRUE; - - return GL_TRUE; -} - - -void -tdfxDestroyContext( __DRIcontext *driContextPriv ) -{ - tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa ); - } - - if ( fxMesa ) { - if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) { - /* This share group is about to go away, free our private - * texture object data. - */ - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj - = _mesa_lookup_texture(fxMesa->glCtx, id); - tdfxTMFreeTexture(fxMesa, tObj); - } - } - - tdfxTMClose(fxMesa); /* free texture memory */ - - _swsetup_DestroyContext( fxMesa->glCtx ); - _tnl_DestroyContext( fxMesa->glCtx ); - _vbo_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 */ - FREE( fxMesa ); - } -} - - -GLboolean -tdfxUnbindContext( __DRIcontext *driContextPriv ) -{ - GET_CURRENT_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv ); - } - - if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) { - LOCK_HARDWARE(fxMesa); - fxMesa->Glide.grGlideGetState(fxMesa->Glide.State); - UNLOCK_HARDWARE(fxMesa); - } - return GL_TRUE; -} - - -GLboolean -tdfxMakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ) -{ - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv ); - } - - if ( driContextPriv ) { - tdfxContextPtr newFx = (tdfxContextPtr) driContextPriv->driverPrivate; - struct gl_context *newCtx = newFx->glCtx; - GET_CURRENT_CONTEXT(curCtx); - - if ((newFx->driDrawable != driDrawPriv) - || (newFx->driReadable != driReadPriv)) { - newFx->driDrawable = driDrawPriv; - newFx->driReadable = driReadPriv; - 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_current( newCtx, - (struct gl_framebuffer *) driDrawPriv->driverPrivate, - (struct gl_framebuffer *) driReadPriv->driverPrivate ); - return GL_TRUE; - } - /* [dBorca] tunnel2 requires this */ - newFx->dirty = ~0; - } - - driUpdateFramebufferSize(newCtx, driDrawPriv); - if (driDrawPriv != driReadPriv) { - driUpdateFramebufferSize(newCtx, driReadPriv); - } - - 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_current( newCtx, - (struct gl_framebuffer *) driDrawPriv->driverPrivate, - (struct gl_framebuffer *) driReadPriv->driverPrivate ); - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - 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 - * is installed. dlopen() the appropriate Glide library and initialize - * this context's Glide function pointers. - * Return: true/false = success/failure - */ -GLboolean tdfxInitGlide(tdfxContextPtr tmesa) -{ - static const char *defaultGlide = "libglide3.so"; - const char *libName; - void *libHandle; - - /* - * XXX this code which selects a Glide library filename given the - * deviceID may need to be cleaned up a bit. - * Non-Linux systems may have different filenames, for example. - */ - switch (tmesa->fxScreen->deviceID) { - case PCI_CHIP_BANSHEE: - case PCI_CHIP_VOODOO3: - libName = "libglide3-v3.so"; - break; - case PCI_CHIP_VOODOO5: /* same as PCI_CHIP_VOODOO4 */ - libName = "libglide3-v5.so"; - break; - default: - { - __driUtilMessage("unrecognized 3dfx deviceID: 0x%x", - tmesa->fxScreen->deviceID); - } - return GL_FALSE; - } - - libHandle = dlopen(libName, RTLD_NOW); - if (!libHandle) { - /* The device-specific Glide library filename didn't work, try the - * old, generic libglide3.so library. - */ - libHandle = dlopen(defaultGlide, RTLD_NOW); - if (!libHandle) { - __driUtilMessage( - "can't find Glide library, dlopen(%s) and dlopen(%s) both failed.", - libName, defaultGlide); - __driUtilMessage("dlerror() message: %s", dlerror()); - return GL_FALSE; - } - libName = defaultGlide; - } - - { - const char *env = getenv("LIBGL_DEBUG"); - if (env && strstr(env, "verbose")) { - fprintf(stderr, "libGL: using Glide library %s\n", libName); - } - } - -#define GET_FUNCTION(PTR, NAME) \ - tmesa->Glide.PTR = dlsym(libHandle, NAME); \ - if (!tmesa->Glide.PTR) { \ - __driUtilMessage("couldn't find Glide function %s in %s.", \ - NAME, libName); \ - } - - GET_FUNCTION(grDrawPoint, "grDrawPoint"); - GET_FUNCTION(grDrawLine, "grDrawLine"); - GET_FUNCTION(grDrawTriangle, "grDrawTriangle"); - GET_FUNCTION(grVertexLayout, "grVertexLayout"); - GET_FUNCTION(grDrawVertexArray, "grDrawVertexArray"); - GET_FUNCTION(grDrawVertexArrayContiguous, "grDrawVertexArrayContiguous"); - GET_FUNCTION(grBufferClear, "grBufferClear"); - /*GET_FUNCTION(grBufferSwap, "grBufferSwap");*/ - GET_FUNCTION(grRenderBuffer, "grRenderBuffer"); - GET_FUNCTION(grErrorSetCallback, "grErrorSetCallback"); - GET_FUNCTION(grFinish, "grFinish"); - GET_FUNCTION(grFlush, "grFlush"); - GET_FUNCTION(grSstWinOpen, "grSstWinOpen"); - GET_FUNCTION(grSstWinClose, "grSstWinClose"); -#if 0 - /* Not in V3 lib, and not used anyway. */ - GET_FUNCTION(grSetNumPendingBuffers, "grSetNumPendingBuffers"); -#endif - GET_FUNCTION(grSelectContext, "grSelectContext"); - GET_FUNCTION(grSstOrigin, "grSstOrigin"); - GET_FUNCTION(grSstSelect, "grSstSelect"); - GET_FUNCTION(grAlphaBlendFunction, "grAlphaBlendFunction"); - GET_FUNCTION(grAlphaCombine, "grAlphaCombine"); - GET_FUNCTION(grAlphaControlsITRGBLighting, "grAlphaControlsITRGBLighting"); - GET_FUNCTION(grAlphaTestFunction, "grAlphaTestFunction"); - GET_FUNCTION(grAlphaTestReferenceValue, "grAlphaTestReferenceValue"); - GET_FUNCTION(grChromakeyMode, "grChromakeyMode"); - GET_FUNCTION(grChromakeyValue, "grChromakeyValue"); - GET_FUNCTION(grClipWindow, "grClipWindow"); - GET_FUNCTION(grColorCombine, "grColorCombine"); - GET_FUNCTION(grColorMask, "grColorMask"); - GET_FUNCTION(grCullMode, "grCullMode"); - GET_FUNCTION(grConstantColorValue, "grConstantColorValue"); - GET_FUNCTION(grDepthBiasLevel, "grDepthBiasLevel"); - GET_FUNCTION(grDepthBufferFunction, "grDepthBufferFunction"); - GET_FUNCTION(grDepthBufferMode, "grDepthBufferMode"); - GET_FUNCTION(grDepthMask, "grDepthMask"); - GET_FUNCTION(grDisableAllEffects, "grDisableAllEffects"); - GET_FUNCTION(grDitherMode, "grDitherMode"); - GET_FUNCTION(grFogColorValue, "grFogColorValue"); - GET_FUNCTION(grFogMode, "grFogMode"); - GET_FUNCTION(grFogTable, "grFogTable"); - GET_FUNCTION(grLoadGammaTable, "grLoadGammaTable"); - GET_FUNCTION(grSplash, "grSplash"); - GET_FUNCTION(grGet, "grGet"); - GET_FUNCTION(grGetString, "grGetString"); - GET_FUNCTION(grQueryResolutions, "grQueryResolutions"); - GET_FUNCTION(grReset, "grReset"); - GET_FUNCTION(grGetProcAddress, "grGetProcAddress"); - GET_FUNCTION(grEnable, "grEnable"); - GET_FUNCTION(grDisable, "grDisable"); - GET_FUNCTION(grCoordinateSpace, "grCoordinateSpace"); - GET_FUNCTION(grDepthRange, "grDepthRange"); - GET_FUNCTION(grStippleMode, "grStippleMode"); - GET_FUNCTION(grStipplePattern, "grStipplePattern"); - GET_FUNCTION(grViewport, "grViewport"); - GET_FUNCTION(grTexCalcMemRequired, "grTexCalcMemRequired"); - GET_FUNCTION(grTexTextureMemRequired, "grTexTextureMemRequired"); - GET_FUNCTION(grTexMinAddress, "grTexMinAddress"); - GET_FUNCTION(grTexMaxAddress, "grTexMaxAddress"); - GET_FUNCTION(grTexNCCTable, "grTexNCCTable"); - GET_FUNCTION(grTexSource, "grTexSource"); - GET_FUNCTION(grTexClampMode, "grTexClampMode"); - GET_FUNCTION(grTexCombine, "grTexCombine"); - GET_FUNCTION(grTexDetailControl, "grTexDetailControl"); - GET_FUNCTION(grTexFilterMode, "grTexFilterMode"); - GET_FUNCTION(grTexLodBiasValue, "grTexLodBiasValue"); - GET_FUNCTION(grTexDownloadMipMap, "grTexDownloadMipMap"); - GET_FUNCTION(grTexDownloadMipMapLevel, "grTexDownloadMipMapLevel"); - GET_FUNCTION(grTexDownloadMipMapLevelPartial, "grTexDownloadMipMapLevelPartial"); - GET_FUNCTION(grTexDownloadTable, "grTexDownloadTable"); - GET_FUNCTION(grTexDownloadTablePartial, "grTexDownloadTablePartial"); - GET_FUNCTION(grTexMipMapMode, "grTexMipMapMode"); - GET_FUNCTION(grTexMultibase, "grTexMultibase"); - GET_FUNCTION(grTexMultibaseAddress, "grTexMultibaseAddress"); - GET_FUNCTION(grLfbLock, "grLfbLock"); - GET_FUNCTION(grLfbUnlock, "grLfbUnlock"); - GET_FUNCTION(grLfbConstantAlpha, "grLfbConstantAlpha"); - GET_FUNCTION(grLfbConstantDepth, "grLfbConstantDepth"); - GET_FUNCTION(grLfbWriteColorSwizzle, "grLfbWriteColorSwizzle"); - GET_FUNCTION(grLfbWriteColorFormat, "grLfbWriteColorFormat"); - GET_FUNCTION(grLfbWriteRegion, "grLfbWriteRegion"); - GET_FUNCTION(grLfbReadRegion, "grLfbReadRegion"); - GET_FUNCTION(grGlideInit, "grGlideInit"); - GET_FUNCTION(grGlideShutdown, "grGlideShutdown"); - GET_FUNCTION(grGlideGetState, "grGlideGetState"); - GET_FUNCTION(grGlideSetState, "grGlideSetState"); - GET_FUNCTION(grGlideGetVertexLayout, "grGlideGetVertexLayout"); - GET_FUNCTION(grGlideSetVertexLayout, "grGlideSetVertexLayout"); - - /* Glide utility functions */ - GET_FUNCTION(guFogGenerateExp, "guFogGenerateExp"); - GET_FUNCTION(guFogGenerateExp2, "guFogGenerateExp2"); - GET_FUNCTION(guFogGenerateLinear, "guFogGenerateLinear"); - - /* DRI functions */ - GET_FUNCTION(grDRIOpen, "grDRIOpen"); - GET_FUNCTION(grDRIPosition, "grDRIPosition"); - /*GET_FUNCTION(grDRILostContext, "grDRILostContext");*/ - GET_FUNCTION(grDRIImportFifo, "grDRIImportFifo"); - GET_FUNCTION(grDRIInvalidateAll, "grDRIInvalidateAll"); - GET_FUNCTION(grDRIResetSAREA, "grDRIResetSAREA"); - GET_FUNCTION(grDRIBufferSwap, "grDRIBufferSwap"); - - /* - * Extension functions: - * Just use dlysm() because we want a NULL pointer if the function is - * not found. - */ - /* PIXEXT extension */ - tmesa->Glide.grStencilFunc = dlsym(libHandle, "grStencilFunc"); - tmesa->Glide.grStencilMask = dlsym(libHandle, "grStencilMask"); - tmesa->Glide.grStencilOp = dlsym(libHandle, "grStencilOp"); - tmesa->Glide.grBufferClearExt = dlsym(libHandle, "grBufferClearExt"); - tmesa->Glide.grColorMaskExt = dlsym(libHandle, "grColorMaskExt"); - /* COMBINE extension */ - tmesa->Glide.grColorCombineExt = dlsym(libHandle, "grColorCombineExt"); - tmesa->Glide.grTexColorCombineExt = dlsym(libHandle, "grTexColorCombineExt"); - tmesa->Glide.grAlphaCombineExt = dlsym(libHandle, "grAlphaCombineExt"); - tmesa->Glide.grTexAlphaCombineExt = dlsym(libHandle, "grTexAlphaCombineExt"); - tmesa->Glide.grAlphaBlendFunctionExt = dlsym(libHandle, "grAlphaBlendFunctionExt"); - tmesa->Glide.grConstantColorValueExt = dlsym(libHandle, "grConstantColorValueExt"); - /* Texus 2 */ - tmesa->Glide.txImgQuantize = dlsym(libHandle, "txImgQuantize"); - 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/src/mesa/drivers/dri/tdfx/tdfx_context.h b/src/mesa/drivers/dri/tdfx/tdfx_context.h deleted file mode 100644 index 7e2f0e00a8e..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.h +++ /dev/null @@ -1,1013 +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. - */ - -/* - * New fixes: - * Daniel Borca <[email protected]>, 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __TDFX_CONTEXT_H__ -#define __TDFX_CONTEXT_H__ - -#include <sys/time.h> -#include "dri_util.h" -#include "main/glheader.h" -#if defined(__linux__) -#include <signal.h> -#endif - -#include "drm.h" -#include "drm_sarea.h" -#include "tdfx_glide.h" -#include "xmlconfig.h" - -#include "main/clip.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/matrix.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "tdfx_screen.h" - - - - -#define TDFX_TMU0 GR_TMU0 -#define TDFX_TMU1 GR_TMU1 -#define TDFX_TMU_SPLIT 98 -#define TDFX_TMU_BOTH 99 -#define TDFX_TMU_NONE 100 - - - -/* Flags for fxMesa->new_state - */ -#define TDFX_NEW_COLOR 0x0001 -#define TDFX_NEW_ALPHA 0x0002 -#define TDFX_NEW_DEPTH 0x0004 -#define TDFX_NEW_FOG 0x0008 -#define TDFX_NEW_STENCIL 0x0010 -#define TDFX_NEW_CLIP 0x0020 -#define TDFX_NEW_VIEWPORT 0x0040 -#define TDFX_NEW_CULL 0x0080 -#define TDFX_NEW_GLIDE 0x0100 -#define TDFX_NEW_TEXTURE 0x0200 -#define TDFX_NEW_CONTEXT 0x0400 -#define TDFX_NEW_LINE 0x0800 -#define TDFX_NEW_RENDER 0x1000 -#define TDFX_NEW_STIPPLE 0x2000 -#define TDFX_NEW_TEXTURE_BIND 0x4000 /* experimental */ - - -/* Flags for fxMesa->dirty - */ -#define TDFX_UPLOAD_COLOR_COMBINE 0x00000001 -#define TDFX_UPLOAD_ALPHA_COMBINE 0x00000002 -#define TDFX_UPLOAD_RENDER_BUFFER 0x00000004 -#define TDFX_UPLOAD_ALPHA_TEST 0x00000008 -#define TDFX_UPLOAD_ALPHA_REF 0x00000010 -#define TDFX_UPLOAD_BLEND_FUNC 0x00000020 -#define TDFX_UPLOAD_DEPTH_MODE 0x00000040 -#define TDFX_UPLOAD_DEPTH_BIAS 0x00000080 -#define TDFX_UPLOAD_DEPTH_FUNC 0x00000100 -#define TDFX_UPLOAD_DEPTH_MASK 0x00000200 -#define TDFX_UPLOAD_FOG_MODE 0x00000400 -#define TDFX_UPLOAD_FOG_COLOR 0x00000800 -#define TDFX_UPLOAD_FOG_TABLE 0x00001000 -#define TDFX_UPLOAD_CONSTANT_COLOR 0x00002000 - -#define TDFX_UPLOAD_CLIP 0x00002000 -#define TDFX_UPLOAD_CULL 0x00004000 -#define TDFX_UPLOAD_VERTEX_LAYOUT 0x00008000 -#define TDFX_UPLOAD_COLOR_MASK 0x00010000 -#define TDFX_UPLOAD_DITHER 0x00040000 -#define TDFX_UPLOAD_STENCIL 0x00080000 - -#define TDFX_UPLOAD_TEXTURE_SOURCE 0x00100000 -#define TDFX_UPLOAD_TEXTURE_PARAMS 0x00200000 -#define TDFX_UPLOAD_TEXTURE_PALETTE 0x00400000 -#define TDFX_UPLOAD_TEXTURE_ENV 0x00800000 -#define TDFX_UPLOAD_TEXTURE_IMAGES 0x01000000 - -#define TDFX_UPLOAD_LINE 0x02000000 - -#define TDFX_UPLOAD_STIPPLE 0x04000000 - -/* Flags for software fallback cases */ -/* See correponding strings in tdfx_tris.c */ -#define TDFX_FALLBACK_TEXTURE_MAP 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_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 -#define TDFX_FALLBACK_DISABLE 0x0800 - -/* Different Glide vertex layouts - */ -#define TDFX_LAYOUT_TINY 0 -#define TDFX_LAYOUT_NOTEX 1 -#define TDFX_LAYOUT_SINGLE 2 -#define TDFX_LAYOUT_MULTI 3 -#define TDFX_LAYOUT_PROJ1 4 -#define TDFX_LAYOUT_PROJ2 5 -#define TDFX_NUM_LAYOUTS 6 - -#define TDFX_XY_OFFSET 0 -#define TDFX_Z_OFFSET 8 -#define TDFX_Q_OFFSET 12 -#define TDFX_ARGB_OFFSET 16 -#define TDFX_FOG_OFFSET 20 -#define TDFX_ST0_OFFSET 24 -#define TDFX_ST1_OFFSET 32 -#define TDFX_Q0_OFFSET 40 -#define TDFX_Q1_OFFSET 44 - - -/* Flags for buffer clears - */ -#define TDFX_FRONT 0x1 -#define TDFX_BACK 0x2 -#define TDFX_DEPTH 0x4 -#define TDFX_STENCIL 0x8 - -/* - * Subpixel offsets to adjust Mesa's (true) window coordinates to - * Glide coordinates. We need these to ensure precise rasterization. - * Otherwise, we'll fail a bunch of conformance tests. - */ -#define TRI_X_OFFSET ( 0.0F) -#define TRI_Y_OFFSET ( 0.0F) -#define LINE_X_OFFSET ( 0.0F) -#define LINE_Y_OFFSET ( 0.125F) -#define PNT_X_OFFSET ( 0.375F) -#define PNT_Y_OFFSET ( 0.375F) - - -#define TDFX_DEPTH_BIAS_SCALE 128 - -/* Including xf86PciInfo.h causes a bunch of errors - */ -#ifndef PCI_CHIP_BANSHEE -#define PCI_CHIP_BANSHEE 0x0003 -#define PCI_CHIP_VOODOO3 0x0005 -#define PCI_CHIP_VOODOO4 0x0009 -#define PCI_CHIP_VOODOO5 0x0009 -#endif - -#define TDFX_IS_BANSHEE( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_BANSHEE ) -#define TDFX_IS_VOODOO3( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO3 ) -#define TDFX_IS_VOODOO4( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4 ) -#define TDFX_IS_VOODOO5( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5 ) -#define TDFX_IS_NAPALM( fxMesa ) \ - ( (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4) || \ - (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5) ) - - -#define PACK_BGRA32(R, G, B, A) \ - ( (((GLuint) (R)) << 16) | \ - (((GLuint) (G)) << 8) | \ - (((GLuint) (B)) ) | \ - (((GLuint) (A)) << 24) ) - -#define PACK_RGBA32(R, G, B, A) \ - ( (((GLuint) (R)) ) | \ - (((GLuint) (G)) << 8) | \ - (((GLuint) (B)) << 16) | \ - (((GLuint) (A)) << 24) ) - -/* - * The first two macros are to pack 8 bit color - * channel values into a 565 format. - */ -#define PACK_RGB16(R, G, B) \ - ((((GLuint) (R) & 0xF8) << 8) | \ - (((GLuint) (G) & 0xFC) << 3) | \ - (((GLuint) (B) & 0xFF) >> 3)) -#define PACK_BGR16(R, G, B) \ - ((((GLuint) (B) & 0xF8) << 8) | \ - (((GLuint) (G) & 0xFC) << 3) | \ - (((GLuint) (R) & 0xFF) >> 3)) -/* - * The second two macros pack 8 bit color channel values - * into 1555 values. - */ -#define PACK_RGBA16(R, G, B, A) \ - (((((GLuint) (A) & 0xFF) > 0) << 15)| \ - (((GLuint) (R) & 0xF8) << 7) | \ - (((GLuint) (G) & 0xF8) << 2) | \ - (((GLuint) (B) & 0xF8) >> 3)) -#define PACK_BGRA16(R, G, B, A) \ - (((((GLuint) (A) & 0xFF) > 0) << 15)| \ - (((GLuint) (B) & 0xF8) << 7) | \ - (((GLuint) (G) & 0xF8) << 2) | \ - (((GLuint) (R) & 0xF8) >> 3)) - -/* Used in calls to grColorMaskv()... - */ -extern const GLboolean false4[4]; -extern const GLboolean true4[4]; - - -typedef struct tdfx_context tdfxContextRec; -typedef struct tdfx_context *tdfxContextPtr; - - -typedef struct { - volatile int fifoPtr; - volatile int fifoRead; - volatile int fifoOwner; - volatile int ctxOwner; - volatile int texOwner; -} -TDFXSAREAPriv; - - -typedef struct { - GLuint swapBuffer; - GLuint reqTexUpload; - GLuint texUpload; - GLuint memTexUpload; - GLuint texSwaps; -} tdfxStats; - - - -/* - * Memory range from startAddr to endAddr-1 - */ -typedef struct mem_range { - struct mem_range *next; - FxU32 startAddr, endAddr; -} -tdfxMemRange; - - -typedef struct { - GLsizei width, height; /* image size */ - GLint wScale, hScale; /* scale factors */ - GrTextureFormat_t glideFormat; /* Glide image format */ -} -tdfxMipMapLevel; - - -#define TDFX_NUM_TMU 2 - - -typedef struct tdfxTexInfo_t -{ - GLboolean isInTM; - GLboolean reloadImages; /* if true, resend images to Glide */ - GLuint lastTimeUsed; - FxU32 whichTMU; - - GrTexInfo info; - GrAspectRatio_t aspectRatio; - tdfxMemRange *tm[TDFX_NUM_TMU]; - - GLint minLevel, maxLevel; - GrTextureFilterMode_t minFilt; - GrTextureFilterMode_t magFilt; - GrTextureClampMode_t sClamp; - GrTextureClampMode_t tClamp; - FxBool LODblend; - GrMipMapMode_t mmMode; - - GLfloat sScale, tScale; /* texcoord scale factor */ - - GrTexTable_t paltype; - GuTexPalette palette; - - GLboolean padded; -} -tdfxTexInfo; - - -#define TDFX_TEXTURE_DATA(mesaObj) ((tdfxTexInfo *)((mesaObj)->DriverData)) - -#define TDFX_TEXIMAGE_DATA(mesaImg) ((tdfxMipMapLevel *)((mesaImg)->DriverData)) - - - -/* - * This is state which may be shared by several tdfx contexts. - * It hangs off of Mesa's gl_shared_state object (ctx->Shared->DriverData). - */ -struct tdfxSharedState { - GLboolean umaTexMemory; - 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. - */ -/* The size of this union is not of relevence: - */ -typedef struct tdfx_vertex_t { - GLfloat x, y, z; /* Coordinates in screen space */ - GLfloat rhw; /* Reciprocal homogeneous w */ - GLubyte color[4]; /* Diffuse color */ - GLfloat fog; - GLfloat tu0, tv0; /* Texture 0 coordinates */ - GLfloat tu1, tv1; /* Texture 1 coordinates */ - GLfloat tq0, tq1; /* Texture 0/1 q coords */ - unsigned char pspec[4]; /* B, G, R, A [0..255] */ - float psize; /* point size */ - long pad[16 - 14]; /* ensure 64b structure */ -} tdfxVertex, *tdfxVertexPtr; - - -/* ================================================================ - * - * We want to keep a mirror of the Glide function call parameters so we - * can avoid updating our state too often. - * - * Each of these broad groups will typically have a new state flag - * associated with it, and will be updated together. The individual - * Glide function calls each have a dirty flag and will only be called - * when absolutely necessary. - */ - -/* for grTexSource() */ -struct tdfx_texsource { - FxU32 StartAddress; - FxU32 EvenOdd; - GrTexInfo *Info; -}; - -/* Texture object params */ -struct tdfx_texparams { - GrTextureClampMode_t sClamp; - GrTextureClampMode_t tClamp; - GrTextureFilterMode_t minFilt; - GrTextureFilterMode_t magFilt; - GrMipMapMode_t mmMode; - FxBool LODblend; - GLfloat LodBias; -}; - -/* for grTexDownloadTable() texture palettes */ -struct tdfx_texpalette { - GrTexTable_t Type; - void *Data; -}; - -/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */ -struct tdfx_combine { - GrCombineFunction_t Function; /* Combine function */ - GrCombineFactor_t Factor; /* Combine scale factor */ - GrCombineLocal_t Local; /* Local combine source */ - GrCombineOther_t Other; /* Other combine source */ - FxBool Invert; /* Combine result inversion flag */ -}; - -/* for Voodoo3's grTexCombine() */ -struct tdfx_texcombine { - GrCombineFunction_t FunctionRGB; - GrCombineFactor_t FactorRGB; - GrCombineFunction_t FunctionAlpha; - GrCombineFactor_t FactorAlpha; - FxBool InvertRGB; - FxBool InvertAlpha; -}; - - -/* for Voodoo5's grColorCombineExt() */ -struct tdfx_combine_color_ext { - GrCCUColor_t SourceA; - GrCombineMode_t ModeA; - GrCCUColor_t SourceB; - GrCombineMode_t ModeB; - GrCCUColor_t SourceC; - FxBool InvertC; - GrCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grAlphaCombineExt() */ -struct tdfx_combine_alpha_ext { - GrACUColor_t SourceA; - GrCombineMode_t ModeA; - GrACUColor_t SourceB; - GrCombineMode_t ModeB; - GrACUColor_t SourceC; - FxBool InvertC; - GrACUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grTexColorCombineExt() */ -struct tdfx_color_texenv { - GrTCCUColor_t SourceA; - GrCombineMode_t ModeA; - GrTCCUColor_t SourceB; - GrCombineMode_t ModeB; - GrTCCUColor_t SourceC; - FxBool InvertC; - GrTCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grTexAlphaCombineExt() */ -struct tdfx_alpha_texenv { - GrTACUColor_t SourceA; - GrCombineMode_t ModeA; - GrTACUColor_t SourceB; - GrCombineMode_t ModeB; - GrTACUColor_t SourceC; - FxBool InvertC; - GrTCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* Voodoo5's texture combine environment */ -struct tdfx_texcombine_ext { - struct tdfx_alpha_texenv Alpha; - struct tdfx_color_texenv Color; - GrColor_t EnvColor; -}; - -/* Used to track changes between Glide's state and Mesa's */ -struct tdfx_texstate { - GLuint Enabled[2]; /* values ala ctx->Texture.Unit[i]._ReallyEnabled */ - GLenum EnvMode[TDFX_NUM_TMU]; /* index is Glide index, not OpenGL */ - GLenum TexFormat[TDFX_NUM_TMU]; /* index is Glide index, not OpenGL */ -}; - -struct tdfx_color { - GrColor_t ClearColor; /* Buffer clear color value */ - GrAlpha_t ClearAlpha; /* Buffer clear alpha value */ - FxBool ColorMask[4]; /* Per-channel write enable flags */ - - GrColor_t MonoColor; /* Constant color value */ - - /* Alpha testing */ - GrCmpFnc_t AlphaFunc; /* Alpha test function */ - GrAlpha_t AlphaRef; /* Alpha ref value in range [0,255] */ - - /* Blending */ - GrAlphaBlendFnc_t BlendSrcRGB; /* Blend source RGB factor */ - GrAlphaBlendFnc_t BlendDstRGB; /* Blend destination RGB factor */ - GrAlphaBlendOp_t BlendEqRGB; /* Blend source RGB op */ - GrAlphaBlendFnc_t BlendSrcA; /* Blend source alpha factor */ - GrAlphaBlendFnc_t BlendDstA; /* Blend destination alpha factor */ - GrAlphaBlendOp_t BlendEqA; /* Blend source alpha op */ - - GrDitherMode_t Dither; /* Dither enable */ -}; - -struct tdfx_depth { - GrDepthBufferMode_t Mode; /* Fixed-point Z or floating-point W */ - FxI32 Bias; /* Polygon offset factor */ - GrCmpFnc_t Func; /* Depth test function */ - FxU32 Clear; /* Buffer clear value */ - FxBool Mask; /* Write enable flag */ -}; - -struct tdfx_stipple { - GrStippleMode_t Mode; /* Stipple enable/disable */ - FxU32 Pattern; /* 8x4 Stipple Pattern */ -}; - -struct tdfx_fog { - GrFogMode_t Mode; /* Glide fog mode */ - GrColor_t Color; /* Fog color value */ - GLenum TableMode; /* GL fog mode currently in table */ - GrFog_t *Table; /* Fog value table */ - FxFloat Density; /* Density >= 0 */ - FxFloat Near; /* Start distance in eye coords */ - FxFloat Far; /* End distance in eye coords */ -}; - -struct tdfx_stencil { - GrCmpFnc_t Function; /* Stencil function */ - GrStencil_t RefValue; /* Stencil reference value */ - GrStencil_t ValueMask; /* Value mask */ - GrStencil_t WriteMask; /* Write mask */ - GrStencil_t FailFunc; /* Stencil fail function */ - GrStencil_t ZFailFunc; /* Stencil pass, depth fail function */ - GrStencil_t ZPassFunc; /* Stencil pass, depth pass function */ - GrStencil_t Clear; /* Buffer clear value */ -}; - -struct tdfx_scissor { - FxU32 minX, minY; /* Lower left corner */ - FxU32 maxX, maxY; /* Upper right corner */ -}; - -struct tdfx_viewport { - GrCoordinateSpaceMode_t Mode; /* Coordinate space */ - FxI32 X, Y; /* Position */ - FxI32 Width, Height; /* Size */ - FxFloat Near, Far; /* Depth buffer range */ -}; - -struct tdfx_glide { - void *State; /* Mirror of internal Glide state */ - GrContext_t Context; /* Glide context identifier */ - FxI32 Board; /* Current graphics subsystem */ - GrColorFormat_t ColorFormat; /* Framebuffer format */ - GrOriginLocation_t Origin; /* Location of screen space origin */ - - FxBool Initialized; /* Glide initialization done? */ - - FxI32 SwapInterval; /* SwapBuffers interval */ - FxI32 MaxPendingSwaps; /* Maximum outstanding SwapBuffers */ - FxI32 TextureAlign; - - /* Extensions */ - FxBool HaveCombineExt; /* COMBINE */ - FxBool HaveCommandTransportExt; /* COMMAND_TRANSPORT */ - FxBool HaveFogCoordExt; /* FOGCOORD */ - FxBool HavePixelExt; /* PIXEXT */ - FxBool HaveTextureBufferExt; /* TEXTUREBUFFER */ - FxBool HaveTexFmtExt; /* TEXFMT */ - FxBool HaveTexUMAExt; /* TEXUMA */ - FxBool HaveMirrorExt; /* MIRROR */ - FxBool HaveTexus2; /* Texus 2 - FXT1 */ - - /* Glide library function pointers */ - void (*grDrawPoint)( const void *pt ); - void (*grDrawLine)( const void *v1, const void *v2 ); - void (*grDrawTriangle)( const void *a, const void *b, const void *c ); - void (*grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode); - void (*grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers); - void (*grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count, - void *pointers, FxU32 stride); - void (*grBufferClear)( GrColor_t color, GrAlpha_t alpha, FxU32 depth ); - void (*grBufferSwap)( FxU32 swap_interval ); - void (*grRenderBuffer)( GrBuffer_t buffer ); - void (*grErrorSetCallback)( GrErrorCallbackFnc_t fnc ); - void (*grFinish)(void); - void (*grFlush)(void); - GrContext_t (*grSstWinOpen)(FxU32 hWnd, - GrScreenResolution_t screen_resolution, - GrScreenRefresh_t refresh_rate, - GrColorFormat_t color_format, - GrOriginLocation_t origin_location, - int nColBuffers, - int nAuxBuffers); - void (*grSstWinClose)( GrContext_t context ); -/* Not used */ -#if 0 - void (*grSetNumPendingBuffers)(FxI32 NumPendingBuffers); -#endif - void (*grSelectContext)( GrContext_t context ); - void (*grSstOrigin)(GrOriginLocation_t origin); - void (*grSstSelect)( int which_sst ); - void (*grAlphaBlendFunction)(GrAlphaBlendFnc_t rgb_sf, - GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendFnc_t alpha_sf, - GrAlphaBlendFnc_t alpha_df); - void (*grAlphaCombine)(GrCombineFunction_t function, - GrCombineFactor_t factor, - GrCombineLocal_t local, GrCombineOther_t other, - FxBool invert); - void (*grAlphaControlsITRGBLighting)( FxBool enable ); - void (*grAlphaTestFunction)( GrCmpFnc_t function ); - void (*grAlphaTestReferenceValue)( GrAlpha_t value ); - void (*grChromakeyMode)( GrChromakeyMode_t mode ); - void (*grChromakeyValue)( GrColor_t value ); - void (*grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy ); - void (*grColorCombine)( GrCombineFunction_t function, - GrCombineFactor_t factor, - GrCombineLocal_t local, - GrCombineOther_t other, - FxBool invert ); - void (*grColorMask)( FxBool rgb, FxBool a ); - void (*grCullMode)( GrCullMode_t mode ); - void (*grConstantColorValue)( GrColor_t value ); - void (*grDepthBiasLevel)( FxI32 level ); - void (*grDepthBufferFunction)( GrCmpFnc_t function ); - void (*grDepthBufferMode)( GrDepthBufferMode_t mode ); - void (*grDepthMask)( FxBool mask ); - void (*grDisableAllEffects)( void ); - void (*grDitherMode)( GrDitherMode_t mode ); - void (*grFogColorValue)( GrColor_t fogcolor ); - void (*grFogMode)( GrFogMode_t mode ); - void (*grFogTable)( const GrFog_t ft[] ); - void (*grLoadGammaTable)( FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue); - void (*grSplash)(float x, float y, float width, float height, FxU32 frame); - FxU32 (*grGet)( FxU32 pname, FxU32 plength, FxI32 *params ); - const char * (*grGetString)( FxU32 pname ); - FxI32 (*grQueryResolutions)( const GrResolution *resTemplate, - GrResolution *output ); - FxBool (*grReset)( FxU32 what ); - GrProc (*grGetProcAddress)( char *procName ); - void (*grEnable)( GrEnableMode_t mode ); - void (*grDisable)( GrEnableMode_t mode ); - void (*grCoordinateSpace)( GrCoordinateSpaceMode_t mode ); - void (*grDepthRange)( FxFloat n, FxFloat f ); - void (*grStippleMode)( GrStippleMode_t mode ); - void (*grStipplePattern)( GrStipplePattern_t mode ); - void (*grViewport)( FxI32 x, FxI32 y, FxI32 width, FxI32 height ); - FxU32 (*grTexCalcMemRequired)(GrLOD_t lodmin, GrLOD_t lodmax, - GrAspectRatio_t aspect, GrTextureFormat_t fmt); - FxU32 (*grTexTextureMemRequired)( FxU32 evenOdd, GrTexInfo *info ); - FxU32 (*grTexMinAddress)( GrChipID_t tmu ); - FxU32 (*grTexMaxAddress)( GrChipID_t tmu ); - void (*grTexNCCTable)( GrNCCTable_t table ); - void (*grTexSource)( GrChipID_t tmu, FxU32 startAddress, - FxU32 evenOdd, GrTexInfo *info ); - void (*grTexClampMode)( GrChipID_t tmu, - GrTextureClampMode_t s_clampmode, - GrTextureClampMode_t t_clampmode ); - void (*grTexCombine)( GrChipID_t tmu, - GrCombineFunction_t rgb_function, - GrCombineFactor_t rgb_factor, - GrCombineFunction_t alpha_function, - GrCombineFactor_t alpha_factor, - FxBool rgb_invert, - FxBool alpha_invert); - void (*grTexDetailControl)( GrChipID_t tmu, int lod_bias, - FxU8 detail_scale, float detail_max ); - void (*grTexFilterMode)( GrChipID_t tmu, - GrTextureFilterMode_t minfilter_mode, - GrTextureFilterMode_t magfilter_mode ); - void (*grTexLodBiasValue)(GrChipID_t tmu, float bias ); - void (*grTexDownloadMipMap)( GrChipID_t tmu, FxU32 startAddress, - FxU32 evenOdd, GrTexInfo *info ); - void (*grTexDownloadMipMapLevel)( GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data ); - FxBool (*grTexDownloadMipMapLevelPartial)( GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data, - int start, - int end ); - void (*grTexDownloadTable)( GrTexTable_t type, void *data ); - void (*grTexDownloadTablePartial)( GrTexTable_t type, - void *data, int start, int end ); - void (*grTexMipMapMode)( GrChipID_t tmu, GrMipMapMode_t mode, - FxBool lodBlend ); - void (*grTexMultibase)( GrChipID_t tmu, FxBool enable ); - void (*grTexMultibaseAddress)( GrChipID_t tmu, - GrTexBaseRange_t range, - FxU32 startAddress, - FxU32 evenOdd, - GrTexInfo *info ); - FxBool (*grLfbLock)( GrLock_t type, GrBuffer_t buffer, - GrLfbWriteMode_t writeMode, - GrOriginLocation_t origin, FxBool pixelPipeline, - GrLfbInfo_t *info ); - FxBool (*grLfbUnlock)( GrLock_t type, GrBuffer_t buffer ); - void (*grLfbConstantAlpha)( GrAlpha_t alpha ); - void (*grLfbConstantDepth)( FxU32 depth ); - void (*grLfbWriteColorSwizzle)(FxBool swizzleBytes, FxBool swapWords); - void (*grLfbWriteColorFormat)(GrColorFormat_t colorFormat); - FxBool (*grLfbWriteRegion)( GrBuffer_t dst_buffer, - FxU32 dst_x, FxU32 dst_y, - GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, - FxBool pixelPipeline, - FxI32 src_stride, void *src_data ); - FxBool (*grLfbReadRegion)( GrBuffer_t src_buffer, - FxU32 src_x, FxU32 src_y, - FxU32 src_width, FxU32 src_height, - FxU32 dst_stride, void *dst_data ); - void (*grGlideInit)( void ); - void (*grGlideShutdown)( void ); - void (*grGlideGetState)( void *state ); - void (*grGlideSetState)( const void *state ); - void (*grGlideGetVertexLayout)( void *layout ); - void (*grGlideSetVertexLayout)( const void *layout ); - /* Glide utility functions */ - void (*guFogGenerateExp)( GrFog_t *fogtable, float density ); - void (*guFogGenerateExp2)( GrFog_t *fogtable, float density ); - void (*guFogGenerateLinear)(GrFog_t *fogtable, float nearZ, float farZ ); - /* DRI functions */ - void (*grDRIOpen)( char *pFB, char *pRegs, int deviceID, - int width, int height, - int mem, int cpp, int stride, - int fifoOffset, int fifoSize, - int fbOffset, int backOffset, int depthOffset, - int textureOffset, int textureSize, - volatile int *fifoPtr, volatile int *fifoRead ); - void (*grDRIPosition)( int x, int y, int w, int h, - int numClip, drm_clip_rect_t *pClip ); - void (*grDRILostContext)( void ); - void (*grDRIImportFifo)( int fifoPtr, int fifoRead ); - void (*grDRIInvalidateAll)( void ); - void (*grDRIResetSAREA)( void ); - void (*grDRIBufferSwap)( FxU32 swapInterval ); - /* Glide extensions */ - /* PIXEXT extension */ - void (*grStencilFunc)( GrCmpFnc_t func, GrStencil_t ref, GrStencil_t mask ); - void (*grStencilMask)( GrStencil_t mask ); - void (*grStencilOp)( GrStencilOp_t fail, GrStencilOp_t zfail, - GrStencilOp_t zpass ); - void (*grBufferClearExt)( GrColor_t color, GrAlpha_t alpha, - FxU32 depth, GrStencil_t stencil ); - void (*grColorMaskExt)( FxBool r, FxBool g, FxBool b, FxBool a ); - /* COMBINE extension */ - void (*grColorCombineExt)( GrCCUColor_t a, GrCombineMode_t a_mode, - GrCCUColor_t b, GrCombineMode_t b_mode, - GrCCUColor_t c, FxBool c_invert, - GrCCUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grTexColorCombineExt)( FxU32 tmu, - GrTCCUColor_t a, GrCombineMode_t a_mode, - GrTCCUColor_t b, GrCombineMode_t b_mode, - GrTCCUColor_t c, FxBool c_invert, - GrTCCUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grAlphaCombineExt)( GrACUColor_t a, GrCombineMode_t a_mode, - GrACUColor_t b, GrCombineMode_t b_mode, - GrACUColor_t c, FxBool c_invert, - GrACUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grTexAlphaCombineExt)( FxU32 tmu, - GrTACUColor_t a, GrCombineMode_t a_mode, - GrTACUColor_t b, GrCombineMode_t b_mode, - GrTACUColor_t c, FxBool c_invert, - GrTACUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grAlphaBlendFunctionExt)( GrAlphaBlendFnc_t rgb_sf, - GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendOp_t rgb_op, - GrAlphaBlendFnc_t alpha_sf, - GrAlphaBlendFnc_t alpha_df, - GrAlphaBlendOp_t alpha_op ); - void (*grConstantColorValueExt)( FxU32 tmu, GrColor_t value ); - /* Texus 2 */ - void (*txImgQuantize)( void *xxx_unknown_arguments ); - void (*txImgDequantizeFXT1)( void *txMip, void *pxMip ); - 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: - */ - struct gl_context *glCtx; /* The core Mesa context */ - - GLuint new_gl_state; - GLuint new_state; - GLuint dirty; - - /* Mirror of hardware state, Glide parameters - */ - GLuint tmu_source[TDFX_NUM_TMU]; - struct tdfx_texsource TexSource[TDFX_NUM_TMU]; - struct tdfx_texparams TexParams[TDFX_NUM_TMU]; - struct tdfx_texpalette TexPalette; - - /* Voodoo3 texture/color combine state */ - struct tdfx_combine ColorCombine; - struct tdfx_combine AlphaCombine; - struct tdfx_texcombine TexCombine[TDFX_NUM_TMU]; - - /* Voodoo5 texture/color combine state */ - struct tdfx_combine_color_ext ColorCombineExt; - struct tdfx_combine_alpha_ext AlphaCombineExt; - struct tdfx_texcombine_ext TexCombineExt[TDFX_NUM_TMU]; - - /* Tracks tex state difference between Glide and Mesa */ - struct tdfx_texstate TexState; - - GrBuffer_t DrawBuffer; /* Current draw buffer */ - GrBuffer_t ReadBuffer; /* Current read buffer */ - - struct tdfx_color Color; - struct tdfx_depth Depth; - struct tdfx_fog Fog; - struct tdfx_stencil Stencil; - struct tdfx_scissor Scissor; - struct tdfx_viewport Viewport; - struct tdfx_stipple Stipple; - - GrCullMode_t CullMode; - - struct tdfx_glide Glide; - - /* Fallback rasterization functions - */ - tdfx_point_func draw_point; - tdfx_line_func draw_line; - tdfx_tri_func draw_triangle; - - - /* Variable-size Glide vertex formats - */ - GLuint vertexFormat; /* the current format */ - void *layout[TDFX_NUM_LAYOUTS]; - tdfxVertex *verts; - - GLfloat hw_viewport[16]; - - GLuint SetupIndex; - GLuint SetupNewInputs; - GLuint RenderIndex; - GLuint Fallback; - GLenum render_primitive; /* what GL thinks */ - GLenum raster_primitive; /* what the hardware thinks */ - - GLfloat sScale0, tScale0; - GLfloat sScale1, tScale1; - - GLuint texBindNumber; - GLint tmuSrc; - - int screen_width; - int screen_height; - - GLboolean haveTwoTMUs; /* True if we have 2 tmu's */ - GLboolean haveHwAlpha; - GLboolean haveHwStencil; - GLboolean haveHwStipple; - - GLint maxPendingSwapBuffers; - - char rendererString[100]; - - /* stuff added for DRI */ - __DRIscreen *driScreen; - __DRIcontext *driContext; - - /** - * DRI drawable bound to this context for drawing. - */ - __DRIdrawable *driDrawable; - - /** - * DRI drawable bound to this context for reading. - */ - __DRIdrawable *driReadable; - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - tdfxScreenPrivate *fxScreen; - TDFXSAREAPriv *sarea; - - - /* - * Changes during execution: - */ - int width, height; /* size of window */ - int x_offset; /* distance from window left to screen left */ - int y_offset; /* distance from window top to screen top */ - int y_delta; /* distance from window bottom to screen bottom */ - - int numClipRects; - drm_clip_rect_t *pClipRects; - GLboolean scissoredClipRects; /* if true, pClipRects is private storage */ - - GuTexPalette glbPalette; /* global texture palette */ - - tdfxStats stats; - - /* Configuration cache - */ - driOptionCache optionCache; -}; - -#define TDFX_CONTEXT(ctx) ((tdfxContextPtr)((ctx)->DriverCtx)) - - -extern GLboolean -tdfxCreateContext( gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate ); - -extern void -tdfxDestroyContext( __DRIcontext *driContextPriv ); - -extern GLboolean -tdfxUnbindContext( __DRIcontext *driContextPriv ); - -extern GLboolean -tdfxMakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ); - -extern GLboolean -tdfxInitGlide( tdfxContextPtr tmesa ); - -extern void -FX_grColorMaskv(struct gl_context *ctx, const GLboolean rgba[4]); - -extern void -FX_grColorMaskv_NoLock(struct gl_context *ctx, const GLboolean rgba[4]); - - -/* Color packing utilities - */ -#define TDFXPACKCOLOR332( r, g, b ) \ - (((b) & 0xe0) | (((g) & 0xe0) >> 3) | (((r) & 0xc0) >> 6)) - -#define TDFXPACKCOLOR1555( r, g, b, a ) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define TDFXPACKCOLOR565( r, g, b ) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define TDFXPACKCOLOR888( r, g, b ) \ - (((b) << 16) | ((g) << 8) | (r)) - -#define TDFXPACKCOLOR8888( r, g, b, a ) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define TDFXPACKCOLOR4444( r, g, b, a ) \ - ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((g) & 0xf0) | ((r) >> 4)) - -static INLINE GrColor_t tdfxPackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return TDFXPACKCOLOR565( r, g, b ); - case 4: - return TDFXPACKCOLOR8888( r, g, b, a ); - default: - return 0; - } -} - -#define DO_DEBUG 1 -#if DO_DEBUG -extern int TDFX_DEBUG; -#else -#define TDFX_DEBUG 0 -#endif - -#define DEBUG_ALWAYS_SYNC 0x01 -#define DEBUG_VERBOSE_API 0x02 -#define DEBUG_VERBOSE_DRI 0x04 -#define DEBUG_VERBOSE_FALL 0x08 - -/* conf */ -#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1 -#define FX_TC_NAPALM 0 - -#endif /* __TDFX_CONTEXT_H__ */ diff --git a/src/mesa/drivers/dri/tdfx/tdfx_dd.c b/src/mesa/drivers/dri/tdfx/tdfx_dd.c deleted file mode 100644 index e981f9abedf..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_dd.c +++ /dev/null @@ -1,222 +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. - */ - -/** - * \file tdfx_dd.c - * Device driver interface functions for 3Dfx based cards. - * - * \author Gareth Hughes <[email protected]> (Original rewrite 29 Sep - 1 Oct 2000) - * \author Brian Paul <[email protected]> - */ - -#include "tdfx_context.h" -#include "tdfx_dd.h" -#include "tdfx_lock.h" -#include "tdfx_pixels.h" - -#include "utils.h" -#include "main/context.h" - - -/* These are used in calls to FX_grColorMaskv() */ -const GLboolean false4[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; -const GLboolean true4[4] = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; - - - -/* KW: Put the word Mesa in the render string because quakeworld - * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE). - * Why? - */ -static const GLubyte *tdfxDDGetString( struct gl_context *ctx, GLenum name ) -{ - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - - switch (name) { - case GL_RENDERER: - { - /* The renderer string must be per-context state to handle - * multihead correctly. - */ - char *const buffer = fxMesa->rendererString; - char hardware[64]; - - LOCK_HARDWARE(fxMesa); - strncpy(hardware, fxMesa->Glide.grGetString(GR_HARDWARE), - sizeof(hardware)); - hardware[sizeof(hardware) - 1] = '\0'; - UNLOCK_HARDWARE(fxMesa); - - if ((strncmp(hardware, "Voodoo3", 7) == 0) - || (strncmp(hardware, "Voodoo4", 7) == 0) - || (strncmp(hardware, "Voodoo5", 7) == 0)) { - hardware[7] = '\0'; - } - else if (strncmp(hardware, "Voodoo Banshee", 14) == 0) { - strcpy(&hardware[6], "Banshee"); - } - else { - /* unexpected result: replace spaces with hyphens */ - int i; - for (i = 0; i < sizeof(hardware) && hardware[i]; i++) { - if (hardware[i] == ' ' || hardware[i] == '\t') { - hardware[i] = '-'; - } - } - } - - (void) driGetRendererString(buffer, hardware, 0); - return (const GLubyte *) buffer; - } - case GL_VENDOR: - return (const GLubyte *)"VA Linux Systems, Inc."; - default: - return NULL; - } -} - - -static void -tdfxBeginQuery(struct gl_context *ctx, struct gl_query_object *q) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - (void) q; - - if (q->Target == GL_SAMPLES_PASSED_ARB) { - LOCK_HARDWARE(fxMesa); - fxMesa->Glide.grFinish(); - fxMesa->Glide.grReset(GR_STATS_PIXELS); - UNLOCK_HARDWARE(fxMesa); - } -} - - -static void -tdfxEndQuery(struct gl_context *ctx, struct gl_query_object *q) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FxI32 total_pixels; - FxI32 z_fail_pixels; - - - if (q->Target == GL_SAMPLES_PASSED_ARB) { - LOCK_HARDWARE(fxMesa); - fxMesa->Glide.grFinish(); - - fxMesa->Glide.grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, sizeof(FxI32), - &z_fail_pixels); - fxMesa->Glide.grGet(GR_STATS_PIXELS_IN, sizeof(FxI32), &total_pixels); - - q->Result = total_pixels - z_fail_pixels; - - /* Apparently, people have seen z_fail_pixels > total_pixels under - * some conditions on some 3Dfx hardware. The occlusion query spec - * requires that we clamp to 0. - */ - if (q->Result < 0) { - q->Result = 0; - } - - q->Ready = GL_TRUE; - - UNLOCK_HARDWARE(fxMesa); - } -} - - -#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \ - ((vis->redBits == r) && \ - (vis->greenBits == g) && \ - (vis->blueBits == b) && \ - (vis->alphaBits == a)) - -void tdfxDDInitDriverFuncs( const struct gl_config *visual, - struct dd_function_table *functions ) -{ - if ( MESA_VERBOSE & VERBOSE_DRIVER ) { - fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ ); - } - - functions->GetString = tdfxDDGetString; - functions->BeginQuery = tdfxBeginQuery; - functions->EndQuery = tdfxEndQuery; - - /* Accelerated paths - */ - if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) ) - { - functions->DrawPixels = tdfx_drawpixels_R8G8B8A8; - functions->ReadPixels = tdfx_readpixels_R8G8B8A8; - } - else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) ) - { - functions->ReadPixels = tdfx_readpixels_R5G6B5; - } -} - - -/* - * These are here for lack of a better place. - */ - -void -FX_grColorMaskv(struct gl_context *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(struct gl_context *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/src/mesa/drivers/dri/tdfx/tdfx_dd.h b/src/mesa/drivers/dri/tdfx/tdfx_dd.h deleted file mode 100644 index d68e1ece1bd..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_dd.h +++ /dev/null @@ -1,44 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __TDFX_DD_H__ -#define __TDFX_DD_H__ - -#include "main/context.h" - -extern void tdfxDDInitDriverFuncs( const struct gl_config *visual, - struct dd_function_table *functions ); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_glide.h b/src/mesa/drivers/dri/tdfx/tdfx_glide.h deleted file mode 100644 index 69e5399e729..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_glide.h +++ /dev/null @@ -1,605 +0,0 @@ -/* - * This file defines macros and types necessary for accessing glide3. - */ - - -#ifndef NEWGLIDE_H -#define NEWGLIDE_H - -#define FX_CALL - -typedef unsigned char FxU8; -typedef signed char FxI8; -typedef unsigned short FxU16; -typedef signed short FxI16; -#if defined(__alpha__) || defined (__LP64__) -typedef signed int FxI32; -typedef unsigned int FxU32; -#else -typedef signed long FxI32; -typedef unsigned long FxU32; -#endif -typedef unsigned long AnyPtr; -typedef int FxBool; -typedef float FxFloat; -typedef double FxDouble; - -typedef unsigned long FxColor_t; -typedef struct -{ - float r, g, b, a; -} -FxColor4; - -typedef FxU32 GrColor_t; -typedef FxU8 GrAlpha_t; -typedef FxU32 GrMipMapId_t; -typedef FxU32 GrStipplePattern_t; -typedef FxU8 GrFog_t; -typedef FxU32 GrContext_t; -typedef int (FX_CALL * GrProc) (void); - -#define FXTRUE 1 -#define FXFALSE 0 - -#define FXBIT(i) (1L << (i)) - -#define GR_NULL_MIPMAP_HANDLE ((GrMipMapId_t) -1) - -#define GR_MIPMAPLEVELMASK_EVEN FXBIT(0) -#define GR_MIPMAPLEVELMASK_ODD FXBIT(1) -#define GR_MIPMAPLEVELMASK_BOTH (GR_MIPMAPLEVELMASK_EVEN | GR_MIPMAPLEVELMASK_ODD ) - -typedef FxI32 GrChipID_t; -#define GR_TMU0 0x0 -#define GR_TMU1 0x1 -#define GR_TMU2 0x2 - -#define GR_FBI 0x0 - -typedef FxI32 GrCombineFunction_t; -#define GR_COMBINE_FUNCTION_ZERO 0x0 -#define GR_COMBINE_FUNCTION_NONE GR_COMBINE_FUNCTION_ZERO -#define GR_COMBINE_FUNCTION_LOCAL 0x1 -#define GR_COMBINE_FUNCTION_LOCAL_ALPHA 0x2 -#define GR_COMBINE_FUNCTION_SCALE_OTHER 0x3 -#define GR_COMBINE_FUNCTION_BLEND_OTHER GR_COMBINE_FUNCTION_SCALE_OTHER -#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL 0x4 -#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA 0x5 -#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL 0x6 -#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL 0x7 -#define GR_COMBINE_FUNCTION_BLEND GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL -#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x8 -#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL 0x9 -#define GR_COMBINE_FUNCTION_BLEND_LOCAL GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL -#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x10 - -typedef FxI32 GrCombineFactor_t; -#define GR_COMBINE_FACTOR_ZERO 0x0 -#define GR_COMBINE_FACTOR_NONE GR_COMBINE_FACTOR_ZERO -#define GR_COMBINE_FACTOR_LOCAL 0x1 -#define GR_COMBINE_FACTOR_OTHER_ALPHA 0x2 -#define GR_COMBINE_FACTOR_LOCAL_ALPHA 0x3 -#define GR_COMBINE_FACTOR_TEXTURE_ALPHA 0x4 -#define GR_COMBINE_FACTOR_TEXTURE_RGB 0x5 -#define GR_COMBINE_FACTOR_DETAIL_FACTOR GR_COMBINE_FACTOR_TEXTURE_ALPHA -#define GR_COMBINE_FACTOR_LOD_FRACTION 0x5 -#define GR_COMBINE_FACTOR_ONE 0x8 -#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL 0x9 -#define GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA 0xa -#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA 0xb -#define GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA 0xc -#define GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA -#define GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION 0xd - -typedef FxI32 GrCombineLocal_t; -#define GR_COMBINE_LOCAL_ITERATED 0x0 -#define GR_COMBINE_LOCAL_CONSTANT 0x1 -#define GR_COMBINE_LOCAL_NONE GR_COMBINE_LOCAL_CONSTANT -#define GR_COMBINE_LOCAL_DEPTH 0x2 - -typedef FxI32 GrCombineOther_t; -#define GR_COMBINE_OTHER_ITERATED 0x0 -#define GR_COMBINE_OTHER_TEXTURE 0x1 -#define GR_COMBINE_OTHER_CONSTANT 0x2 -#define GR_COMBINE_OTHER_NONE GR_COMBINE_OTHER_CONSTANT - -typedef FxI32 GrAlphaSource_t; -#define GR_ALPHASOURCE_CC_ALPHA 0x0 -#define GR_ALPHASOURCE_ITERATED_ALPHA 0x1 -#define GR_ALPHASOURCE_TEXTURE_ALPHA 0x2 -#define GR_ALPHASOURCE_TEXTURE_ALPHA_TIMES_ITERATED_ALPHA 0x3 - -typedef FxI32 GrColorCombineFnc_t; -#define GR_COLORCOMBINE_ZERO 0x0 -#define GR_COLORCOMBINE_CCRGB 0x1 -#define GR_COLORCOMBINE_ITRGB 0x2 -#define GR_COLORCOMBINE_ITRGB_DELTA0 0x3 -#define GR_COLORCOMBINE_DECAL_TEXTURE 0x4 -#define GR_COLORCOMBINE_TEXTURE_TIMES_CCRGB 0x5 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB 0x6 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_DELTA0 0x7 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_ADD_ALPHA 0x8 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA 0x9 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA_ADD_ITRGB 0xa -#define GR_COLORCOMBINE_TEXTURE_ADD_ITRGB 0xb -#define GR_COLORCOMBINE_TEXTURE_SUB_ITRGB 0xc -#define GR_COLORCOMBINE_CCRGB_BLEND_ITRGB_ON_TEXALPHA 0xd -#define GR_COLORCOMBINE_DIFF_SPEC_A 0xe -#define GR_COLORCOMBINE_DIFF_SPEC_B 0xf -#define GR_COLORCOMBINE_ONE 0x10 - -typedef FxI32 GrAlphaBlendFnc_t; -#define GR_BLEND_ZERO 0x0 -#define GR_BLEND_SRC_ALPHA 0x1 -#define GR_BLEND_SRC_COLOR 0x2 -#define GR_BLEND_DST_COLOR GR_BLEND_SRC_COLOR -#define GR_BLEND_DST_ALPHA 0x3 -#define GR_BLEND_ONE 0x4 -#define GR_BLEND_ONE_MINUS_SRC_ALPHA 0x5 -#define GR_BLEND_ONE_MINUS_SRC_COLOR 0x6 -#define GR_BLEND_ONE_MINUS_DST_COLOR GR_BLEND_ONE_MINUS_SRC_COLOR -#define GR_BLEND_ONE_MINUS_DST_ALPHA 0x7 -#define GR_BLEND_RESERVED_8 0x8 -#define GR_BLEND_RESERVED_9 0x9 -#define GR_BLEND_RESERVED_A 0xa -#define GR_BLEND_RESERVED_B 0xb -#define GR_BLEND_RESERVED_C 0xc -#define GR_BLEND_RESERVED_D 0xd -#define GR_BLEND_RESERVED_E 0xe -#define GR_BLEND_ALPHA_SATURATE 0xf -#define GR_BLEND_PREFOG_COLOR GR_BLEND_ALPHA_SATURATE -#define GR_BLEND_SAME_COLOR_EXT 0x08 -#define GR_BLEND_ONE_MINUS_SAME_COLOR_EXT 0x09 - -typedef FxI32 GrAspectRatio_t; -#define GR_ASPECT_LOG2_8x1 3 -#define GR_ASPECT_LOG2_4x1 2 -#define GR_ASPECT_LOG2_2x1 1 -#define GR_ASPECT_LOG2_1x1 0 -#define GR_ASPECT_LOG2_1x2 -1 -#define GR_ASPECT_LOG2_1x4 -2 -#define GR_ASPECT_LOG2_1x8 -3 - -typedef FxI32 GrBuffer_t; -#define GR_BUFFER_FRONTBUFFER 0x0 -#define GR_BUFFER_BACKBUFFER 0x1 -#define GR_BUFFER_AUXBUFFER 0x2 -#define GR_BUFFER_DEPTHBUFFER 0x3 -#define GR_BUFFER_ALPHABUFFER 0x4 -#define GR_BUFFER_TRIPLEBUFFER 0x5 - -typedef FxI32 GrChromakeyMode_t; -#define GR_CHROMAKEY_DISABLE 0x0 -#define GR_CHROMAKEY_ENABLE 0x1 - -typedef FxI32 GrChromaRangeMode_t; -#define GR_CHROMARANGE_RGB_ALL_EXT 0x0 - -#define GR_CHROMARANGE_DISABLE_EXT 0x00 -#define GR_CHROMARANGE_ENABLE_EXT 0x01 - -typedef FxI32 GrTexChromakeyMode_t; -#define GR_TEXCHROMA_DISABLE_EXT 0x0 -#define GR_TEXCHROMA_ENABLE_EXT 0x1 - -#define GR_TEXCHROMARANGE_RGB_ALL_EXT 0x0 - -typedef FxI32 GrCmpFnc_t; -#define GR_CMP_NEVER 0x0 -#define GR_CMP_LESS 0x1 -#define GR_CMP_EQUAL 0x2 -#define GR_CMP_LEQUAL 0x3 -#define GR_CMP_GREATER 0x4 -#define GR_CMP_NOTEQUAL 0x5 -#define GR_CMP_GEQUAL 0x6 -#define GR_CMP_ALWAYS 0x7 - -typedef FxI32 GrColorFormat_t; -#define GR_COLORFORMAT_ARGB 0x0 -#define GR_COLORFORMAT_ABGR 0x1 - -#define GR_COLORFORMAT_RGBA 0x2 -#define GR_COLORFORMAT_BGRA 0x3 - -typedef FxI32 GrCullMode_t; -#define GR_CULL_DISABLE 0x0 -#define GR_CULL_NEGATIVE 0x1 -#define GR_CULL_POSITIVE 0x2 - -typedef FxI32 GrDepthBufferMode_t; -#define GR_DEPTHBUFFER_DISABLE 0x0 -#define GR_DEPTHBUFFER_ZBUFFER 0x1 -#define GR_DEPTHBUFFER_WBUFFER 0x2 -#define GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS 0x3 -#define GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS 0x4 - -typedef FxI32 GrDitherMode_t; -#define GR_DITHER_DISABLE 0x0 -#define GR_DITHER_2x2 0x1 -#define GR_DITHER_4x4 0x2 - -typedef FxI32 GrStippleMode_t; -#define GR_STIPPLE_DISABLE 0x0 -#define GR_STIPPLE_PATTERN 0x1 -#define GR_STIPPLE_ROTATE 0x2 - -typedef FxI32 GrFogMode_t; -#define GR_FOG_DISABLE 0x0 -#define GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT 0x1 -#define GR_FOG_WITH_TABLE_ON_Q 0x2 -#define GR_FOG_WITH_TABLE_ON_W GR_FOG_WITH_TABLE_ON_Q -#define GR_FOG_WITH_ITERATED_Z 0x3 -#define GR_FOG_WITH_ITERATED_ALPHA_EXT 0x4 -#define GR_FOG_MULT2 0x100 -#define GR_FOG_ADD2 0x200 - -typedef FxU32 GrLock_t; -#define GR_LFB_READ_ONLY 0x00 -#define GR_LFB_WRITE_ONLY 0x01 -#define GR_LFB_IDLE 0x00 -#define GR_LFB_NOIDLE 0x10 - -typedef FxI32 GrLfbBypassMode_t; -#define GR_LFBBYPASS_DISABLE 0x0 -#define GR_LFBBYPASS_ENABLE 0x1 - -typedef FxI32 GrLfbWriteMode_t; -#define GR_LFBWRITEMODE_565 0x0 -#define GR_LFBWRITEMODE_555 0x1 -#define GR_LFBWRITEMODE_1555 0x2 -#define GR_LFBWRITEMODE_RESERVED1 0x3 -#define GR_LFBWRITEMODE_888 0x4 -#define GR_LFBWRITEMODE_8888 0x5 -#define GR_LFBWRITEMODE_RESERVED2 0x6 -#define GR_LFBWRITEMODE_RESERVED3 0x7 -#define GR_LFBWRITEMODE_RESERVED4 0x8 -#define GR_LFBWRITEMODE_RESERVED5 0x9 -#define GR_LFBWRITEMODE_RESERVED6 0xa -#define GR_LFBWRITEMODE_RESERVED7 0xb -#define GR_LFBWRITEMODE_565_DEPTH 0xc -#define GR_LFBWRITEMODE_555_DEPTH 0xd -#define GR_LFBWRITEMODE_1555_DEPTH 0xe -#define GR_LFBWRITEMODE_ZA16 0xf -#define GR_LFBWRITEMODE_ANY 0xFF - -typedef FxI32 GrOriginLocation_t; -#define GR_ORIGIN_UPPER_LEFT 0x0 -#define GR_ORIGIN_LOWER_LEFT 0x1 -#define GR_ORIGIN_ANY 0xFF - -typedef struct -{ - int size; - void *lfbPtr; - FxU32 strideInBytes; - GrLfbWriteMode_t writeMode; - GrOriginLocation_t origin; -} -GrLfbInfo_t; - -typedef FxI32 GrLOD_t; -#define GR_LOD_LOG2_2048 0xb -#define GR_LOD_LOG2_1024 0xa -#define GR_LOD_LOG2_512 0x9 -#define GR_LOD_LOG2_256 0x8 -#define GR_LOD_LOG2_128 0x7 -#define GR_LOD_LOG2_64 0x6 -#define GR_LOD_LOG2_32 0x5 -#define GR_LOD_LOG2_16 0x4 -#define GR_LOD_LOG2_8 0x3 -#define GR_LOD_LOG2_4 0x2 -#define GR_LOD_LOG2_2 0x1 -#define GR_LOD_LOG2_1 0x0 - -typedef FxI32 GrMipMapMode_t; -#define GR_MIPMAP_DISABLE 0x0 -#define GR_MIPMAP_NEAREST 0x1 -#define GR_MIPMAP_NEAREST_DITHER 0x2 - -typedef FxI32 GrSmoothingMode_t; -#define GR_SMOOTHING_DISABLE 0x0 -#define GR_SMOOTHING_ENABLE 0x1 - -typedef FxI32 GrTextureClampMode_t; -#define GR_TEXTURECLAMP_WRAP 0x0 -#define GR_TEXTURECLAMP_CLAMP 0x1 -#define GR_TEXTURECLAMP_MIRROR_EXT 0x2 - -typedef FxI32 GrTextureCombineFnc_t; -#define GR_TEXTURECOMBINE_ZERO 0x0 -#define GR_TEXTURECOMBINE_DECAL 0x1 -#define GR_TEXTURECOMBINE_OTHER 0x2 -#define GR_TEXTURECOMBINE_ADD 0x3 -#define GR_TEXTURECOMBINE_MULTIPLY 0x4 -#define GR_TEXTURECOMBINE_SUBTRACT 0x5 -#define GR_TEXTURECOMBINE_DETAIL 0x6 -#define GR_TEXTURECOMBINE_DETAIL_OTHER 0x7 -#define GR_TEXTURECOMBINE_TRILINEAR_ODD 0x8 -#define GR_TEXTURECOMBINE_TRILINEAR_EVEN 0x9 -#define GR_TEXTURECOMBINE_ONE 0xa - -typedef FxI32 GrTextureFilterMode_t; -#define GR_TEXTUREFILTER_POINT_SAMPLED 0x0 -#define GR_TEXTUREFILTER_BILINEAR 0x1 - -typedef FxI32 GrTextureFormat_t; -#define GR_TEXFMT_8BIT 0x0 -#define GR_TEXFMT_RGB_332 GR_TEXFMT_8BIT -#define GR_TEXFMT_YIQ_422 0x1 -#define GR_TEXFMT_ALPHA_8 0x2 -#define GR_TEXFMT_INTENSITY_8 0x3 -#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4 -#define GR_TEXFMT_P_8 0x5 -#define GR_TEXFMT_RSVD0 0x6 -#define GR_TEXFMT_RSVD1 0x7 -#define GR_TEXFMT_16BIT 0x8 -#define GR_TEXFMT_ARGB_8332 GR_TEXFMT_16BIT -#define GR_TEXFMT_AYIQ_8422 0x9 -#define GR_TEXFMT_RGB_565 0xa -#define GR_TEXFMT_ARGB_1555 0xb -#define GR_TEXFMT_ARGB_4444 0xc -#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd -#define GR_TEXFMT_AP_88 0xe -#define GR_TEXFMT_RSVD2 0xf -#define GR_TEXFMT_ARGB_CMP_FXT1 0x11 -#define GR_TEXFMT_ARGB_8888 0x12 -#define GR_TEXFMT_YUYV_422 0x13 -#define GR_TEXFMT_UYVY_422 0x14 -#define GR_TEXFMT_AYUV_444 0x15 -#define GR_TEXFMT_ARGB_CMP_DXT1 0x16 -#define GR_TEXFMT_ARGB_CMP_DXT2 0x17 -#define GR_TEXFMT_ARGB_CMP_DXT3 0x18 -#define GR_TEXFMT_ARGB_CMP_DXT4 0x19 -#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A - -typedef FxU32 GrTexTable_t; -#define GR_TEXTABLE_NCC0 0x0 -#define GR_TEXTABLE_NCC1 0x1 -#define GR_TEXTABLE_PALETTE 0x2 -#define GR_TEXTABLE_PALETTE_6666_EXT 0x3 - -typedef FxU32 GrNCCTable_t; -#define GR_NCCTABLE_NCC0 0x0 -#define GR_NCCTABLE_NCC1 0x1 - -typedef FxU32 GrTexBaseRange_t; -#define GR_TEXBASE_256 0x3 -#define GR_TEXBASE_128 0x2 -#define GR_TEXBASE_64 0x1 -#define GR_TEXBASE_32_TO_1 0x0 -#define GR_TEXBASE_2048 0x7 -#define GR_TEXBASE_1024 0x6 -#define GR_TEXBASE_512 0x5 -#define GR_TEXBASE_256_TO_1 0x4 - -typedef FxU32 GrEnableMode_t; -#define GR_MODE_DISABLE 0x0 -#define GR_MODE_ENABLE 0x1 - -#define GR_AA_ORDERED 0x01 -#define GR_ALLOW_MIPMAP_DITHER 0x02 -#define GR_PASSTHRU 0x03 -#define GR_SHAMELESS_PLUG 0x04 -#define GR_VIDEO_SMOOTHING 0x05 - -typedef FxU32 GrCoordinateSpaceMode_t; -#define GR_WINDOW_COORDS 0x00 -#define GR_CLIP_COORDS 0x01 - -/* Parameters for strips */ -#define GR_PARAM_XY 0x01 -#define GR_PARAM_Z 0x02 -#define GR_PARAM_W 0x03 -#define GR_PARAM_Q 0x04 -#define GR_PARAM_FOG_EXT 0x05 - -#define GR_PARAM_A 0x10 - -#define GR_PARAM_RGB 0x20 - -#define GR_PARAM_PARGB 0x30 - -#define GR_PARAM_ST0 0x40 -#define GR_PARAM_ST1 GR_PARAM_ST0+1 -#define GR_PARAM_ST2 GR_PARAM_ST0+2 - -#define GR_PARAM_Q0 0x50 -#define GR_PARAM_Q1 GR_PARAM_Q0+1 -#define GR_PARAM_Q2 GR_PARAM_Q0+2 - -#define GR_PARAM_DISABLE 0x00 -#define GR_PARAM_ENABLE 0x01 - -/* grDrawVertexArray/grDrawVertexArrayContiguous */ -#define GR_POINTS 0 -#define GR_LINE_STRIP 1 -#define GR_LINES 2 -#define GR_POLYGON 3 -#define GR_TRIANGLE_STRIP 4 -#define GR_TRIANGLE_FAN 5 -#define GR_TRIANGLES 6 -#define GR_TRIANGLE_STRIP_CONTINUE 7 -#define GR_TRIANGLE_FAN_CONTINUE 8 - -/* grGet/grReset */ -#define GR_BITS_DEPTH 0x01 -#define GR_BITS_RGBA 0x02 -#define GR_FIFO_FULLNESS 0x03 -#define GR_FOG_TABLE_ENTRIES 0x04 -#define GR_GAMMA_TABLE_ENTRIES 0x05 -#define GR_GLIDE_STATE_SIZE 0x06 -#define GR_GLIDE_VERTEXLAYOUT_SIZE 0x07 -#define GR_IS_BUSY 0x08 -#define GR_LFB_PIXEL_PIPE 0x09 -#define GR_MAX_TEXTURE_SIZE 0x0a -#define GR_MAX_TEXTURE_ASPECT_RATIO 0x0b -#define GR_MEMORY_FB 0x0c -#define GR_MEMORY_TMU 0x0d -#define GR_MEMORY_UMA 0x0e -#define GR_NUM_BOARDS 0x0f -#define GR_NON_POWER_OF_TWO_TEXTURES 0x10 -#define GR_NUM_FB 0x11 -#define GR_NUM_SWAP_HISTORY_BUFFER 0x12 -#define GR_NUM_TMU 0x13 -#define GR_PENDING_BUFFERSWAPS 0x14 -#define GR_REVISION_FB 0x15 -#define GR_REVISION_TMU 0x16 -#define GR_STATS_LINES 0x17 -#define GR_STATS_PIXELS_AFUNC_FAIL 0x18 -#define GR_STATS_PIXELS_CHROMA_FAIL 0x19 -#define GR_STATS_PIXELS_DEPTHFUNC_FAIL 0x1a -#define GR_STATS_PIXELS_IN 0x1b -#define GR_STATS_PIXELS_OUT 0x1c -#define GR_STATS_PIXELS 0x1d -#define GR_STATS_POINTS 0x1e -#define GR_STATS_TRIANGLES_IN 0x1f -#define GR_STATS_TRIANGLES_OUT 0x20 -#define GR_STATS_TRIANGLES 0x21 -#define GR_SWAP_HISTORY 0x22 -#define GR_SUPPORTS_PASSTHRU 0x23 -#define GR_TEXTURE_ALIGN 0x24 -#define GR_VIDEO_POSITION 0x25 -#define GR_VIEWPORT 0x26 -#define GR_WDEPTH_MIN_MAX 0x27 -#define GR_ZDEPTH_MIN_MAX 0x28 -#define GR_VERTEX_PARAMETER 0x29 -#define GR_BITS_GAMMA 0x2a -#define GR_GET_RESERVED_1 0x1000 - -/* grGetString types */ -#define GR_EXTENSION 0xa0 -#define GR_HARDWARE 0xa1 -#define GR_RENDERER 0xa2 -#define GR_VENDOR 0xa3 -#define GR_VERSION 0xa4 - -typedef FxI32 GrScreenRefresh_t; -#define GR_REFRESH_NONE 0xff - -typedef FxI32 GrScreenResolution_t; -#define GR_RESOLUTION_NONE 0xff - -typedef struct -{ - GrLOD_t smallLodLog2; - GrLOD_t largeLodLog2; - GrAspectRatio_t aspectRatioLog2; - GrTextureFormat_t format; - void *data; -} -GrTexInfo; - -typedef struct GrSstPerfStats_s -{ - FxU32 pixelsIn; - FxU32 chromaFail; - FxU32 zFuncFail; - FxU32 aFuncFail; - FxU32 pixelsOut; -} -GrSstPerfStats_t; - -typedef struct -{ - GrScreenResolution_t resolution; - GrScreenRefresh_t refresh; - int numColorBuffers; - int numAuxBuffers; -} -GrResolution; - -typedef GrResolution GlideResolution; -#define GR_QUERY_ANY ((FxU32)(~0)) - -typedef FxU32 GrLfbSrcFmt_t; -#define GR_LFB_SRC_FMT_565 0x00 -#define GR_LFB_SRC_FMT_555 0x01 -#define GR_LFB_SRC_FMT_1555 0x02 -#define GR_LFB_SRC_FMT_888 0x04 -#define GR_LFB_SRC_FMT_8888 0x05 -#define GR_LFB_SRC_FMT_565_DEPTH 0x0c -#define GR_LFB_SRC_FMT_555_DEPTH 0x0d -#define GR_LFB_SRC_FMT_1555_DEPTH 0x0e -#define GR_LFB_SRC_FMT_ZA16 0x0f -#define GR_LFB_SRC_FMT_RLE16 0x80 - -typedef FxU32 GrPixelFormat_t; -#define GR_PIXFMT_I_8 0x0001 -#define GR_PIXFMT_AI_88 0x0002 -#define GR_PIXFMT_RGB_565 0x0003 -#define GR_PIXFMT_ARGB_1555 0x0004 -#define GR_PIXFMT_ARGB_8888 0x0005 -#define GR_PIXFMT_AA_2_RGB_565 0x0006 -#define GR_PIXFMT_AA_2_ARGB_1555 0x0007 -#define GR_PIXFMT_AA_2_ARGB_8888 0x0008 -#define GR_PIXFMT_AA_4_RGB_565 0x0009 -#define GR_PIXFMT_AA_4_ARGB_1555 0x000a -#define GR_PIXFMT_AA_4_ARGB_8888 0x000b - -#define GR_LFBWRITEMODE_Z32 0x0008 - -typedef FxU32 GrAAMode_t; -#define GR_AA_NONE 0x0000 -#define GR_AA_4SAMPLES 0x0001 - -typedef FxU8 GrStencil_t; - -typedef FxU32 GrStencilOp_t; -#define GR_STENCILOP_KEEP 0x00 -#define GR_STENCILOP_ZERO 0x01 -#define GR_STENCILOP_REPLACE 0x02 -#define GR_STENCILOP_INCR_CLAMP 0x03 -#define GR_STENCILOP_DECR_CLAMP 0x04 -#define GR_STENCILOP_INVERT 0x05 -#define GR_STENCILOP_INCR_WRAP 0x06 -#define GR_STENCILOP_DECR_WRAP 0x07 - -#define GR_TEXTURE_UMA_EXT 0x06 -#define GR_STENCIL_MODE_EXT 0x07 -#define GR_OPENGL_MODE_EXT 0x08 - -typedef FxU32 GrCCUColor_t; -typedef FxU32 GrACUColor_t; -typedef FxU32 GrTCCUColor_t; -typedef FxU32 GrTACUColor_t; -#define GR_CMBX_ZERO 0x00 -#define GR_CMBX_TEXTURE_ALPHA 0x01 -#define GR_CMBX_ALOCAL 0x02 -#define GR_CMBX_AOTHER 0x03 -#define GR_CMBX_B 0x04 -#define GR_CMBX_CONSTANT_ALPHA 0x05 -#define GR_CMBX_CONSTANT_COLOR 0x06 -#define GR_CMBX_DETAIL_FACTOR 0x07 -#define GR_CMBX_ITALPHA 0x08 -#define GR_CMBX_ITRGB 0x09 -#define GR_CMBX_LOCAL_TEXTURE_ALPHA 0x0a -#define GR_CMBX_LOCAL_TEXTURE_RGB 0x0b -#define GR_CMBX_LOD_FRAC 0x0c -#define GR_CMBX_OTHER_TEXTURE_ALPHA 0x0d -#define GR_CMBX_OTHER_TEXTURE_RGB 0x0e -#define GR_CMBX_TEXTURE_RGB 0x0f -#define GR_CMBX_TMU_CALPHA 0x10 -#define GR_CMBX_TMU_CCOLOR 0x11 - -typedef FxU32 GrCombineMode_t; -#define GR_FUNC_MODE_ZERO 0x00 -#define GR_FUNC_MODE_X 0x01 -#define GR_FUNC_MODE_ONE_MINUS_X 0x02 -#define GR_FUNC_MODE_NEGATIVE_X 0x03 -#define GR_FUNC_MODE_X_MINUS_HALF 0x04 - -typedef FxU32 GrAlphaBlendOp_t; -#define GR_BLEND_OP_ADD 0x00 -#define GR_BLEND_OP_SUB 0x01 -#define GR_BLEND_OP_REVSUB 0x02 - -typedef struct -{ - FxU32 data[256]; -} -GuTexPalette; - -typedef void (*GrErrorCallbackFnc_t) (const char *string, FxBool fatal); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_lock.c b/src/mesa/drivers/dri/tdfx/tdfx_lock.c deleted file mode 100644 index f218e4ee576..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_lock.c +++ /dev/null @@ -1,100 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#include "tdfx_context.h" -#include "tdfx_lock.h" -#include "tdfx_state.h" -#include "tdfx_render.h" -#include "tdfx_texman.h" - -#include "drirenderbuffer.h" - - -void tdfxGetLock( tdfxContextPtr fxMesa ) -{ - __DRIcontext *cPriv = fxMesa->driContext; - __DRIdrawable *const drawable = cPriv->driDrawablePriv; - __DRIdrawable *const readable = cPriv->driReadablePriv; - __DRIscreen *sPriv = drawable->driScreenPriv; - TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) + - fxMesa->fxScreen->sarea_priv_offset); - unsigned int stamp = drawable->lastStamp; - - drmGetLock( fxMesa->driFd, fxMesa->hHWContext, 0 ); - - /* This macro will update drawable's cliprects if needed */ - DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable); - if (drawable != readable) { - DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable); - } - - if ( saPriv->fifoOwner != fxMesa->hHWContext ) { - fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead ); - } - - if ( saPriv->ctxOwner != fxMesa->hHWContext ) { - /* This sequence looks a little odd. Glide mirrors the state, and - * when you get the state you are forcing the mirror to be up to - * date, and then getting a copy from the mirror. You can then force - * that state onto the hardware when you set the state. - */ - void *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 ); - } - -#if 0 - if ( saPriv->texOwner != fxMesa->hHWContext ) { - tdfxTMRestoreTextures_NoLock( fxMesa ); - } -#endif - - if ((*drawable->pStamp != stamp) - || (saPriv->ctxOwner != fxMesa->hHWContext)) { - driUpdateFramebufferSize(fxMesa->glCtx, drawable); - if (drawable != readable) { - driUpdateFramebufferSize(fxMesa->glCtx, readable); - } - - tdfxUpdateClipping(fxMesa->glCtx); - tdfxUploadClipping(fxMesa); - } - - DEBUG_LOCK(); -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_lock.h b/src/mesa/drivers/dri/tdfx/tdfx_lock.h deleted file mode 100644 index 74e3f5c9cc4..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_lock.h +++ /dev/null @@ -1,143 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __TDFX_LOCK_H__ -#define __TDFX_LOCK_H__ - -/* You can turn this 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 /* DEBUG_LOCKING */ - - -extern void tdfxGetLock( tdfxContextPtr fxMesa ); - - -/* !!! 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 !!! */ - -#define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \ - do { \ - DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ - if (__ret) drmGetLock(fd,context,0); \ - } while(0) - -#define LOCK_HARDWARE( fxMesa ) \ - do { \ - char __ret = 0; \ - \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( fxMesa->driHwLock, fxMesa->hHWContext, \ - DRM_LOCK_HELD | fxMesa->hHWContext, __ret ); \ - if ( __ret ) { \ - tdfxGetLock( fxMesa ); \ - } \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware using the global current context */ -#define UNLOCK_HARDWARE( fxMesa ) \ - do { \ - DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); \ - DEBUG_RESET(); \ - } while (0) - -/* - * This pair of macros makes a loop over the drawing operations - * so it is not self contained and doesn't have the nice single - * statement semantics of most macros. - */ -#define BEGIN_CLIP_LOOP(fxMesa) \ - do { \ - LOCK_HARDWARE( fxMesa ); \ - BEGIN_CLIP_LOOP_LOCKED( fxMesa ) - -#define BEGIN_CLIP_LOOP_LOCKED(fxMesa) \ - do { \ - int _nc = fxMesa->numClipRects; \ - while (_nc--) { \ - if (fxMesa->numClipRects > 1) { \ - int _height = fxMesa->screen_height; \ - fxMesa->Glide.grClipWindow(fxMesa->pClipRects[_nc].x1, \ - _height - fxMesa->pClipRects[_nc].y2, \ - fxMesa->pClipRects[_nc].x2, \ - _height - fxMesa->pClipRects[_nc].y1); \ - } - - -#define END_CLIP_LOOP_LOCKED( fxMesa ) \ - } \ - } while (0) - -#define END_CLIP_LOOP( fxMesa ) \ - END_CLIP_LOOP_LOCKED( fxMesa ); \ - UNLOCK_HARDWARE( fxMesa ); \ - } while (0) - -#endif /* __TDFX_LOCK_H__ */ diff --git a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c deleted file mode 100644 index bbbd0d5740f..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c +++ /dev/null @@ -1,686 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * Nathan Hand <[email protected]> - * - */ - -#include "tdfx_context.h" -#include "tdfx_dd.h" -#include "tdfx_lock.h" -#include "tdfx_pixels.h" -#include "tdfx_render.h" - -#include "swrast/swrast.h" - -#include "main/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); - - -#if 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; -} -#endif - - -#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 -inClipRects(tdfxContextPtr fxMesa, int px, int py) -{ - int i; - for (i = 0; i < fxMesa->numClipRects; i++) { - if ((px >= fxMesa->pClipRects[i].x1) && - (px < fxMesa->pClipRects[i].x2) && - (py >= fxMesa->pClipRects[i].y1) && - (py < fxMesa->pClipRects[i].y2)) return GL_TRUE; - } - return GL_FALSE; -} -#endif - -/* test if rectangle of pixels (px,py) (px+width,py+height) is visible */ -static GLboolean -inClipRects_Region(tdfxContextPtr fxMesa, int x, int y, int width, int height) -{ - int i; - int x1, y1, x2, y2; - int xmin, xmax, ymin, ymax, pixelsleft; - - y1 = y - height + 1; y2 = y; - x1 = x; x2 = x + width - 1; - pixelsleft = width * height; - - for (i = 0; i < fxMesa->numClipRects; i++) - { - /* algorithm requires x1 < x2 and y1 < y2 */ - if ((fxMesa->pClipRects[i].x1 < fxMesa->pClipRects[i].x2)) { - xmin = fxMesa->pClipRects[i].x1; - xmax = fxMesa->pClipRects[i].x2-1; - } else { - xmin = fxMesa->pClipRects[i].x2; - xmax = fxMesa->pClipRects[i].x1-1; - } - if ((fxMesa->pClipRects[i].y1 < fxMesa->pClipRects[i].y2)) { - ymin = fxMesa->pClipRects[i].y1; - ymax = fxMesa->pClipRects[i].y2-1; - } else { - ymin = fxMesa->pClipRects[i].y2; - ymax = fxMesa->pClipRects[i].y1-1; - } - - /* reject trivial cases */ - if (xmax < x1) continue; - if (ymax < y1) continue; - if (xmin > x2) continue; - if (ymin > y2) continue; - - /* find the intersection */ - if (xmin < x1) xmin = x1; - if (ymin < y1) ymin = y1; - if (xmax > x2) xmax = x2; - if (ymax > y2) ymax = y2; - - pixelsleft -= (xmax-xmin+1) * (ymax-ymin+1); - } - - return pixelsleft == 0; -} - -#if 0 -GLboolean -tdfx_bitmap_R5G6B5(struct gl_context * ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte * bitmap) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - TdfxU16 color; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - /* check if there's any raster operations enabled which we can't handle */ - if (ctx->RasterMask & (ALPHATEST_BIT | - BLEND_BIT | - DEPTH_BIT | - FOG_BIT | - LOGIC_OP_BIT | - SCISSOR_BIT | - STENCIL_BIT | - MASKING_BIT | - MULTI_DRAW_BIT)) return GL_FALSE; - - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (px < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - px); - width -= (ctx->Scissor.X - px); - px = ctx->Scissor.X; - } - /* clip right */ - if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (py < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - py); - height -= (ctx->Scissor.Y - py); - py = ctx->Scissor.Y; - } - /* clip top */ - if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return GL_TRUE; /* totally scissored away */ - } - else { - finalUnpack = unpack; - } - - /* compute pixel value */ - { - GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f); - GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f); - GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f); - /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f); */ - if (fxMesa->bgrOrder) { - color = (TdfxU16) - (((TdfxU16) 0xf8 & b) << (11 - 3)) | - (((TdfxU16) 0xfc & g) << (5 - 3 + 1)) | - (((TdfxU16) 0xf8 & r) >> 3); - } - else - color = (TdfxU16) - (((TdfxU16) 0xf8 & r) << (11 - 3)) | - (((TdfxU16) 0xfc & g) << (5 - 3 + 1)) | - (((TdfxU16) 0xf8 & b) >> 3); - } - - info.size = sizeof(info); - if (!TDFX_grLfbLock(fxMesa, - GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_565, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { -#ifndef TDFX_SILENT - fprintf(stderr, "tdfx Driver: error locking the linear frame buffer\n"); -#endif - return GL_TRUE; - } - - { - const GLint winX = fxMesa->x_offset; - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - /* The dest stride depends on the hardware and whether we're drawing - * to the front or back buffer. This compile-time test seems to do - * the job for now. - */ - const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) - ? (fxMesa->screen_width) : (info.strideInBytes / 2); - GLint row; - /* compute dest address of bottom-left pixel in bitmap */ - GLushort *dst = (GLushort *) info.lfbPtr - + (winY - py) * dstStride + (winX + px); - - for (row = 0; row < height; row++) { - const GLubyte *src = - (const GLubyte *) _mesa_image_address2d(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, - GL_BITMAP, row, 0); - if (finalUnpack->LsbFirst) { - /* least significan bit first */ - GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - if (inClipRects(fxMesa, winX + px + col, winY - py - row)) - dst[col] = color; - } - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - if (mask != 1) - src++; - } - else { - /* most significan bit first */ - GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - if (inClipRects(fxMesa, winX + px + col, winY - py - row)) - dst[col] = color; - } - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - if (mask != 128) - src++; - } - dst -= dstStride; - } - } - - TDFX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB); - return GL_TRUE; -} -#endif - -#if 0 -GLboolean -tdfx_bitmap_R8G8B8A8(struct gl_context * ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte * bitmap) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GLuint color; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - /* check if there's any raster operations enabled which we can't handle */ - if (ctx->RasterMask & (ALPHATEST_BIT | - BLEND_BIT | - DEPTH_BIT | - FOG_BIT | - LOGIC_OP_BIT | - SCISSOR_BIT | - STENCIL_BIT | - MASKING_BIT | - MULTI_DRAW_BIT)) return GL_FALSE; - - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (px < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - px); - width -= (ctx->Scissor.X - px); - px = ctx->Scissor.X; - } - /* clip right */ - if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (py < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - py); - height -= (ctx->Scissor.Y - py); - py = ctx->Scissor.Y; - } - /* clip top */ - if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return GL_TRUE; /* totally scissored away */ - } - else { - finalUnpack = unpack; - } - - /* compute pixel value */ - { - GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f); - GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f); - GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f); - GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0f); - color = PACK_BGRA32(r, g, b, a); - } - - info.size = sizeof(info); - if (!TDFX_grLfbLock(fxMesa, GR_LFB_WRITE_ONLY, - fxMesa->currentFB, GR_LFBWRITEMODE_8888, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { -#ifndef TDFX_SILENT - fprintf(stderr, "tdfx Driver: error locking the linear frame buffer\n"); -#endif - return GL_TRUE; - } - - { - const GLint winX = fxMesa->x_offset; - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - GLint dstStride; - GLuint *dst; - GLint row; - - if (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) { - dstStride = fxMesa->screen_width; - dst = - (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + - px); - } - else { - dstStride = info.strideInBytes / 4; - dst = - (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + - px); - } - - /* compute dest address of bottom-left pixel in bitmap */ - for (row = 0; row < height; row++) { - const GLubyte *src = - (const GLubyte *) _mesa_image_address2d(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, - GL_BITMAP, row, 0); - if (finalUnpack->LsbFirst) { - /* least significan bit first */ - GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - if (inClipRects(fxMesa, winX + px + col, winY - py - row)) - dst[col] = color; - } - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - if (mask != 1) - src++; - } - else { - /* most significan bit first */ - GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - if (inClipRects(fxMesa, winX + px + col, winY - py - row)) - dst[col] = color; - } - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - if (mask != 128) - src++; - } - dst -= dstStride; - } - } - - TDFX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB); - return GL_TRUE; -} -#endif - -void -tdfx_readpixels_R5G6B5(struct gl_context * 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 || - (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; - __DRIdrawable *const readable = fxMesa->driReadable; - const GLint winX = readable->x; - const GLint winY = readable->y + readable->h - 1; - const GLint scrX = winX + x; - const GLint scrY = winY - 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)) { - const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer[0] == - GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2); - const GLushort *src = (const GLushort *) info.lfbPtr - + scrY * srcStride + scrX; - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, - dstImage, width, height, format, type, 0, 0); - const GLint dstStride = _mesa_image_row_stride(packing, - width, format, type); - - /* 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; - } -} - -void -tdfx_readpixels_R8G8B8A8(struct gl_context * 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)) || - (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; - __DRIdrawable *const readable = fxMesa->driReadable; - const GLint winX = readable->x; - const GLint winY = readable->y + readable->h - 1; - const GLint scrX = winX + x; - const GLint scrY = winY - 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)) - { - const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) - ? (fxMesa->screen_width) : (info.strideInBytes / 4); - const GLuint *src = (const GLuint *) info.lfbPtr - + scrY * srcStride + scrX; - const GLint dstStride = - _mesa_image_row_stride(packing, width, format, type); - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, - dstImage, width, height, format, type, 0, 0); - const GLint widthInBytes = width * 4; - - { - 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); - } -} - -void -tdfx_drawpixels_R8G8B8A8(struct gl_context * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - 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][0] || - !ctx->Color.ColorMask[0][1] || - !ctx->Color.ColorMask[0][2] || - !ctx->Color.ColorMask[0][3] || - ctx->Color.ColorLogicOpEnabled || - ctx->Texture._EnabledUnits || - fxMesa->Fallback) - { - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - 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; - const GLint scrX = winX + x; - const GLint scrY = winY - y; - - /* lock early to make sure cliprects are right */ - LOCK_HARDWARE(fxMesa); - - /* make sure hardware has latest blend funcs */ - if (ctx->Color.BlendEnabled) { - fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC; - tdfxEmitHwStateLocked( fxMesa ); - } - - /* look for clipmasks, giveup if region obscured */ - if (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) { - if (!inClipRects_Region(fxMesa, scrX, scrY, width, height)) { - UNLOCK_HARDWARE(fxMesa); - _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)) - { - const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) - ? (fxMesa->screen_width * 4) : (info.strideInBytes); - GLubyte *dst = (GLubyte *) info.lfbPtr - + scrY * dstStride + scrX * 4; - const GLint srcStride = - _mesa_image_row_stride(unpack, width, format, type); - const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack, - pixels, width, height, format, type, 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_WRITE_ONLY, fxMesa->DrawBuffer); - } - UNLOCK_HARDWARE(fxMesa); - } -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_pixels.h b/src/mesa/drivers/dri/tdfx/tdfx_pixels.h deleted file mode 100644 index f4cc20fd625..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_pixels.h +++ /dev/null @@ -1,76 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * Nathan Hand <[email protected]> - * - */ - -#ifndef __TDFX_PIXELS_H__ -#define __TDFX_PIXELS_H__ - -#include "main/context.h" - -extern void -tdfx_bitmap_R5G6B5( struct gl_context *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - -extern void -tdfx_bitmap_R8G8B8A8( struct gl_context *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - -extern void -tdfx_readpixels_R5G6B5( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage ); - -extern void -tdfx_readpixels_R8G8B8A8( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage ); - -extern void -tdfx_drawpixels_R8G8B8A8( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.c b/src/mesa/drivers/dri/tdfx/tdfx_render.c deleted file mode 100644 index f0837567877..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_render.c +++ /dev/null @@ -1,804 +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. - */ - -/* - * New fixes: - * Daniel Borca <[email protected]>, 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#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 void tdfxClear( struct gl_context *ctx, GLbitfield mask ) -{ - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLbitfield softwareMask = mask & (BUFFER_BIT_ACCUM); - const GLuint stencil_size = - fxMesa->haveHwStencil ? fxMesa->glCtx->Visual.stencilBits : 0; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "tdfxClear(0x%x)\n", mask); - } - - /* Need this check to respond to glScissor and clipping updates */ - if ((fxMesa->new_state & (TDFX_NEW_CLIP | TDFX_NEW_DEPTH)) || - (fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK)) { - tdfxDDUpdateHwState(ctx); - } - - /* we can't clear accum buffers */ - mask &= ~(BUFFER_BIT_ACCUM); - - if (mask & BUFFER_BIT_STENCIL) { - if (!fxMesa->haveHwStencil || (ctx->Stencil.WriteMask[0] & 0xff) != 0xff) { - /* Napalm seems to have trouble with stencil write masks != 0xff */ - /* do stencil clear in software */ - mask &= ~(BUFFER_BIT_STENCIL); - softwareMask |= BUFFER_BIT_STENCIL; - } - } - - if (fxMesa->glCtx->Visual.redBits != 8) { - /* can only do color masking if running in 24/32bpp on Napalm */ - if (ctx->Color.ColorMask[0][RCOMP] != ctx->Color.ColorMask[0][GCOMP] || - ctx->Color.ColorMask[0][GCOMP] != ctx->Color.ColorMask[0][BCOMP]) { - softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)); - mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); - } - } - - if (fxMesa->haveHwStencil) { - /* - * If we want to clear stencil, it must be enabled - * in the HW, even if the stencil test is not enabled - * in the OGL state. - */ - LOCK_HARDWARE(fxMesa); - if (mask & BUFFER_BIT_STENCIL) { - fxMesa->Glide.grStencilMask(/*ctx->Stencil.WriteMask*/ 0xff); - /* set stencil ref value = desired clear value */ - fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS, - (fxMesa->Stencil.Clear & 0xff), 0xff); - fxMesa->Glide.grStencilOp(GR_STENCILOP_REPLACE, - GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE); - fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT); - } - else { - fxMesa->Glide.grDisable(GR_STENCIL_MODE_EXT); - } - UNLOCK_HARDWARE(fxMesa); - } - - /* - * This may be ugly, but it's needed in order to work around a number - * of Glide bugs. - */ - BEGIN_CLIP_LOOP(fxMesa); - { - /* - * This could probably be done fancier but doing each possible case - * explicitly is less error prone. - */ - switch (mask & ~BUFFER_BIT_STENCIL) { - case BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH: - /* back buffer & depth */ - FX_grColorMaskv_NoLock(ctx, true4); /* work around Voodoo3 bug */ - fxMesa->Glide.grDepthMask(FXTRUE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) { - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - } - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (!ctx->Depth.Mask || !ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXFALSE); - } - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_DEPTH: - /* XXX it appears that the depth buffer isn't cleared when - * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set. - * This is a work-around/ - */ - /* clear depth */ - fxMesa->Glide.grDepthMask(FXTRUE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grColorMaskv_NoLock(ctx, false4); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear & 0xff); - /* clear front */ - FX_grColorMaskv_NoLock(ctx, true4); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (!ctx->Depth.Mask || !ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXFALSE); - } - break; - case BUFFER_BIT_BACK_LEFT: - /* back buffer only */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - break; - case BUFFER_BIT_FRONT_LEFT: - /* front buffer only */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT: - /* front and back */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH: - /* clear front */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - /* clear back and depth */ - fxMesa->Glide.grDepthMask(FXTRUE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (!ctx->Depth.Mask || !ctx->Depth.Mask) { - fxMesa->Glide.grDepthMask(FXFALSE); - } - break; - case BUFFER_BIT_DEPTH: - /* just the depth buffer */ - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grColorMaskv_NoLock(ctx, false4); - fxMesa->Glide.grDepthMask(FXTRUE); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - FX_grColorMaskv_NoLock(ctx, true4); - if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (!ctx->Depth.Test || !ctx->Depth.Mask) - fxMesa->Glide.grDepthMask(FXFALSE); - break; - default: - /* clear no color buffers or depth buffer but might clear stencil */ - if (stencil_size > 0 && (mask & BUFFER_BIT_STENCIL)) { - /* XXX need this RenderBuffer call to work around Glide bug */ - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - fxMesa->Glide.grDepthMask(FXFALSE); - FX_grColorMaskv_NoLock(ctx, false4); - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) (ctx->Stencil.Clear & 0xff)); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - FX_grColorMaskv_NoLock(ctx, true4); - if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - } - } - } - END_CLIP_LOOP(fxMesa); - - if (fxMesa->haveHwStencil && (mask & BUFFER_BIT_STENCIL)) { - /* We changed the stencil state above. Signal that we need to - * upload it again. - */ - fxMesa->dirty |= TDFX_UPLOAD_STENCIL; - } - - if (softwareMask) - _swrast_Clear(ctx, softwareMask); -} - - - -static void tdfxFinish( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - - LOCK_HARDWARE( fxMesa ); - fxMesa->Glide.grFinish(); - UNLOCK_HARDWARE( fxMesa ); -} - -static void tdfxFlush( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - - LOCK_HARDWARE( fxMesa ); - fxMesa->Glide.grFlush(); - UNLOCK_HARDWARE( fxMesa ); -} - - -#if 0 -static const char *texSource(int k) -{ - switch (k) { - case GR_CMBX_ZERO: - return "GR_CMBX_ZERO"; - case GR_CMBX_TEXTURE_ALPHA: - return "GR_CMBX_TEXTURE_ALPHA"; - case GR_CMBX_ALOCAL: - return "GR_CMBX_ALOCAL"; - case GR_CMBX_AOTHER: - return "GR_CMBX_AOTHER"; - case GR_CMBX_B: - return "GR_CMBX_B"; - case GR_CMBX_CONSTANT_ALPHA: - return "GR_CMBX_CONSTANT_ALPHA"; - case GR_CMBX_CONSTANT_COLOR: - return "GR_CMBX_CONSTANT_COLOR"; - case GR_CMBX_DETAIL_FACTOR: - return "GR_CMBX_DETAIL_FACTOR"; - case GR_CMBX_ITALPHA: - return "GR_CMBX_ITALPHA"; - case GR_CMBX_ITRGB: - return "GR_CMBX_ITRGB"; - case GR_CMBX_LOCAL_TEXTURE_ALPHA: - return "GR_CMBX_LOCAL_TEXTURE_ALPHA"; - case GR_CMBX_LOCAL_TEXTURE_RGB: - return "GR_CMBX_LOCAL_TEXTURE_RGB"; - case GR_CMBX_LOD_FRAC: - return "GR_CMBX_LOD_FRAC"; - case GR_CMBX_OTHER_TEXTURE_ALPHA: - return "GR_CMBX_OTHER_TEXTURE_ALPHA"; - case GR_CMBX_OTHER_TEXTURE_RGB: - return "GR_CMBX_OTHER_TEXTURE_RGB"; - case GR_CMBX_TEXTURE_RGB: - return "GR_CMBX_TEXTURE_RGB"; - case GR_CMBX_TMU_CALPHA: - return "GR_CMBX_TMU_CALPHA"; - case GR_CMBX_TMU_CCOLOR: - return "GR_CMBX_TMU_CCOLOR"; - default: - return ""; - } -} -#endif - -#if 0 -static const char *texMode(int k) -{ - switch (k) { - case GR_FUNC_MODE_ZERO: - return "GR_FUNC_MODE_ZERO"; - case GR_FUNC_MODE_X: - return "GR_FUNC_MODE_X"; - case GR_FUNC_MODE_ONE_MINUS_X: - return "GR_FUNC_MODE_ONE_MINUS_X"; - case GR_FUNC_MODE_NEGATIVE_X: - return "GR_FUNC_MODE_NEGATIVE_X"; - case GR_FUNC_MODE_X_MINUS_HALF: - return "GR_FUNC_MODE_X_MINUS_HALF"; - default: - return ""; - } -} -#endif - -#if 0 -static const char *texInvert(int k) -{ - return k ? "FXTRUE" : "FXFALSE"; -} -#endif - -static void uploadTextureEnv( tdfxContextPtr fxMesa ) -{ - if (TDFX_IS_NAPALM(fxMesa)) { - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { -#if 0 - printf("upload env %d\n", unit); - printf(" cSourceA = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceA)); - printf(" cModeA = %s\n", texMode(fxMesa->TexCombineExt[unit].Color.ModeA)); - printf(" cSourceB = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceB)); - printf(" cModeB = %s\n", texMode(fxMesa->TexCombineExt[unit].Color.ModeB)); - printf(" cSourceC = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceC)); - printf(" cInvertC = %s\n", texInvert(fxMesa->TexCombineExt[unit].Color.InvertC)); - printf(" cSourceD = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceD)); - printf(" cInvertD = %s\n", texInvert(fxMesa->TexCombineExt[unit].Color.InvertD)); - printf(" cShift = %d\t", fxMesa->TexCombineExt[unit].Color.Shift); - printf(" cInvert = %d\n", fxMesa->TexCombineExt[unit].Color.Invert); - printf(" aSourceA = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceA)); - printf(" aModeA = %s\n", texMode(fxMesa->TexCombineExt[unit].Alpha.ModeA)); - printf(" aSourceB = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceB)); - printf(" aModeB = %s\n", texMode(fxMesa->TexCombineExt[unit].Alpha.ModeB)); - printf(" aSourceC = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceC)); - printf(" aInvertC = %s\n", texInvert(fxMesa->TexCombineExt[unit].Alpha.InvertC)); - printf(" aSourceD = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceD)); - printf(" aInvertD = %s\n", texInvert(fxMesa->TexCombineExt[unit].Alpha.InvertD)); - printf(" aShift = %d\t", fxMesa->TexCombineExt[unit].Alpha.Shift); - printf(" aInvert = %d\n", fxMesa->TexCombineExt[unit].Alpha.Invert); - printf(" Color = 0x%08x\n", fxMesa->TexCombineExt[unit].EnvColor); -#endif - fxMesa->Glide.grTexColorCombineExt(TDFX_TMU0 + unit, - fxMesa->TexCombineExt[unit].Color.SourceA, - fxMesa->TexCombineExt[unit].Color.ModeA, - fxMesa->TexCombineExt[unit].Color.SourceB, - fxMesa->TexCombineExt[unit].Color.ModeB, - fxMesa->TexCombineExt[unit].Color.SourceC, - fxMesa->TexCombineExt[unit].Color.InvertC, - fxMesa->TexCombineExt[unit].Color.SourceD, - fxMesa->TexCombineExt[unit].Color.InvertD, - fxMesa->TexCombineExt[unit].Color.Shift, - fxMesa->TexCombineExt[unit].Color.Invert); - fxMesa->Glide.grTexAlphaCombineExt(TDFX_TMU0 + unit, - fxMesa->TexCombineExt[unit].Alpha.SourceA, - fxMesa->TexCombineExt[unit].Alpha.ModeA, - fxMesa->TexCombineExt[unit].Alpha.SourceB, - fxMesa->TexCombineExt[unit].Alpha.ModeB, - fxMesa->TexCombineExt[unit].Alpha.SourceC, - fxMesa->TexCombineExt[unit].Alpha.InvertC, - fxMesa->TexCombineExt[unit].Alpha.SourceD, - fxMesa->TexCombineExt[unit].Alpha.InvertD, - fxMesa->TexCombineExt[unit].Alpha.Shift, - fxMesa->TexCombineExt[unit].Alpha.Invert); - fxMesa->Glide.grConstantColorValueExt(TDFX_TMU0 + unit, - fxMesa->TexCombineExt[unit].EnvColor); - } - } - else { - /* Voodoo3 */ - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - struct tdfx_texcombine *comb = &fxMesa->TexCombine[unit]; - fxMesa->Glide.grTexCombine(TDFX_TMU0 + unit, - comb->FunctionRGB, - comb->FactorRGB, - comb->FunctionAlpha, - comb->FactorAlpha, - comb->InvertRGB, - comb->InvertAlpha); - } - } -} - - -static void uploadTextureParams( tdfxContextPtr fxMesa ) -{ - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - const struct tdfx_texparams *p = &fxMesa->TexParams[unit]; - /* - printf("upload params %d\n", unit); - printf(" clamp %x %x\n", env->sClamp, env->tClamp); - printf(" filter %x %x\n", env->minFilt, env->magFilt); - printf(" mipmap %x %x\n", env->mmMode, env->LODblend); - printf(" lod bias %f\n", env->LodBias); - */ - fxMesa->Glide.grTexClampMode(GR_TMU0 + unit, p->sClamp, p->tClamp); - fxMesa->Glide.grTexFilterMode(GR_TMU0 + unit, p->minFilt, p->magFilt); - fxMesa->Glide.grTexMipMapMode(GR_TMU0 + unit, p->mmMode, p->LODblend); - fxMesa->Glide.grTexLodBiasValue(GR_TMU0 + unit, CLAMP(p->LodBias, -8, 7.75)); - } -} - - -static void uploadTextureSource( tdfxContextPtr fxMesa ) -{ - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - const struct tdfx_texsource *src = &fxMesa->TexSource[unit]; - /* - printf("upload source %d @ %d %p\n", unit, src->StartAddress, src->Info); - */ - if (src->Info) { - /* - printf(" smallLodLog2=%d largeLodLog2=%d ar=%d format=%d data=%p\n", - src->Info->smallLodLog2, src->Info->largeLodLog2, - src->Info->aspectRatioLog2, src->Info->format, - src->Info->data); - */ - fxMesa->Glide.grTexSource(GR_TMU0 + unit, - src->StartAddress, - src->EvenOdd, - src->Info); - } - } -} - - -static void uploadTextureImages( tdfxContextPtr fxMesa ) -{ - struct gl_context *ctx = fxMesa->glCtx; - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; - 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; - } - } - } -} - - - -/* - * If scissoring is enabled, compute intersection of scissor region - * with all X clip rects, resulting in new cliprect list. - * If number of cliprects is zero or one, call grClipWindow to setup - * the clip region. Otherwise we'll call grClipWindow inside the - * BEGIN_CLIP_LOOP macro. - */ -void tdfxUploadClipping( tdfxContextPtr fxMesa ) -{ - __DRIdrawable *dPriv = fxMesa->driDrawable; - - assert(dPriv); - - if (fxMesa->numClipRects == 0) { - /* all drawing clipped away */ - fxMesa->Glide.grClipWindow(0, 0, 0, 0); - } - 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); - } - /* else, we'll do a cliprect loop around all drawing */ - - fxMesa->Glide.grDRIPosition( dPriv->x, dPriv->y, dPriv->w, dPriv->h, - fxMesa->numClipRects, fxMesa->pClipRects ); -} - - -void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa ) -{ - if ( !fxMesa->dirty ) - return; - - 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); - } - else { - /* Voodoo 3 */ - fxMesa->Glide.grColorCombine( fxMesa->ColorCombine.Function, - fxMesa->ColorCombine.Factor, - fxMesa->ColorCombine.Local, - fxMesa->ColorCombine.Other, - fxMesa->ColorCombine.Invert ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_COMBINE; - } - if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_COMBINE ) { - if (TDFX_IS_NAPALM(fxMesa)) { - fxMesa->Glide.grAlphaCombineExt(fxMesa->AlphaCombineExt.SourceA, - fxMesa->AlphaCombineExt.ModeA, - fxMesa->AlphaCombineExt.SourceB, - fxMesa->AlphaCombineExt.ModeB, - fxMesa->AlphaCombineExt.SourceC, - fxMesa->AlphaCombineExt.InvertC, - fxMesa->AlphaCombineExt.SourceD, - fxMesa->AlphaCombineExt.InvertD, - fxMesa->AlphaCombineExt.Shift, - fxMesa->AlphaCombineExt.Invert); - } - else { - /* Voodoo 3 */ - fxMesa->Glide.grAlphaCombine( fxMesa->AlphaCombine.Function, - fxMesa->AlphaCombine.Factor, - fxMesa->AlphaCombine.Local, - fxMesa->AlphaCombine.Other, - fxMesa->AlphaCombine.Invert ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_COMBINE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_RENDER_BUFFER ) { - fxMesa->Glide.grRenderBuffer( fxMesa->DrawBuffer ); - fxMesa->dirty &= ~TDFX_UPLOAD_RENDER_BUFFER; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE) { - fxMesa->Glide.grStipplePattern( fxMesa->Stipple.Pattern ); - fxMesa->Glide.grStippleMode( fxMesa->Stipple.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_TEST ) { - fxMesa->Glide.grAlphaTestFunction( fxMesa->Color.AlphaFunc ); - fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_TEST; - } - if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_REF ) { - fxMesa->Glide.grAlphaTestReferenceValue( fxMesa->Color.AlphaRef ); - fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_REF; - } - if ( fxMesa->dirty & TDFX_UPLOAD_BLEND_FUNC ) { - if (fxMesa->Glide.grAlphaBlendFunctionExt) { - fxMesa->Glide.grAlphaBlendFunctionExt( fxMesa->Color.BlendSrcRGB, - fxMesa->Color.BlendDstRGB, - fxMesa->Color.BlendEqRGB, - fxMesa->Color.BlendSrcA, - fxMesa->Color.BlendDstA, - fxMesa->Color.BlendEqA ); - } - else { - fxMesa->Glide.grAlphaBlendFunction( fxMesa->Color.BlendSrcRGB, - fxMesa->Color.BlendDstRGB, - fxMesa->Color.BlendSrcA, - fxMesa->Color.BlendDstA ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_BLEND_FUNC; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_MODE ) { - fxMesa->Glide.grDepthBufferMode( fxMesa->Depth.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_MODE; - } - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_BIAS ) { - fxMesa->Glide.grDepthBiasLevel( fxMesa->Depth.Bias ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_BIAS; - } - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_FUNC ) { - fxMesa->Glide.grDepthBufferFunction( fxMesa->Depth.Func ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_FUNC; - } - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_MASK ) { - fxMesa->Glide.grDepthMask( fxMesa->Depth.Mask ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_MASK; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_DITHER) { - fxMesa->Glide.grDitherMode( fxMesa->Color.Dither ); - } - - if ( fxMesa->dirty & TDFX_UPLOAD_FOG_MODE ) { - fxMesa->Glide.grFogMode( fxMesa->Fog.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_FOG_MODE; - } - if ( fxMesa->dirty & TDFX_UPLOAD_FOG_COLOR ) { - fxMesa->Glide.grFogColorValue( fxMesa->Fog.Color ); - fxMesa->dirty &= ~TDFX_UPLOAD_FOG_COLOR; - } - if ( fxMesa->dirty & TDFX_UPLOAD_FOG_TABLE ) { - fxMesa->Glide.grFogTable( fxMesa->Fog.Table ); - fxMesa->dirty &= ~TDFX_UPLOAD_FOG_TABLE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) { - fxMesa->Glide.grCullMode( fxMesa->CullMode ); - fxMesa->dirty &= ~TDFX_UPLOAD_CULL; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_CLIP ) { - tdfxUploadClipping( fxMesa ); - fxMesa->dirty &= ~TDFX_UPLOAD_CLIP; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK ) { - if ( fxMesa->Glide.grColorMaskExt - && fxMesa->glCtx->Visual.redBits == 8) { - fxMesa->Glide.grColorMaskExt( fxMesa->Color.ColorMask[RCOMP], - fxMesa->Color.ColorMask[GCOMP], - fxMesa->Color.ColorMask[BCOMP], - fxMesa->Color.ColorMask[ACOMP] ); - } else { - fxMesa->Glide.grColorMask( fxMesa->Color.ColorMask[RCOMP] || - fxMesa->Color.ColorMask[GCOMP] || - fxMesa->Color.ColorMask[BCOMP], - /*fxMesa->Color.ColorMask[0][ACOMP]*/GL_FALSE/*[dBorca] no-no*/ ); - } - 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_LINE ) { - if (fxMesa->glCtx->Line.SmoothFlag && fxMesa->glCtx->Line.Width == 1.0) - fxMesa->Glide.grEnable(GR_AA_ORDERED); - else - fxMesa->Glide.grDisable(GR_AA_ORDERED); - fxMesa->dirty &= ~TDFX_UPLOAD_LINE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_STENCIL ) { - if (fxMesa->glCtx->Stencil._Enabled) { - fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT); - fxMesa->Glide.grStencilOp(fxMesa->Stencil.FailFunc, - fxMesa->Stencil.ZFailFunc, - fxMesa->Stencil.ZPassFunc); - fxMesa->Glide.grStencilFunc(fxMesa->Stencil.Function, - fxMesa->Stencil.RefValue, - fxMesa->Stencil.ValueMask); - fxMesa->Glide.grStencilMask(fxMesa->Stencil.WriteMask); - } - else { - fxMesa->Glide.grDisable(GR_STENCIL_MODE_EXT); - } - fxMesa->dirty &= ~TDFX_UPLOAD_STENCIL; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_VERTEX_LAYOUT ) { - fxMesa->Glide.grGlideSetVertexLayout( fxMesa->layout[fxMesa->vertexFormat] ); - /* [dborca] enable fogcoord */ - fxMesa->Glide.grVertexLayout(GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, - fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); - fxMesa->dirty &= ~TDFX_UPLOAD_VERTEX_LAYOUT; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_ENV ) { - uploadTextureEnv(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_ENV; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_PARAMS ) { - uploadTextureParams(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_PARAMS; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_PALETTE ) { - if (fxMesa->TexPalette.Data) { - fxMesa->Glide.grTexDownloadTable(fxMesa->TexPalette.Type, fxMesa->TexPalette.Data); - } - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_PALETTE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_SOURCE ) { - uploadTextureSource(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_SOURCE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_IMAGES ) { - uploadTextureImages(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_IMAGES; - } - - fxMesa->dirty = 0; -} - - - -void tdfxInitRenderFuncs( struct dd_function_table *functions ) -{ - functions->Clear = tdfxClear; - functions->Finish = tdfxFinish; - functions->Flush = tdfxFlush; -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.h b/src/mesa/drivers/dri/tdfx/tdfx_render.h deleted file mode 100644 index 18c61683335..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_render.h +++ /dev/null @@ -1,49 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __TDFX_RENDER_H__ -#define __TDFX_RENDER_H__ - -#include "tdfx_context.h" - -extern void tdfxInitRenderFuncs( struct dd_function_table *functions ); - -extern void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa ); - -extern void tdfxUploadClipping( tdfxContextPtr fxMesa ); - -#define FLUSH_BATCH( fxMesa ) - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c deleted file mode 100644 index 084560ff87d..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ /dev/null @@ -1,450 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#include "tdfx_dri.h" -#include "tdfx_context.h" -#include "tdfx_lock.h" -#include "tdfx_span.h" - -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "xmlpool.h" - -#include "utils.h" - -#ifdef DEBUG_LOCKING -char *prevLockFile = 0; -int prevLockLine = 0; -#endif - -#ifndef TDFX_DEBUG -int TDFX_DEBUG = 0; -#endif - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) - DRI_CONF_SECTION_END -DRI_CONF_END; - -static const __DRIextension *tdfxExtensions[] = { - &driReadDrawableExtension, - NULL -}; - -static const GLuint __driNConfigOptions = 1; - -static GLboolean -tdfxCreateScreen( __DRIscreen *sPriv ) -{ - tdfxScreenPrivate *fxScreen; - TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv; - - if (sPriv->devPrivSize != sizeof(TDFXDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(TDFXDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - fxScreen = (tdfxScreenPrivate *) CALLOC( sizeof(tdfxScreenPrivate) ); - if ( !fxScreen ) - return GL_FALSE; - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&fxScreen->optionCache, - __driConfigOptions, __driNConfigOptions); - - fxScreen->driScrnPriv = sPriv; - sPriv->private = (void *) fxScreen; - - fxScreen->regs.handle = fxDRIPriv->regs; - fxScreen->regs.size = fxDRIPriv->regsSize; - fxScreen->deviceID = fxDRIPriv->deviceID; - fxScreen->width = fxDRIPriv->width; - fxScreen->height = fxDRIPriv->height; - fxScreen->mem = fxDRIPriv->mem; - fxScreen->cpp = fxDRIPriv->cpp; - fxScreen->stride = fxDRIPriv->stride; - fxScreen->fifoOffset = fxDRIPriv->fifoOffset; - fxScreen->fifoSize = fxDRIPriv->fifoSize; - fxScreen->fbOffset = fxDRIPriv->fbOffset; - fxScreen->backOffset = fxDRIPriv->backOffset; - fxScreen->depthOffset = fxDRIPriv->depthOffset; - fxScreen->textureOffset = fxDRIPriv->textureOffset; - fxScreen->textureSize = fxDRIPriv->textureSize; - fxScreen->sarea_priv_offset = fxDRIPriv->sarea_priv_offset; - - if ( drmMap( sPriv->fd, fxScreen->regs.handle, - fxScreen->regs.size, &fxScreen->regs.map ) ) { - return GL_FALSE; - } - - sPriv->extensions = tdfxExtensions; - - return GL_TRUE; -} - - -static void -tdfxDestroyScreen( __DRIscreen *sPriv ) -{ - tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private; - - if (!fxScreen) - return; - - drmUnmap( fxScreen->regs.map, fxScreen->regs.size ); - - /* free all option information */ - driDestroyOptionInfo (&fxScreen->optionCache); - - FREE( fxScreen ); - sPriv->private = NULL; -} - - -static GLboolean -tdfxInitDriver( __DRIscreen *sPriv ) -{ - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)sPriv ); - } - - if ( !tdfxCreateScreen( sPriv ) ) { - tdfxDestroyScreen( sPriv ); - return GL_FALSE; - } - - return GL_TRUE; -} - - -static GLboolean -tdfxCreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap ) -{ - tdfxScreenPrivate *screen = (tdfxScreenPrivate *) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp, - screen->fbOffset, screen->width, driDrawPriv); - tdfxSetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp, - screen->backOffset, screen->width, - driDrawPriv); - tdfxSetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - backRb->backBuffer = GL_TRUE; - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, screen->cpp, - screen->depthOffset, screen->width, - driDrawPriv); - tdfxSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, screen->cpp, - screen->depthOffset, screen->width, - driDrawPriv); - tdfxSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(MESA_FORMAT_S8, NULL, screen->cpp, - screen->depthOffset, screen->width, - driDrawPriv); - tdfxSetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - GL_FALSE, /*swStencil,*/ - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -tdfxDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - - -static void -tdfxSwapBuffers( __DRIdrawable *driDrawPriv ) - -{ - GET_CURRENT_CONTEXT(ctx); - tdfxContextPtr fxMesa = 0; - struct gl_framebuffer *mesaBuffer; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driDrawPriv ); - } - - mesaBuffer = (struct gl_framebuffer *) 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 ) { - __DRIdrawable *curDrawPriv; - fxMesa = TDFX_CONTEXT(ctx); - curDrawPriv = fxMesa->driContext->driDrawablePriv; - - if ( curDrawPriv == driDrawPriv ) { - /* swapping window bound to current context, flush first */ - _mesa_notifySwapBuffers( 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 ); -#ifdef DEBUG - printf("SwapBuf SetState 1\n"); -#endif - 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 - - assert(fxMesa); - - 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 ); -#ifdef DEBUG - printf("SwapBuf SetState 2\n"); -#endif - fxMesa->Glide.grGlideSetState(fxMesa->Glide.State ); - } - UNLOCK_HARDWARE( fxMesa ); - } -} - -static const __DRIconfig ** -tdfxFillInModes(__DRIscreen *psp, - unsigned pixel_bits, - unsigned depth_bits, - unsigned stencil_bits, - GLboolean have_back_buffer) -{ - unsigned deep = (depth_bits > 17); - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - - static const GLenum db_modes[2] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML }; - uint8_t depth_bits_array[4]; - uint8_t stencil_bits_array[4]; - uint8_t msaa_samples_array[1]; - if(deep) { - depth_bits_array[0] = 0; - depth_bits_array[1] = 24; - stencil_bits_array[0] = 0; - stencil_bits_array[1] = 8; - } else { - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = 0; - depth_bits_array[2] = depth_bits; - depth_bits_array[3] = 0; - stencil_bits_array[0] = 0; - stencil_bits_array[1] = 0; - stencil_bits_array[2] = 8; - stencil_bits_array[3] = 8; - } - - msaa_samples_array[0] = 0; - - return (const __DRIconfig **) - driCreateConfigs(deep ? GL_RGBA : GL_RGB, - deep ? GL_UNSIGNED_INT_8_8_8_8 : - GL_UNSIGNED_SHORT_5_6_5, - depth_bits_array, - stencil_bits_array, - deep ? 2 : 4, - db_modes, 2, - msaa_samples_array, 1, - GL_TRUE); -} - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -tdfxInitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { 1, 1, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 0, 0 }; - - /* divined from tdfx_dri.c, sketchy */ - TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv; - - /* XXX i wish it was like this */ - /* bpp = dri_priv->bpp */ - int bpp = (dri_priv->cpp > 2) ? 24 : 16; - - if ( ! driCheckDriDdxDrmVersions2( "tdfx", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) - return NULL; - - if (!tdfxInitDriver(psp)) - return NULL; - - return tdfxFillInModes(psp, - bpp, (bpp == 16) ? 16 : 24, - (bpp == 16) ? 0 : 8, - (dri_priv->backOffset!=dri_priv->depthOffset)); -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = tdfxInitScreen, - .DestroyScreen = tdfxDestroyScreen, - .CreateContext = tdfxCreateContext, - .DestroyContext = tdfxDestroyContext, - .CreateBuffer = tdfxCreateBuffer, - .DestroyBuffer = tdfxDestroyBuffer, - .SwapBuffers = tdfxSwapBuffers, - .MakeCurrent = tdfxMakeCurrent, - .UnbindContext = tdfxUnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = NULL, - .WaitForMSC = NULL, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.h b/src/mesa/drivers/dri/tdfx/tdfx_screen.h deleted file mode 100644 index 6aa42e86674..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.h +++ /dev/null @@ -1,72 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * - */ - -#ifndef __TDFX_SCREEN_H__ -#define __TDFX_SCREEN_H__ - -typedef struct { - drm_handle_t handle; - drmSize size; - drmAddress map; -} tdfxRegion, *tdfxRegionPtr; - -typedef struct { - tdfxRegion regs; - - int deviceID; - int width; - int height; - int mem; - int cpp; - int stride; - - int fifoOffset; - int fifoSize; - - int fbOffset; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; - - __DRIscreen *driScrnPriv; - unsigned int sarea_priv_offset; - - /* Configuration cache with default values for all contexts */ - driOptionCache optionCache; -} tdfxScreenPrivate; - - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_span.c b/src/mesa/drivers/dri/tdfx/tdfx_span.c deleted file mode 100644 index 12524e2316a..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_span.c +++ /dev/null @@ -1,1386 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * Keith Whitwell <[email protected]> - * - */ - -#include "tdfx_context.h" -#include "tdfx_lock.h" -#include "tdfx_span.h" -#include "tdfx_render.h" -#include "swrast/swrast.h" - - -#define DBG 0 - - -#define LOCAL_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - __DRIdrawable *const dPriv = drb->dPriv; \ - GLuint pitch = drb->backBuffer ? info.strideInBytes \ - : (drb->pitch * drb->cpp); \ - const GLuint bottom = dPriv->h - 1; \ - char *buf = (char *)((char *)info.lfbPtr + \ - (dPriv->x * drb->cpp) + \ - (dPriv->y * pitch)); \ - GLuint p; \ - (void) buf; (void) p; - - -#define Y_FLIP(_y) (bottom - _y) - - -#define HW_WRITE_LOCK() \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - FLUSH_BATCH( fxMesa ); \ - 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)) { - -#define HW_WRITE_UNLOCK() \ - fxMesa->Glide.grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer );\ - } - - -#define HW_READ_LOCK() \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - FLUSH_BATCH( fxMesa ); \ - UNLOCK_HARDWARE( fxMesa ); \ - 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 ) ) \ - { - -#define HW_READ_UNLOCK() \ - fxMesa->Glide.grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer );\ - } - - -#define HW_WRITE_CLIPLOOP() \ - do { \ - int _nc = fxMesa->numClipRects; \ - while (_nc--) { \ - int minx = fxMesa->pClipRects[_nc].x1 - fxMesa->x_offset; \ - int miny = fxMesa->pClipRects[_nc].y1 - fxMesa->y_offset; \ - int maxx = fxMesa->pClipRects[_nc].x2 - fxMesa->x_offset; \ - int maxy = fxMesa->pClipRects[_nc].y2 - fxMesa->y_offset; - -#define HW_READ_CLIPLOOP() \ - do { \ - const __DRIdrawable *dPriv = fxMesa->driDrawable; \ - drm_clip_rect_t *rect = dPriv->pClipRects; \ - int _nc = dPriv->numClipRects; \ - while (_nc--) { \ - const int minx = rect->x1 - fxMesa->x_offset; \ - const int miny = rect->y1 - fxMesa->y_offset; \ - const int maxx = rect->x2 - fxMesa->x_offset; \ - const int maxy = rect->y2 - fxMesa->y_offset; \ - rect++; - -#define HW_ENDCLIPLOOP() \ - } \ - } while (0) - - - -#define LFB_MODE GR_LFBWRITEMODE_565 - - -/* 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) | \ - (((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 *)(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] = 0xff; \ - } while (0) - -#define TAG(x) tdfx##x##_RGB565 -#define BYTESPERPIXEL 2 -#include "spantmp.h" -#undef BYTESPERPIXEL - - -/* 16 bit, BGR565 color spanline and pixel functions */ \ -#if 0 - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)b & 0xf8) << 8) | \ - (((int)g & 0xfc) << 3) | \ - (((int)r & 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 *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (p << 3) & 0xf8; \ - rgba[1] = (p >> 3) & 0xfc; \ - rgba[2] = (p >> 8) & 0xf8; \ - rgba[3] = 0xff; \ - } while (0) - -#define TAG(x) tdfx##x##_BGR565 -#define BYTESPERPIXEL 2 -#include "spantmp.h" -#undef BYTESPERPIXEL -#endif - - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_888 - - -/* 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) | \ - (r << 16)) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*3 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLuint p = *(GLuint *)(buf + _x*3 + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = 0xff; \ -} while (0) - -#define TAG(x) tdfx##x##_RGB888 -#define BYTESPERPIXEL 4 -#include "spantmp.h" -#undef BYTESPERPIXEL - - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_8888 - - -/* 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) | \ - (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 *)(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) tdfx##x##_ARGB8888 -#define BYTESPERPIXEL 4 -#include "spantmp.h" -#undef BYTESPERPIXEL - - - -/* ================================================================ - * Old span functions below... - */ - - -/* - * Examine the cliprects to generate an array of flags to indicate - * which pixels in a span are visible. Note: (x,y) is a screen - * coordinate. - */ -static void -generate_vismask(const tdfxContextPtr fxMesa, GLint x, GLint y, GLint n, - GLubyte vismask[]) -{ - GLboolean initialized = GL_FALSE; - GLint i, j; - - /* Ensure we clear the visual mask */ - memset(vismask, 0, n); - - /* turn on flags for all visible pixels */ - for (i = 0; i < fxMesa->numClipRects; i++) { - const drm_clip_rect_t *rect = &fxMesa->pClipRects[i]; - - if (y >= rect->y1 && y < rect->y2) { - if (x >= rect->x1 && x + n <= rect->x2) { - /* common case, whole span inside cliprect */ - memset(vismask, 1, n); - return; - } - if (x < rect->x2 && x + n >= rect->x1) { - /* some of the span is inside the rect */ - GLint start, end; - if (!initialized) { - memset(vismask, 0, n); - initialized = GL_TRUE; - } - if (x < rect->x1) - start = rect->x1 - x; - else - start = 0; - if (x + n > rect->x2) - end = rect->x2 - x; - else - end = n; - assert(start >= 0); - assert(end <= n); - for (j = start; j < end; j++) - vismask[j] = 1; - } - } - } -} - -/* - * Examine cliprects and determine if the given screen pixel is visible. - */ -static GLboolean -visible_pixel(const tdfxContextPtr fxMesa, int scrX, int scrY) -{ - int i; - for (i = 0; i < fxMesa->numClipRects; i++) { - const drm_clip_rect_t *rect = &fxMesa->pClipRects[i]; - if (scrX >= rect->x1 && - scrX < rect->x2 && - scrY >= rect->y1 && scrY < rect->y2) return GL_TRUE; - } - return GL_FALSE; -} - - - -/* - * Depth buffer read/write functions. - */ -/* - * To read the frame buffer, we need to lock and unlock it. The - * four macros {READ,WRITE}_FB_SPAN_{LOCK,UNLOCK} - * do this for us. - * - * Note that the lock must be matched with an unlock. These - * macros include a spare curly brace, so they must - * be syntactically matched. - * - * Note, also, that you can't lock a buffer twice with different - * modes. That is to say, you can't lock a buffer in both read - * and write modes. The strideInBytes and LFB pointer will be - * the same with read and write locks, so you can use either. - * o The HW has different state for reads and writes, so - * locking it twice may give screwy results. - * o The DRM won't let you lock twice. It hangs. This is probably - * because of the LOCK_HARDWARE IN THE *_FB_SPAN_LOCK macros, - * and could be eliminated with nonlocking lock routines. But - * what's the point after all. - */ -#define READ_FB_SPAN_LOCK(fxMesa, info, target_buffer) \ - UNLOCK_HARDWARE(fxMesa); \ - LOCK_HARDWARE(fxMesa); \ - (info).size=sizeof(info); \ - if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY, \ - target_buffer, \ - GR_LFBWRITEMODE_ANY, \ - GR_ORIGIN_UPPER_LEFT, \ - FXFALSE, \ - &(info))) { - -#define READ_FB_SPAN_UNLOCK(fxMesa, target_buffer) \ - fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, target_buffer); \ - } else { \ - fprintf(stderr, "tdfxDriver: Can't get %s (%d) read lock\n", \ - (target_buffer == GR_BUFFER_BACKBUFFER) \ - ? "back buffer" \ - : ((target_buffer == GR_BUFFER_AUXBUFFER) \ - ? "depth buffer" \ - : "unknown buffer"), \ - target_buffer); \ - } - -#define WRITE_FB_SPAN_LOCK(fxMesa, info, target_buffer, write_mode) \ - UNLOCK_HARDWARE(fxMesa); \ - LOCK_HARDWARE(fxMesa); \ - info.size=sizeof(info); \ - if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY, \ - target_buffer, \ - write_mode, \ - GR_ORIGIN_UPPER_LEFT, \ - FXFALSE, \ - &info)) { - -#define WRITE_FB_SPAN_UNLOCK(fxMesa, target_buffer) \ - fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, target_buffer); \ - } else { \ - fprintf(stderr, "tdfxDriver: Can't get %s (%d) write lock\n", \ - (target_buffer == GR_BUFFER_BACKBUFFER) \ - ? "back buffer" \ - : ((target_buffer == GR_BUFFER_AUXBUFFER) \ - ? "depth buffer" \ - : "unknown buffer"), \ - target_buffer); \ - } - -/* - * Because the Linear Frame Buffer is not necessarily aligned - * with the depth buffer, we have to do some fiddling - * around to get the right addresses. - * - * Perhaps a picture is in order. The Linear Frame Buffer - * looks like this: - * - * |<----------------------info.strideInBytes------------->| - * |<-----physicalStrideInBytes------->| - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * | | | - * | Legal Memory | Forbidden Zone | - * | | | - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * - * You can only reliably read and write legal locations. Reads - * and writes from the Forbidden Zone will return undefined values, - * and may cause segmentation faults. - * - * Now, the depth buffer may not end up in a location such each - * scan line is an LFB line. For example, the depth buffer may - * look like this: - * - * wrapped ordinary. - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * |0000000000000000000000 | | back - * |1111111111111111111111 | | buffer - * |2222222222222222222222 | | - * |4096b align. padxx00000000000000000| Forbidden Zone | depth - * |0000 11111111111111111| | buffer - * |1111 22222222222222222| | - * |2222 | | - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * where each number is the scan line number. We know it will - * be aligned on 128 byte boundaries, at least. Aligning this - * on a scanline boundary causes the back and depth buffers to - * thrash in the SST1 cache. (Note that the back buffer is always - * allocated at the beginning of LFB memory, and so it is always - * properly aligned with the LFB stride.) - * - * We call the beginning of the line (which is the rightmost - * part of the depth line in the picture above) the *ordinary* part - * of the scanline, and the end of the line (which is the - * leftmost part, one line below) the *wrapped* part of the scanline. - * a.) We need to know what x value to subtract from the screen - * x coordinate to index into the wrapped part. - * b.) We also need to figure out if we need to read from the ordinary - * part scan line, or from the wrapped part of the scan line. - * - * [ad a] - * The first wrapped x coordinate is that coordinate such that - * depthBufferOffset&(info.strideInBytes) + x*elmentSize {*} - * > physicalStrideInBytes - * where depthBufferOffset is the LFB distance in bytes - * from the back buffer to the depth buffer. The expression - * depthBufferOffset&(info.strideInBytes) - * is then the offset (in bytes) from the beginining of (any) - * depth buffer line to first element in the line. - * Simplifying inequation {*} above we see that x is the smallest - * value such that - * x*elementSize > physicalStrideInBytes {**} - * - depthBufferOffset&(info.strideInBytes) - * Now, we know that both the summands on the right are multiples of - * 128, and elementSize <= 4, so if equality holds in {**}, x would - * be a multiple of 32. Thus we can set x to - * xwrapped = (physicalStrideInBytes - * - depthBufferOffset&(info.strideInBytes))/elementSize - * + 1 - * - * [ad b] - * Question b is now simple. We read from the wrapped scan line if - * x is greater than xwrapped. - */ -#define TILE_WIDTH_IN_BYTES 128 -#define TILE_WIDTH_IN_ZOXELS(bpz) (TILE_WIDTH_IN_BYTES/(bpz)) -#define TILE_HEIGHT_IN_LINES 32 -typedef struct -{ - void *lfbPtr; - void *lfbWrapPtr; - FxU32 LFBStrideInElts; - GLint firstWrappedX; -} -LFBParameters; - -/* - * We need information about the back buffer. Note that - * this function *cannot be called* while the aux buffer - * is locked, or the caller will hang. - * - * Only Glide knows the LFB address of the back and depth - * offsets. The upper levels of Mesa know the depth offset, - * but that is not in LFB space, it is tiled memory space, - * and is not useable for us. - */ -static void -GetBackBufferInfo(tdfxContextPtr fxMesa, GrLfbInfo_t * backBufferInfo) -{ - READ_FB_SPAN_LOCK(fxMesa, *backBufferInfo, GR_BUFFER_BACKBUFFER); - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_BACKBUFFER); -} - -static void -GetFbParams(tdfxContextPtr fxMesa, - GrLfbInfo_t * info, - GrLfbInfo_t * backBufferInfo, - LFBParameters * ReadParamsp, FxU32 elementSize) -{ - FxU32 physicalStrideInBytes, bufferOffset; - FxU32 strideInBytes = info->strideInBytes; - char *lfbPtr = (char *) (info->lfbPtr); /* For arithmetic, use char * */ - - /* - * These two come directly from the info structure. - */ - ReadParamsp->lfbPtr = (void *) lfbPtr; - ReadParamsp->LFBStrideInElts = strideInBytes / elementSize; - /* - * Now, calculate the value of firstWrappedX. - * - * The physical stride is the screen width in bytes rounded up to - * the next highest multiple of 128 bytes. Note that this fails - * when TILE_WIDTH_IN_BYTES is not a power of two. - * - * The buffer Offset is the distance between the beginning of - * the LFB space, which is the beginning of the back buffer, - * and the buffer we are gathering information about. - * We want to make this routine usable for operations on the - * back buffer, though we don't actually use it on the back - * buffer. Note, then, that if bufferOffset == 0, the firstWrappedX - * is in the forbidden zone, and is therefore never reached. - * - * Note that if - * physicalStrideInBytes - * < bufferOffset&(info->strideInBytes-1) - * the buffer begins in the forbidden zone. We assert for this. - */ - bufferOffset = (FxU32)(lfbPtr - (char *) backBufferInfo->lfbPtr); - physicalStrideInBytes - = (fxMesa->screen_width * elementSize + TILE_WIDTH_IN_BYTES - 1) - & ~(TILE_WIDTH_IN_BYTES - 1); - assert(physicalStrideInBytes > (bufferOffset & (strideInBytes - 1))); - ReadParamsp->firstWrappedX - = (physicalStrideInBytes - - (bufferOffset & (strideInBytes - 1))) / elementSize; - /* - * This is the address of the next physical line. - */ - ReadParamsp->lfbWrapPtr - = (void *) ((char *) backBufferInfo->lfbPtr - + (bufferOffset & ~(strideInBytes - 1)) - + (TILE_HEIGHT_IN_LINES) * strideInBytes); -} - -/* - * These macros fetch data from the frame buffer. The type is - * the type of data we want to fetch. It should match the type - * whose size was used with GetFbParams to fill in the structure - * in *ReadParamsp. We have a macro to read the ordinary - * part, a second macro to read the wrapped part, and one which - * will do either. When we are reading a span, we will know - * when the ordinary part ends, so there's no need to test for - * it. However, when reading and writing pixels, we don't - * necessarily know. I suppose it's a matter of taste whether - * it's better in the macro or in the call. - * - * Recall that x and y are screen coordinates. - */ -#define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \ - (((type *)((ReadParamsp)->lfbPtr)) \ - [(y) * ((ReadParamsp)->LFBStrideInElts) \ - + (x)]) -#define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \ - (((type *)((ReadParamsp)->lfbWrapPtr)) \ - [((y)) * ((ReadParamsp)->LFBStrideInElts) \ - + ((x) - (ReadParamsp)->firstWrappedX)]) -#define GET_FB_DATA(ReadParamsp, type, x, y) \ - (((x) < (ReadParamsp)->firstWrappedX) \ - ? GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \ - : GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y)) -#define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \ - (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) -#define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \ - (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) -#define PUT_FB_DATA(ReadParamsp, type, x, y, value) \ - do { \ - if ((x) < (ReadParamsp)->firstWrappedX) \ - PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value); \ - else \ - PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value); \ - } while (0) - - -static void -tdfxDDWriteDepthSpan(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, const void *values, - const GLubyte mask[]) -{ - const GLuint *depth = (const GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->y_offset + fxMesa->height - 1; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits; - GrLfbInfo_t info; - GLubyte visMask[MAX_WIDTH]; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDWriteDepthSpan(...)\n"); - } - - assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32)); - /* - * Convert x and y to screen coordinates. - */ - x += fxMesa->x_offset; - y = bottom - y; - if (mask) { - GLint i; - GLushort d16; - GrLfbInfo_t backBufferInfo; - - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, - GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - int wrappedPartStart; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - if (mask[i] && visMask[i]) { - d16 = depth[i]; - PUT_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y, d16); - } - } - for (; i < n; i++) { - if (mask[i] && visMask[i]) { - d16 = depth[i]; - PUT_WRAPPED_FB_DATA(&ReadParams, GLushort, x + i, y, d16); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, - GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - int wrappedPartStart; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - GLuint d32; - if (mask[i] && visMask[i]) { - if (stencil_size > 0) { - d32 = - GET_ORDINARY_FB_DATA(&ReadParams, GLuint, - x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - for (; i < n; i++) { - GLuint d32; - if (mask[i] && visMask[i]) { - if (stencil_size > 0) { - d32 = - GET_WRAPPED_FB_DATA(&ReadParams, GLuint, - x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - } - else { - GLint i; - GLuint d32; - GLushort d16; - GrLfbInfo_t backBufferInfo; - - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - GLuint wrappedPartStart; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - if (visMask[i]) { - d16 = depth[i]; - PUT_ORDINARY_FB_DATA(&ReadParams, - GLushort, - x + i, y, - d16); - } - } - for (; i < n; i++) { - if (visMask[i]) { - d16 = depth[i]; - PUT_WRAPPED_FB_DATA(&ReadParams, - GLushort, - x + i, y, - d16); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - GLuint wrappedPartStart; - - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - if (visMask[i]) { - if (stencil_size > 0) { - d32 = GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - for (; i < n; i++) { - if (visMask[i]) { - if (stencil_size > 0) { - d32 = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - } -} - -static void -tdfxDDWriteMonoDepthSpan(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, const void *value, - const GLubyte mask[]) -{ - GLuint depthVal = *((GLuint *) value); - GLuint depths[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) - depths[i] = depthVal; - tdfxDDWriteDepthSpan(ctx, rb, n, x, y, depths, mask); -} - - -static void -tdfxDDReadDepthSpan(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, void *values) -{ - GLuint *depth = (GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->height + fxMesa->y_offset - 1; - GLuint i; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GrLfbInfo_t info; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDReadDepthSpan(...)\n"); - } - - /* - * Convert to screen coordinates. - */ - x += fxMesa->x_offset; - y = bottom - y; - switch (depth_size) { - case 16: - { - LFBParameters ReadParams; - GrLfbInfo_t backBufferInfo; - int wrappedPartStart; - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - /* - * Read the line. - */ - for (i = 0; i < wrappedPartStart; i++) { - depth[i] = - GET_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y); - } - for (; i < n; i++) { - depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLushort, - x + i, y); - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - case 24: - case 32: - { - LFBParameters ReadParams; - GrLfbInfo_t backBufferInfo; - int wrappedPartStart; - GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits; - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - /* - * Read the line. - */ - for (i = 0; i < wrappedPartStart; i++) { - const GLuint mask = - (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF; - depth[i] = - GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y); - depth[i] &= mask; - } - for (; i < n; i++) { - const GLuint mask = - (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF; - depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y); - depth[i] &= mask; - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - } -} - - -static void -tdfxDDWriteDepthPixels(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[]) -{ - const GLuint *depth = (const GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->height + fxMesa->y_offset - 1; - GLuint i; - GLushort d16; - GLuint d32; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits; - GrLfbInfo_t info; - int xpos; - int ypos; - GrLfbInfo_t backBufferInfo; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDWriteDepthPixels(...)\n"); - } - - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - for (i = 0; i < n; i++) { - if ((!mask || mask[i]) && visible_pixel(fxMesa, x[i], y[i])) { - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - d16 = depth[i]; - PUT_FB_DATA(&ReadParams, GLushort, xpos, ypos, d16); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - for (i = 0; i < n; i++) { - if (!mask || mask[i]) { - if (visible_pixel(fxMesa, x[i], y[i])) { - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - if (stencil_size > 0) { - d32 = - GET_FB_DATA(&ReadParams, GLuint, xpos, ypos); - d32 = (d32 & 0xFF000000) | (depth[i] & 0xFFFFFF); - } - else { - d32 = depth[i]; - } - PUT_FB_DATA(&ReadParams, GLuint, xpos, ypos, d32); - } - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } -} - - -static void -tdfxDDReadDepthPixels(struct gl_context * ctx, struct gl_renderbuffer *rb, GLuint n, - const GLint x[], const GLint y[], void *values) -{ - GLuint *depth = (GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->height + fxMesa->y_offset - 1; - GLuint i; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GLushort d16; - int xpos; - int ypos; - GrLfbInfo_t info; - GLuint stencil_size; - GrLfbInfo_t backBufferInfo; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDReadDepthPixels(...)\n"); - } - - assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32)); - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - for (i = 0; i < n; i++) { - /* - * Convert to screen coordinates. - */ - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - d16 = GET_FB_DATA(&ReadParams, GLushort, xpos, ypos); - depth[i] = d16; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - stencil_size = fxMesa->glCtx->Visual.stencilBits; - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - for (i = 0; i < n; i++) { - GLuint d32; - - /* - * Convert to screen coordinates. - */ - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - d32 = GET_FB_DATA(&ReadParams, GLuint, xpos, ypos); - if (stencil_size > 0) { - d32 &= 0x00FFFFFF; - } - depth[i] = d32; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - default: - assert(0); - } -} - -/* - * Stencil buffer read/write functions. - */ -#define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF) -#define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff) -#define BUILD_ZS(z, s) (((s) << 24) | (z)) - -static void -write_stencil_span(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, const GLubyte mask[]) -{ - const GLubyte *stencil = (const GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - const GLint scrX = winX + x; - const GLint scrY = winY - y; - LFBParameters ReadParams; - GLubyte visMask[MAX_WIDTH]; - GLuint i; - int wrappedPartStart; - - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - generate_vismask(fxMesa, scrX, scrY, n, visMask); - for (i = 0; i < wrappedPartStart; i++) { - if (visMask[i] && (!mask || mask[i])) { - GLuint z = GET_ORDINARY_FB_DATA(&ReadParams, GLuint, - scrX + i, scrY) & 0x00FFFFFF; - z |= (stencil[i] & 0xFF) << 24; - PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z); - } - } - for (; i < n; i++) { - if (visMask[i] && (!mask || mask[i])) { - GLuint z = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, - scrX + i, scrY) & 0x00FFFFFF; - z |= (stencil[i] & 0xFF) << 24; - PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - - -static void -write_mono_stencil_span(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *value, const GLubyte mask[]) -{ - GLbyte stencilVal = *((GLbyte *) value); - GLbyte stencils[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) - stencils[i] = stencilVal; - write_stencil_span(ctx, rb, n, x, y, stencils, mask); -} - - -static void -read_stencil_span(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values) -{ - GLubyte *stencil = (GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - GLuint i; - LFBParameters ReadParams; - int wrappedPartStart; - - /* - * Convert to screen coordinates. - */ - x += winX; - y = winY - y; - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - stencil[i] = (GET_ORDINARY_FB_DATA(&ReadParams, GLuint, - x + i, y) >> 24) & 0xFF; - } - for (; i < n; i++) { - stencil[i] = (GET_WRAPPED_FB_DATA(&ReadParams, GLuint, - x + i, y) >> 24) & 0xFF; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - - -static void -write_stencil_pixels(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[]) -{ - const GLubyte *stencil = (const GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - LFBParameters ReadParams; - GLuint i; - - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - for (i = 0; i < n; i++) { - const GLint scrX = winX + x[i]; - const GLint scrY = winY - y[i]; - if ((!mask || mask[i]) && visible_pixel(fxMesa, scrX, scrY)) { - GLuint z = - GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) & 0x00FFFFFF; - z |= (stencil[i] & 0xFF) << 24; - PUT_FB_DATA(&ReadParams, GLuint, scrX, scrY, z); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - - -static void -read_stencil_pixels(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - void *values) -{ - GLubyte *stencil = (GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - GLuint i; - LFBParameters ReadParams; - - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - for (i = 0; i < n; i++) { - const GLint scrX = winX + x[i]; - const GLint scrY = winY - y[i]; - stencil[i] = - (GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) >> 24) & 0xFF; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - -#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \ - ((vis.redBits == r) && \ - (vis.greenBits == g) && \ - (vis.blueBits == b) && \ - (vis.alphaBits == a)) - - - - -/**********************************************************************/ -/* Locking for swrast */ -/**********************************************************************/ - - -static void tdfxSpanRenderStart( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - LOCK_HARDWARE(fxMesa); -} - -static void tdfxSpanRenderFinish( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - _swrast_flush( ctx ); - UNLOCK_HARDWARE(fxMesa); -} - -/**********************************************************************/ -/* Initialize swrast device driver */ -/**********************************************************************/ - -void tdfxDDInitSpanFuncs( struct gl_context *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx ); - swdd->SpanRenderStart = tdfxSpanRenderStart; - swdd->SpanRenderFinish = tdfxSpanRenderFinish; -} - - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -tdfxSetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis) -{ - if (drb->Base.InternalFormat == GL_RGBA) { - if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { - tdfxInitPointers_RGB565(&drb->Base); - } - else if (vis->redBits == 8 && vis->greenBits == 8 - && vis->blueBits == 8 && vis->alphaBits == 0) { - tdfxInitPointers_RGB888(&drb->Base); - } - else if (vis->redBits == 8 && vis->greenBits == 8 - && vis->blueBits == 8 && vis->alphaBits == 8) { - tdfxInitPointers_ARGB8888(&drb->Base); - } - else { - _mesa_problem(NULL, "problem in tdfxSetSpanFunctions"); - } - } - else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16 || - drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { - drb->Base.GetRow = tdfxDDReadDepthSpan; - drb->Base.GetValues = tdfxDDReadDepthPixels; - drb->Base.PutRow = tdfxDDWriteDepthSpan; - drb->Base.PutMonoRow = tdfxDDWriteMonoDepthSpan; - drb->Base.PutValues = tdfxDDWriteDepthPixels; - drb->Base.PutMonoValues = NULL; - } - else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { - drb->Base.GetRow = read_stencil_span; - drb->Base.GetValues = read_stencil_pixels; - drb->Base.PutRow = write_stencil_span; - drb->Base.PutMonoRow = write_mono_stencil_span; - drb->Base.PutValues = write_stencil_pixels; - drb->Base.PutMonoValues = NULL; - } -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_span.h b/src/mesa/drivers/dri/tdfx/tdfx_span.h deleted file mode 100644 index ae3d074a582..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_span.h +++ /dev/null @@ -1,48 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#ifndef __TDFX_SPAN_H__ -#define __TDFX_SPAN_H__ - -#include "main/context.h" -#include "drirenderbuffer.h" - -extern void tdfxDDInitSpanFuncs( struct gl_context *ctx ); - -extern void -tdfxSetSpanFunctions(driRenderbuffer *rb, const struct gl_config *vis); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c deleted file mode 100644 index b26b2c710b9..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_state.c +++ /dev/null @@ -1,1429 +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. - */ - -/* - * New fixes: - * Daniel Borca <[email protected]>, 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * Keith Whitwell <[email protected]> (port to 3.5) - * - */ - -#include "main/mtypes.h" -#include "main/colormac.h" - -#include "swrast/swrast.h" -#include "vbo/vbo.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_tex.h" -#include "tdfx_texman.h" -#include "tdfx_texstate.h" -#include "tdfx_render.h" - - - -/* ============================================================= - * Alpha blending - */ - -static void tdfxUpdateAlphaMode( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrCmpFnc_t func; - GrAlphaBlendFnc_t srcRGB, dstRGB, srcA, dstA; - GrAlphaBlendOp_t eqRGB, eqA; - GrAlpha_t ref = (GLint) (ctx->Color.AlphaRef * 255.0); - - GLboolean isNapalm = TDFX_IS_NAPALM(fxMesa); - GLboolean have32bpp = (ctx->Visual.greenBits == 8); - GLboolean haveAlpha = fxMesa->haveHwAlpha; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if ( ctx->Color.AlphaEnabled ) { - func = ctx->Color.AlphaFunc - GL_NEVER + GR_CMP_NEVER; - } else { - func = GR_CMP_ALWAYS; - } - - if ( ctx->Color.BlendEnabled - && (fxMesa->Fallback & TDFX_FALLBACK_BLEND) == 0 ) { - switch ( ctx->Color.Blend[0].SrcRGB ) { - case GL_ZERO: - srcRGB = GR_BLEND_ZERO; - break; - case GL_ONE: - srcRGB = GR_BLEND_ONE; - break; - case GL_DST_COLOR: - srcRGB = GR_BLEND_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - srcRGB = GR_BLEND_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - srcRGB = GR_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - srcRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - srcRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - srcRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_SRC_ALPHA_SATURATE: - srcRGB = GR_BLEND_ALPHA_SATURATE; - break; - case GL_SRC_COLOR: - if (isNapalm) { - srcRGB = GR_BLEND_SAME_COLOR_EXT; - break; - } - case GL_ONE_MINUS_SRC_COLOR: - if (isNapalm) { - srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; - break; - } - default: - srcRGB = GR_BLEND_ONE; - } - - switch ( ctx->Color.Blend[0].SrcA ) { - case GL_ZERO: - srcA = GR_BLEND_ZERO; - break; - case GL_ONE: - srcA = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - srcA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - srcA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_DST_COLOR: - case GL_DST_ALPHA: - srcA = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_COLOR: - case GL_ONE_MINUS_DST_ALPHA: - srcA = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_SRC_ALPHA_SATURATE: - srcA = GR_BLEND_ONE; - break; - default: - srcA = GR_BLEND_ONE; - } - - switch ( ctx->Color.Blend[0].DstRGB ) { - case GL_ZERO: - dstRGB = GR_BLEND_ZERO; - break; - case GL_ONE: - dstRGB = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - dstRGB = GR_BLEND_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - dstRGB = GR_BLEND_ONE_MINUS_SRC_COLOR; - break; - case GL_SRC_ALPHA: - dstRGB = GR_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dstRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - dstRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - dstRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_DST_COLOR: - if (isNapalm) { - dstRGB = GR_BLEND_SAME_COLOR_EXT; - break; - } - case GL_ONE_MINUS_DST_COLOR: - if (isNapalm) { - dstRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; - break; - } - default: - dstRGB = GR_BLEND_ZERO; - } - - switch ( ctx->Color.Blend[0].DstA ) { - case GL_ZERO: - dstA = GR_BLEND_ZERO; - break; - case GL_ONE: - dstA = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - dstA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - dstA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_DST_COLOR: - case GL_DST_ALPHA: - dstA = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_COLOR: - case GL_ONE_MINUS_DST_ALPHA: - dstA = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - default: - dstA = GR_BLEND_ZERO; - } - - switch ( ctx->Color.Blend[0].EquationRGB ) { - case GL_FUNC_SUBTRACT: - eqRGB = GR_BLEND_OP_SUB; - break; - case GL_FUNC_REVERSE_SUBTRACT: - eqRGB = GR_BLEND_OP_REVSUB; - break; - case GL_FUNC_ADD: - default: - eqRGB = GR_BLEND_OP_ADD; - break; - } - - switch ( ctx->Color.Blend[0].EquationA ) { - case GL_FUNC_SUBTRACT: - eqA = GR_BLEND_OP_SUB; - break; - case GL_FUNC_REVERSE_SUBTRACT: - eqA = GR_BLEND_OP_REVSUB; - break; - case GL_FUNC_ADD: - default: - eqA = GR_BLEND_OP_ADD; - break; - } - } else { - /* blend disabled */ - srcRGB = GR_BLEND_ONE; - dstRGB = GR_BLEND_ZERO; - eqRGB = GR_BLEND_OP_ADD; - srcA = GR_BLEND_ONE; - dstA = GR_BLEND_ZERO; - eqA = GR_BLEND_OP_ADD; - } - - if ( fxMesa->Color.AlphaFunc != func ) { - fxMesa->Color.AlphaFunc = func; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_TEST; - } - if ( fxMesa->Color.AlphaRef != ref ) { - fxMesa->Color.AlphaRef = ref; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_REF; - } - - if ( fxMesa->Color.BlendSrcRGB != srcRGB || - fxMesa->Color.BlendDstRGB != dstRGB || - fxMesa->Color.BlendEqRGB != eqRGB || - fxMesa->Color.BlendSrcA != srcA || - fxMesa->Color.BlendDstA != dstA || - fxMesa->Color.BlendEqA != eqA ) - { - fxMesa->Color.BlendSrcRGB = srcRGB; - fxMesa->Color.BlendDstRGB = dstRGB; - fxMesa->Color.BlendEqRGB = eqRGB; - fxMesa->Color.BlendSrcA = srcA; - fxMesa->Color.BlendDstA = dstA; - fxMesa->Color.BlendEqA = eqA; - fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC; - } -} - -static void tdfxDDAlphaFunc( struct gl_context *ctx, GLenum func, GLfloat ref ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; -} - -static void tdfxDDBlendEquationSeparate( struct gl_context *ctx, - GLenum modeRGB, GLenum modeA ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - assert( modeRGB == modeA ); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; -} - -static void tdfxDDBlendFuncSeparate( struct gl_context *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; - - /* - * XXX - Voodoo5 seems to suffer from precision problems in some - * blend modes. To pass all the conformance tests we'd have to - * fall back to software for many modes. Revisit someday. - */ -} - -/* ============================================================= - * Stipple - */ - -void tdfxUpdateStipple( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - GrStippleMode_t mode = GR_STIPPLE_DISABLE; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - FLUSH_BATCH( fxMesa ); - - if (ctx->Polygon.StippleFlag) { - mode = GR_STIPPLE_PATTERN; - } - - if ( fxMesa->Stipple.Mode != mode ) { - fxMesa->Stipple.Mode = mode; - fxMesa->dirty |= TDFX_UPLOAD_STIPPLE; - } -} - - -/* ============================================================= - * Depth testing - */ - -static void tdfxUpdateZMode( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - GrCmpFnc_t func; - FxI32 bias; - FxBool mask; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) - fprintf( stderr, "%s()\n", __FUNCTION__ ); - - - bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE); - - if ( ctx->Depth.Test ) { - func = ctx->Depth.Func - GL_NEVER + GR_CMP_NEVER; - mask = ctx->Depth.Mask; - } - else { - /* depth testing disabled */ - func = GR_CMP_ALWAYS; /* fragments always pass */ - mask = FXFALSE; /* zbuffer is not touched */ - } - - fxMesa->Depth.Clear = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear); - - if ( fxMesa->Depth.Bias != bias ) { - fxMesa->Depth.Bias = bias; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS; - } - if ( fxMesa->Depth.Func != func ) { - fxMesa->Depth.Func = func; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_FUNC | TDFX_UPLOAD_DEPTH_MASK; - } - if ( fxMesa->Depth.Mask != mask ) { - fxMesa->Depth.Mask = mask; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_MASK; - } -} - -static void tdfxDDDepthFunc( struct gl_context *ctx, GLenum func ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; -} - -static void tdfxDDDepthMask( struct gl_context *ctx, GLboolean flag ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; -} - -static void tdfxDDClearDepth( struct gl_context *ctx, GLclampd d ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; -} - - - -/* ============================================================= - * Stencil - */ - - -/* Evaluate all stencil state and make the Glide calls. - */ -static GrStencil_t convertGLStencilOp( GLenum op ) -{ - switch ( op ) { - case GL_KEEP: - return GR_STENCILOP_KEEP; - case GL_ZERO: - return GR_STENCILOP_ZERO; - case GL_REPLACE: - return GR_STENCILOP_REPLACE; - case GL_INCR: - return GR_STENCILOP_INCR_CLAMP; - case GL_DECR: - return GR_STENCILOP_DECR_CLAMP; - case GL_INVERT: - return GR_STENCILOP_INVERT; - case GL_INCR_WRAP_EXT: - return GR_STENCILOP_INCR_WRAP; - case GL_DECR_WRAP_EXT: - return GR_STENCILOP_DECR_WRAP; - default: - _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" ); - } - return GR_STENCILOP_KEEP; /* never get, silence compiler warning */ -} - - -static void tdfxUpdateStencil( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if (fxMesa->haveHwStencil) { - if (ctx->Stencil._Enabled) { - fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER + GR_CMP_NEVER; - fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0] & 0xff; - fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0] & 0xff; - fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0] & 0xff; - fxMesa->Stencil.FailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[0]); - fxMesa->Stencil.ZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[0]); - fxMesa->Stencil.ZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[0]); - fxMesa->Stencil.Clear = ctx->Stencil.Clear & 0xff; - } - fxMesa->dirty |= TDFX_UPLOAD_STENCIL; - } -} - - -static void -tdfxDDStencilFuncSeparate( struct gl_context *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_STENCIL; -} - -static void -tdfxDDStencilMaskSeparate( struct gl_context *ctx, GLenum face, GLuint mask ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_STENCIL; -} - -static void -tdfxDDStencilOpSeparate( struct gl_context *ctx, GLenum face, GLenum sfail, - GLenum zfail, GLenum zpass ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_STENCIL; -} - - -/* ============================================================= - * Fog - orthographic fog still not working - */ - -static void tdfxUpdateFogAttrib( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrFogMode_t mode; - GrColor_t color; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if ( ctx->Fog.Enabled ) { - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) { - mode = GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT; - } else { - mode = GR_FOG_WITH_TABLE_ON_Q; - } - } else { - mode = GR_FOG_DISABLE; - } - - color = TDFXPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F), - (GLubyte)(ctx->Fog.Color[1]*255.0F), - (GLubyte)(ctx->Fog.Color[2]*255.0F)); - - if ( fxMesa->Fog.Mode != mode ) { - fxMesa->Fog.Mode = mode; - fxMesa->dirty |= TDFX_UPLOAD_FOG_MODE; - fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;/*JJJ*/ - } - if ( fxMesa->Fog.Color != color ) { - fxMesa->Fog.Color = color; - fxMesa->dirty |= TDFX_UPLOAD_FOG_COLOR; - } - if ( fxMesa->Fog.TableMode != ctx->Fog.Mode || - fxMesa->Fog.Density != ctx->Fog.Density || - fxMesa->Fog.Near != ctx->Fog.Start || - fxMesa->Fog.Far != ctx->Fog.End ) - { - switch( ctx->Fog.Mode ) { - case GL_EXP: - fxMesa->Glide.guFogGenerateExp( fxMesa->Fog.Table, ctx->Fog.Density ); - break; - case GL_EXP2: - 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 ); - break; - } - - fxMesa->Fog.TableMode = ctx->Fog.Mode; - fxMesa->Fog.Density = ctx->Fog.Density; - fxMesa->Fog.Near = ctx->Fog.Start; - fxMesa->Fog.Far = ctx->Fog.End; - fxMesa->dirty |= TDFX_UPLOAD_FOG_TABLE; - } -} - -static void tdfxDDFogfv( struct gl_context *ctx, GLenum pname, const GLfloat *param ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_FOG; - - switch (pname) { - case GL_FOG_COORDINATE_SOURCE_EXT: { - GLenum p = (GLenum)*param; - if (p == GL_FOG_COORDINATE_EXT) { - _swrast_allow_vertex_fog(ctx, GL_TRUE); - _swrast_allow_pixel_fog(ctx, GL_FALSE); - _tnl_allow_vertex_fog( ctx, GL_TRUE); - _tnl_allow_pixel_fog( ctx, GL_FALSE); - } else { - _swrast_allow_vertex_fog(ctx, GL_FALSE); - _swrast_allow_pixel_fog(ctx, GL_TRUE); - _tnl_allow_vertex_fog( ctx, GL_FALSE); - _tnl_allow_pixel_fog( ctx, GL_TRUE); - } - break; - } - default: - ; - } -} - - -/* ============================================================= - * Clipping - */ - -static int intersect_rect( drm_clip_rect_t *out, - const drm_clip_rect_t *a, - const drm_clip_rect_t *b) -{ - *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 (out->y1 >= out->y2) return 0; - return 1; -} - - -/* - * Examine XF86 cliprect list and scissor state to recompute our - * cliprect list. - */ -void tdfxUpdateClipping( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - __DRIdrawable *dPriv = fxMesa->driDrawable; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - assert(ctx); - assert(fxMesa); - assert(dPriv); - - if ( dPriv->x != fxMesa->x_offset || dPriv->y != fxMesa->y_offset || - dPriv->w != fxMesa->width || dPriv->h != fxMesa->height ) { - fxMesa->x_offset = dPriv->x; - fxMesa->y_offset = dPriv->y; - fxMesa->width = dPriv->w; - fxMesa->height = dPriv->h; - fxMesa->y_delta = - fxMesa->screen_height - fxMesa->y_offset - fxMesa->height; - tdfxUpdateViewport( ctx ); - } - - if (fxMesa->scissoredClipRects && fxMesa->pClipRects) { - free(fxMesa->pClipRects); - } - - if (ctx->Scissor.Enabled) { - /* intersect OpenGL scissor box with all cliprects to make a new - * list of cliprects. - */ - drm_clip_rect_t scissor; - int x1 = ctx->Scissor.X + fxMesa->x_offset; - int y1 = fxMesa->screen_height - fxMesa->y_delta - - ctx->Scissor.Y - ctx->Scissor.Height; - int x2 = x1 + ctx->Scissor.Width; - int y2 = y1 + ctx->Scissor.Height; - scissor.x1 = MAX2(x1, 0); - scissor.y1 = MAX2(y1, 0); - scissor.x2 = MAX2(x2, 0); - scissor.y2 = MAX2(y2, 0); - - assert(scissor.x2 >= scissor.x1); - assert(scissor.y2 >= scissor.y1); - - fxMesa->pClipRects = malloc(dPriv->numClipRects - * sizeof(drm_clip_rect_t)); - if (fxMesa->pClipRects) { - int i; - fxMesa->numClipRects = 0; - for (i = 0; i < dPriv->numClipRects; i++) { - if (intersect_rect(&fxMesa->pClipRects[fxMesa->numClipRects], - &scissor, &dPriv->pClipRects[i])) { - fxMesa->numClipRects++; - } - } - fxMesa->scissoredClipRects = GL_TRUE; - } - else { - /* out of memory, forgo scissor */ - fxMesa->numClipRects = dPriv->numClipRects; - fxMesa->pClipRects = dPriv->pClipRects; - fxMesa->scissoredClipRects = GL_FALSE; - } - } - else { - fxMesa->numClipRects = dPriv->numClipRects; - fxMesa->pClipRects = dPriv->pClipRects; - fxMesa->scissoredClipRects = GL_FALSE; - } - - fxMesa->dirty |= TDFX_UPLOAD_CLIP; -} - - - -/* ============================================================= - * Culling - */ - -void tdfxUpdateCull( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrCullMode_t mode = GR_CULL_DISABLE; - - /* 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 ) { - mode = GR_CULL_POSITIVE; - } else { - mode = GR_CULL_NEGATIVE; - } - break; - - case GL_BACK: - if ( ctx->Polygon.FrontFace == GL_CCW ) { - mode = GR_CULL_NEGATIVE; - } else { - mode = GR_CULL_POSITIVE; - } - break; - - case GL_FRONT_AND_BACK: - /* Handled as a fallback on triangles in tdfx_tris.c */ - return; - - default: - ASSERT(0); - break; - } - } - - if ( fxMesa->CullMode != mode ) { - fxMesa->CullMode = mode; - fxMesa->dirty |= TDFX_UPLOAD_CULL; - } -} - -static void tdfxDDCullFace( struct gl_context *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CULL; -} - -static void tdfxDDFrontFace( struct gl_context *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CULL; -} - - -/* ============================================================= - * Line drawing. - */ - -static void tdfxUpdateLine( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - FLUSH_BATCH( fxMesa ); - fxMesa->dirty |= TDFX_UPLOAD_LINE; -} - - -static void tdfxDDLineWidth( struct gl_context *ctx, GLfloat width ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_LINE; -} - - -/* ============================================================= - * Color Attributes - */ - -static void tdfxDDColorMask( struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - - if ( fxMesa->Color.ColorMask[RCOMP] != r || - fxMesa->Color.ColorMask[GCOMP] != g || - fxMesa->Color.ColorMask[BCOMP] != b || - fxMesa->Color.ColorMask[ACOMP] != a ) { - fxMesa->Color.ColorMask[RCOMP] = r; - fxMesa->Color.ColorMask[GCOMP] = g; - fxMesa->Color.ColorMask[BCOMP] = b; - fxMesa->Color.ColorMask[ACOMP] = a; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_MASK; - - if (ctx->Visual.redBits < 8) { - /* Can't do RGB colormasking in 16bpp mode. */ - /* We can completely ignore the alpha mask. */ - FALLBACK( fxMesa, TDFX_FALLBACK_COLORMASK, (r != g || g != b) ); - } - } -} - - -static void tdfxDDClearColor( struct gl_context *ctx, - const GLfloat color[4] ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLubyte c[4]; - FLUSH_BATCH( fxMesa ); - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - fxMesa->Color.ClearColor = TDFXPACKCOLOR888( c[0], c[1], c[2] ); - fxMesa->Color.ClearAlpha = c[3]; -} - - -/* ============================================================= - * Light Model - */ - -static void tdfxDDLightModelfv( struct gl_context *ctx, GLenum pname, - const GLfloat *param ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) { - FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR, - (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR )); - } -} - -static void tdfxDDShadeModel( struct gl_context *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - /* FIXME: Can we implement native flat shading? */ - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -/* ============================================================= - * Scissor - */ - -static void -tdfxDDScissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CLIP; -} - -/* ============================================================= - * Render - */ - -static void tdfxUpdateRenderAttrib( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->dirty |= TDFX_UPLOAD_RENDER_BUFFER; -} - -/* ============================================================= - * Viewport - */ - -void tdfxUpdateViewport( struct gl_context *ctx ) -{ - 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_BIT_POS; -} - - -static void tdfxDDViewport( struct gl_context *ctx, GLint x, GLint y, - GLsizei w, GLsizei h ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_VIEWPORT; -} - - -static void tdfxDDDepthRange( struct gl_context *ctx, GLclampd nearVal, GLclampd farVal ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_VIEWPORT; -} - - -/* ============================================================= - * State enable/disable - */ - -static void tdfxDDEnable( struct gl_context *ctx, GLenum cap, GLboolean state ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - switch ( cap ) { - case GL_ALPHA_TEST: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; - break; - - case GL_BLEND: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; - FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)/*JJJ - more blending*/); - break; - - case GL_CULL_FACE: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CULL; - break; - - case GL_DEPTH_TEST: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; - break; - - case GL_DITHER: - FLUSH_BATCH( fxMesa ); - if ( state ) { - fxMesa->Color.Dither = GR_DITHER_2x2; - } else { - fxMesa->Color.Dither = GR_DITHER_DISABLE; - } - fxMesa->dirty |= TDFX_UPLOAD_DITHER; - break; - - case GL_FOG: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_FOG; - break; - - case GL_COLOR_LOGIC_OP: - 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: - FLUSH_BATCH( fxMesa ); - 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; - break; - - case GL_SCISSOR_TEST: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CLIP; - break; - - case GL_STENCIL_TEST: - FLUSH_BATCH( fxMesa ); - FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil); - fxMesa->new_state |= TDFX_NEW_STENCIL; - break; - - case GL_TEXTURE_3D: - FLUSH_BATCH( fxMesa ); - FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_MAP, state); /* wrong */ - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - default: - return; - } -} - - - -/* Set the buffer used for drawing */ -/* XXX support for separate read/draw buffers hasn't been tested */ -static void tdfxDDDrawBuffer( struct gl_context *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - FLUSH_BATCH( fxMesa ); - - if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) { - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE ); - return; - } - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; - fxMesa->new_state |= TDFX_NEW_RENDER; - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - case BUFFER_BACK_LEFT: - fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; - fxMesa->new_state |= TDFX_NEW_RENDER; - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - case -1: - FX_grColorMaskv( ctx, false4 ); - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - default: - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE ); - break; - } -} - - -static void tdfxDDReadBuffer( struct gl_context *ctx, GLenum mode ) -{ - /* XXX ??? */ -} - - -/* ============================================================= - * Polygon stipple - */ - -static void tdfxDDPolygonStipple( struct gl_context *ctx, const GLubyte *mask ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - const GLubyte *m = mask; - GLubyte q[4]; - int i,j,k; - 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; - - /* 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]; - q[1] = mask[4]; - q[2] = mask[8]; - q[3] = mask[12]; - - for (k = 0 ; k < 8 ; k++) - for (j = 0 ; j < 4; j++) - for (i = 0 ; i < 4 ; i++,m++) { - if (*m != q[j]) { - fxMesa->haveHwStipple = GL_FALSE; - return; - } - } - - fxMesa->haveHwStipple = GL_TRUE; - fxMesa->Stipple.Pattern = ( (q[0] << 0) | - (q[1] << 8) | - (q[2] << 16) | - (q[3] << 24) ); -} - - - -static void tdfxDDRenderMode( struct gl_context *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FALLBACK( fxMesa, TDFX_FALLBACK_RENDER_MODE, (mode != GL_RENDER) ); -} - - - -static void tdfxDDPrintState( const char *msg, GLuint flags ) -{ - fprintf( stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n", - msg, - flags, - (flags & TDFX_NEW_COLOR) ? "color, " : "", - (flags & TDFX_NEW_ALPHA) ? "alpha, " : "", - (flags & TDFX_NEW_DEPTH) ? "depth, " : "", - (flags & TDFX_NEW_RENDER) ? "render, " : "", - (flags & TDFX_NEW_FOG) ? "fog, " : "", - (flags & TDFX_NEW_STENCIL) ? "stencil, " : "", - (flags & TDFX_NEW_STIPPLE) ? "stipple, " : "", - (flags & TDFX_NEW_CLIP) ? "clip, " : "", - (flags & TDFX_NEW_VIEWPORT) ? "viewport, " : "", - (flags & TDFX_NEW_CULL) ? "cull, " : "", - (flags & TDFX_NEW_GLIDE) ? "glide, " : "", - (flags & TDFX_NEW_TEXTURE) ? "texture, " : "", - (flags & TDFX_NEW_CONTEXT) ? "context, " : ""); -} - - - -void tdfxDDUpdateHwState( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - int new_state = fxMesa->new_state; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if ( new_state ) - { - FLUSH_BATCH( fxMesa ); - - fxMesa->new_state = 0; - - if ( 0 ) - tdfxDDPrintState( "tdfxUpdateHwState", new_state ); - - /* Update the various parts of the context's state. - */ - if ( new_state & TDFX_NEW_ALPHA ) { - tdfxUpdateAlphaMode( ctx ); - } - - if ( new_state & TDFX_NEW_DEPTH ) - tdfxUpdateZMode( ctx ); - - if ( new_state & TDFX_NEW_FOG ) - tdfxUpdateFogAttrib( ctx ); - - if ( new_state & TDFX_NEW_CLIP ) - tdfxUpdateClipping( ctx ); - - if ( new_state & TDFX_NEW_STIPPLE ) - tdfxUpdateStipple( ctx ); - - if ( new_state & TDFX_NEW_CULL ) - tdfxUpdateCull( ctx ); - - if ( new_state & TDFX_NEW_LINE ) - tdfxUpdateLine( ctx ); - - if ( new_state & TDFX_NEW_VIEWPORT ) - tdfxUpdateViewport( ctx ); - - if ( new_state & TDFX_NEW_RENDER ) - tdfxUpdateRenderAttrib( ctx ); - - if ( new_state & TDFX_NEW_STENCIL ) - tdfxUpdateStencil( ctx ); - - if ( new_state & TDFX_NEW_TEXTURE ) { - tdfxUpdateTextureState( ctx ); - } - else if ( new_state & TDFX_NEW_TEXTURE_BIND ) { - tdfxUpdateTextureBinding( ctx ); - } - } - - if ( 0 ) { - FxI32 bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE); - - if ( fxMesa->Depth.Bias != bias ) { - fxMesa->Depth.Bias = bias; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS; - } - } - - if ( fxMesa->dirty ) { - LOCK_HARDWARE( fxMesa ); - tdfxEmitHwStateLocked( fxMesa ); - UNLOCK_HARDWARE( fxMesa ); - } -} - - -static void tdfxDDInvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - TDFX_CONTEXT(ctx)->new_gl_state |= new_state; -} - - - -/* Initialize the context's Glide state mirror. These values will be - * used as Glide function call parameters when the time comes. - */ -void tdfxInitState( tdfxContextPtr fxMesa ) -{ - struct gl_context *ctx = fxMesa->glCtx; - GLint i; - - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - - fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB; - fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertC = FXTRUE; - fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertD = FXFALSE; - fxMesa->ColorCombineExt.Shift = 0; - fxMesa->ColorCombineExt.Invert = FXFALSE; - fxMesa->AlphaCombineExt.SourceA = GR_CMBX_ITALPHA; - fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertC = FXTRUE; - fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertD = FXFALSE; - fxMesa->AlphaCombineExt.Shift = 0; - fxMesa->AlphaCombineExt.Invert = FXFALSE; - - fxMesa->sScale0 = fxMesa->tScale0 = 1.0; - fxMesa->sScale1 = fxMesa->tScale1 = 1.0; - - fxMesa->TexPalette.Type = 0; - fxMesa->TexPalette.Data = NULL; - - for ( i = 0 ; i < TDFX_NUM_TMU ; i++ ) { - fxMesa->TexSource[i].StartAddress = 0; - fxMesa->TexSource[i].EvenOdd = GR_MIPMAPLEVELMASK_EVEN; - fxMesa->TexSource[i].Info = NULL; - - fxMesa->TexCombine[i].FunctionRGB = 0; - fxMesa->TexCombine[i].FactorRGB = 0; - fxMesa->TexCombine[i].FunctionAlpha = 0; - fxMesa->TexCombine[i].FactorAlpha = 0; - fxMesa->TexCombine[i].InvertRGB = FXFALSE; - fxMesa->TexCombine[i].InvertAlpha = FXFALSE; - - fxMesa->TexCombineExt[i].Alpha.SourceA = 0; - /* XXX more state to init here */ - fxMesa->TexCombineExt[i].Color.SourceA = 0; - fxMesa->TexCombineExt[i].EnvColor = 0x0; - - fxMesa->TexParams[i].sClamp = GR_TEXTURECLAMP_WRAP; - fxMesa->TexParams[i].tClamp = GR_TEXTURECLAMP_WRAP; - fxMesa->TexParams[i].minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - fxMesa->TexParams[i].magFilt = GR_TEXTUREFILTER_BILINEAR; - fxMesa->TexParams[i].mmMode = GR_MIPMAP_DISABLE; - fxMesa->TexParams[i].LODblend = FXFALSE; - fxMesa->TexParams[i].LodBias = 0.0; - - fxMesa->TexState.EnvMode[i] = ~0; - fxMesa->TexState.TexFormat[i] = ~0; - fxMesa->TexState.Enabled[i] = 0; - } - - if ( ctx->Visual.doubleBufferMode) { - fxMesa->DrawBuffer = GR_BUFFER_BACKBUFFER; - fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; - } else { - fxMesa->DrawBuffer = GR_BUFFER_FRONTBUFFER; - fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; - } - - fxMesa->Color.ClearColor = 0x00000000; - fxMesa->Color.ClearAlpha = 0x00; - fxMesa->Color.ColorMask[RCOMP] = FXTRUE; - fxMesa->Color.ColorMask[BCOMP] = FXTRUE; - fxMesa->Color.ColorMask[GCOMP] = FXTRUE; - fxMesa->Color.ColorMask[ACOMP] = FXTRUE; - fxMesa->Color.MonoColor = 0xffffffff; - - fxMesa->Color.AlphaFunc = GR_CMP_ALWAYS; - fxMesa->Color.AlphaRef = 0x00; - fxMesa->Color.BlendSrcRGB = GR_BLEND_ONE; - fxMesa->Color.BlendDstRGB = GR_BLEND_ZERO; - fxMesa->Color.BlendSrcA = GR_BLEND_ONE; - fxMesa->Color.BlendSrcA = GR_BLEND_ZERO; - - fxMesa->Color.Dither = GR_DITHER_2x2; - - if ( fxMesa->glCtx->Visual.depthBits > 0 ) { - fxMesa->Depth.Mode = GR_DEPTHBUFFER_ZBUFFER; - } else { - fxMesa->Depth.Mode = GR_DEPTHBUFFER_DISABLE; - } - fxMesa->Depth.Bias = 0; - fxMesa->Depth.Func = GR_CMP_LESS; - fxMesa->Depth.Clear = 0; /* computed later */ - fxMesa->Depth.Mask = FXTRUE; - - - fxMesa->Fog.Mode = GR_FOG_DISABLE; - fxMesa->Fog.Color = 0x00000000; - fxMesa->Fog.Table = NULL; - fxMesa->Fog.Density = 1.0; - fxMesa->Fog.Near = 1.0; - fxMesa->Fog.Far = 1.0; - - fxMesa->Stencil.Function = GR_CMP_ALWAYS; - fxMesa->Stencil.RefValue = 0; - fxMesa->Stencil.ValueMask = 0xff; - fxMesa->Stencil.WriteMask = 0xff; - fxMesa->Stencil.FailFunc = 0; - fxMesa->Stencil.ZFailFunc = 0; - fxMesa->Stencil.ZPassFunc = 0; - fxMesa->Stencil.Clear = 0; - - fxMesa->Stipple.Mode = GR_STIPPLE_DISABLE; - fxMesa->Stipple.Pattern = 0xffffffff; - - fxMesa->Scissor.minX = 0; - fxMesa->Scissor.minY = 0; - fxMesa->Scissor.maxX = 0; - fxMesa->Scissor.maxY = 0; - - fxMesa->Viewport.Mode = GR_WINDOW_COORDS; - fxMesa->Viewport.X = 0; - fxMesa->Viewport.Y = 0; - fxMesa->Viewport.Width = 0; - fxMesa->Viewport.Height = 0; - fxMesa->Viewport.Near = 0.0; - fxMesa->Viewport.Far = 0.0; - - fxMesa->CullMode = GR_CULL_DISABLE; - - fxMesa->Glide.ColorFormat = GR_COLORFORMAT_ABGR; - fxMesa->Glide.Origin = GR_ORIGIN_LOWER_LEFT; - fxMesa->Glide.Initialized = FXFALSE; -} - - - -void tdfxDDInitStateFuncs( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - ctx->Driver.UpdateState = tdfxDDInvalidateState; - - ctx->Driver.ClearColor = tdfxDDClearColor; - ctx->Driver.DrawBuffer = tdfxDDDrawBuffer; - ctx->Driver.ReadBuffer = tdfxDDReadBuffer; - - ctx->Driver.AlphaFunc = tdfxDDAlphaFunc; - ctx->Driver.BlendEquationSeparate = tdfxDDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = tdfxDDBlendFuncSeparate; - ctx->Driver.ClearDepth = tdfxDDClearDepth; - ctx->Driver.ColorMask = tdfxDDColorMask; - ctx->Driver.CullFace = tdfxDDCullFace; - ctx->Driver.FrontFace = tdfxDDFrontFace; - ctx->Driver.DepthFunc = tdfxDDDepthFunc; - ctx->Driver.DepthMask = tdfxDDDepthMask; - ctx->Driver.DepthRange = tdfxDDDepthRange; - ctx->Driver.Enable = tdfxDDEnable; - ctx->Driver.Fogfv = tdfxDDFogfv; - ctx->Driver.LightModelfv = tdfxDDLightModelfv; - ctx->Driver.LineWidth = tdfxDDLineWidth; - ctx->Driver.PolygonStipple = tdfxDDPolygonStipple; - ctx->Driver.RenderMode = tdfxDDRenderMode; - ctx->Driver.Scissor = tdfxDDScissor; - ctx->Driver.ShadeModel = tdfxDDShadeModel; - - if ( fxMesa->haveHwStencil ) { - ctx->Driver.StencilFuncSeparate = tdfxDDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = tdfxDDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = tdfxDDStencilOpSeparate; - } - - ctx->Driver.Viewport = tdfxDDViewport; -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.h b/src/mesa/drivers/dri/tdfx/tdfx_state.h deleted file mode 100644 index 2e96fcbeb5d..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_state.h +++ /dev/null @@ -1,60 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#ifndef __TDFX_STATE_H__ -#define __TDFX_STATE_H__ - -#include "main/context.h" -#include "tdfx_context.h" - -extern void tdfxDDInitStateFuncs( struct gl_context *ctx ); - -extern void tdfxDDUpdateHwState( struct gl_context *ctx ); - -extern void tdfxInitState( tdfxContextPtr fxMesa ); - -extern void tdfxUpdateClipping( struct gl_context *ctx ); - - -extern void tdfxFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( rmesa, bit, mode ) tdfxFallback( rmesa->glCtx, bit, mode ) - -extern void tdfxUpdateCull( struct gl_context *ctx ); -extern void tdfxUpdateStipple( struct gl_context *ctx ); -extern void tdfxUpdateViewport( struct gl_context *ctx ); - - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c deleted file mode 100644 index d74ddb24005..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c +++ /dev/null @@ -1,1868 +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. - */ - -/* - * New fixes: - * Daniel Borca <[email protected]>, 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - - -#include "main/enums.h" -#include "main/image.h" -#include "main/mipmap.h" -#include "main/texcompress.h" -#include "main/teximage.h" -#include "main/texstore.h" -#include "main/texobj.h" -#include "tdfx_context.h" -#include "tdfx_tex.h" -#include "tdfx_texman.h" - - -/* no borders! can't halve 1x1! (stride > width * comp) not allowed */ -static void -_mesa_halve2x2_teximage2d ( struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint bytesPerPixel, - GLint srcWidth, GLint srcHeight, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - GLint i, j, k; - GLint dstWidth = srcWidth / 2; - GLint dstHeight = srcHeight / 2; - GLint srcRowStride = srcWidth * bytesPerPixel; - GLubyte *src = (GLubyte *)srcImage; - GLubyte *dst = dstImage; - GLuint dstImageOffsets = 0; - - GLuint bpt = 0; - GLubyte *_s = NULL; - GLubyte *_d = NULL; - GLenum _t = 0; - - if (texImage->TexFormat == MESA_FORMAT_RGB565) { - _t = GL_UNSIGNED_SHORT_5_6_5_REV; - bpt = bytesPerPixel; - } else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) { - _t = GL_UNSIGNED_SHORT_4_4_4_4_REV; - bpt = bytesPerPixel; - } else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) { - _t = GL_UNSIGNED_SHORT_1_5_5_5_REV; - bpt = bytesPerPixel; - } - if (bpt) { - bytesPerPixel = 4; - srcRowStride = srcWidth * bytesPerPixel; - if (dstWidth == 0) { - dstWidth = 1; - } - if (dstHeight == 0) { - dstHeight = 1; - } - _s = src = MALLOC(srcRowStride * srcHeight); - _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight); - _mesa_texstore(ctx, 2, GL_RGBA, - MESA_FORMAT_RGBA8888_REV, src, - 0, 0, 0, /* dstX/Y/Zoffset */ - srcRowStride, /* dstRowStride */ - &dstImageOffsets, - srcWidth, srcHeight, 1, - texImage->_BaseFormat, _t, srcImage, &ctx->DefaultPacking); - } - - if (srcHeight == 1) { - for (i = 0; i < dstWidth; i++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + src[bytesPerPixel] + 1) / 2; - src++; - dst++; - } - src += bytesPerPixel; - } - } else if (srcWidth == 1) { - for (j = 0; j < dstHeight; j++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + src[srcRowStride] + 1) / 2; - src++; - dst++; - } - src += srcRowStride; - } - } else { - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + - src[bytesPerPixel] + - src[srcRowStride] + - src[srcRowStride + bytesPerPixel] + 2) / 4; - src++; - dst++; - } - src += bytesPerPixel; - } - src += srcRowStride; - } - } - - if (bpt) { - src = _s; - dst = _d; - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, dstImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstWidth * bpt, - &dstImageOffsets, - dstWidth, dstHeight, 1, - GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking); - FREE(dst); - FREE(src); - } -} - - -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; - } -} - - -static void -tdfxGenerateMipmap(struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj) -{ - GLint mipWidth, mipHeight; - tdfxMipMapLevel *mip; - struct gl_texture_image *mipImage; /* the new/next image */ - struct gl_texture_image *texImage; - const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); - GLint level = texObj->BaseLevel; - GLsizei width, height, texelBytes; - const tdfxMipMapLevel *mml; - - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - - mml = TDFX_TEXIMAGE_DATA(texImage); - - width = texImage->Width; - height = texImage->Height; - while (level < texObj->MaxLevel && level < maxLevels - 1) { - mipWidth = width / 2; - if (!mipWidth) { - mipWidth = 1; - } - mipHeight = height / 2; - if (!mipHeight) { - mipHeight = 1; - } - if ((mipWidth == width) && (mipHeight == height)) { - break; - } - ++level; - mipImage = _mesa_select_tex_image(ctx, texObj, target, level); - mip = TDFX_TEXIMAGE_DATA(mipImage); - _mesa_halve2x2_teximage2d(ctx, - texImage, - texelBytes, - mml->width, mml->height, - texImage->Data, mipImage->Data); - texImage = mipImage; - mml = mip; - width = mipWidth; - height = mipHeight; - } -} - - -/* - * 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 - * sscale - S scale factor used during triangle setup - * tscale - T scale factor used during triangle setup - * wscale - OpenGL -> Glide image width scale factor - * hscale - OpenGL -> Glide image height scale factor - * - * Sample results: - * w h lodlevel aspectRatio - * 128 128 GR_LOD_LOG2_128 (=7) GR_ASPECT_LOG2_1x1 (=0) - * 64 64 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_1x1 (=0) - * 64 32 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_2x1 (=1) - * 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 struct gl_context *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; - - ASSERT(w >= 1); - ASSERT(h >= 1); - - logw = logbase2(w); - logh = logbase2(h); - ar = logw - logh; /* aspect ratio = difference in log dimensions */ - s = t = 256.0; - ws = hs = 1; - - /* 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; - if (ar <= GR_ASPECT_LOG2_8x1) { - t = 256 >> ar; - } - else { - /* have to stretch image height */ - t = 32.0; - hs = 1 << (ar - 3); - ar = GR_ASPECT_LOG2_8x1; - } - } - else { - ASSERT(w < h); - lod = logh; - if (ar >= GR_ASPECT_LOG2_1x8) { - s = 256 >> -ar; - } - else { - /* have to stretch image width */ - s = 32.0; - ws = 1 << (-ar - 3); - ar = GR_ASPECT_LOG2_1x8; - } - } - - 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; -} - - -/* - * We need to call this when a texture object's minification filter - * or texture image sizes change. - */ -static void RevalidateTexture(struct gl_context *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[0][minl]) { - maxl = MIN2(tObj->MaxLevel, tObj->Image[0][minl]->MaxLog2); - - /* compute largeLodLog2, aspect ratio and texcoord scale factors */ - tdfxTexGetInfo(ctx, tObj->Image[0][minl]->Width, tObj->Image[0][minl]->Height, - &ti->info.largeLodLog2, - &ti->info.aspectRatioLog2, - &(ti->sScale), &(ti->tScale), NULL, NULL); - } - - if (tObj->Image[0][maxl] && (tObj->Sampler.MinFilter != GL_NEAREST) && (tObj->Sampler.MinFilter != GL_LINEAR)) { - /* mipmapping: need to compute smallLodLog2 */ - tdfxTexGetInfo(ctx, tObj->Image[0][maxl]->Width, - tObj->Image[0][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; - - /* this is necessary because of fxDDCompressedTexImage2D */ - if (ti->padded) { - struct gl_texture_image *texImage = tObj->Image[0][minl]; - tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - if (mml->wScale != 1 || mml->hScale != 1) { - ti->sScale /= mml->wScale; - ti->tScale /= mml->hScale; - } - } -} - - -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; - - ti->mmMode = GR_MIPMAP_NEAREST; - ti->LODblend = FXFALSE; - - return ti; -} - - -/* - * Called via glBindTexture. - */ -static void -tdfxBindTexture(struct gl_context * ctx, GLenum target, - struct gl_texture_object *tObj) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "fxmesa: fxDDTexBind(%d,%p)\n", tObj->Name, - tObj->DriverData); - } - - if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) - return; - - if (!tObj->DriverData) { - tObj->DriverData = fxAllocTexObjData(fxMesa); - } - - ti = TDFX_TEXTURE_DATA(tObj); - ti->lastTimeUsed = fxMesa->texBindNumber++; - - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -/* - * Called via glTexEnv. - */ -static void -tdfxTexEnv(struct gl_context * ctx, GLenum target, GLenum pname, - const GLfloat * param) -{ - 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; -} - - -/* - * Called via glTexParameter. - */ -static void -tdfxTexParameter(struct gl_context * 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_1D) && (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 (!fxMesa->Glide.HaveCombineExt) { - 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 (!fxMesa->Glide.HaveCombineExt) { - 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; - } - ti->reloadImages = GL_TRUE; - 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_TO_BORDER: - case GL_CLAMP_TO_EDGE: - case GL_CLAMP: - ti->sClamp = GR_TEXTURECLAMP_CLAMP; - break; - case GL_REPEAT: - ti->sClamp = GR_TEXTURECLAMP_WRAP; - break; - case GL_MIRRORED_REPEAT: - ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT; - break; - default: - break; - } - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - case GL_TEXTURE_WRAP_T: - switch (param) { - case GL_CLAMP_TO_BORDER: - case GL_CLAMP_TO_EDGE: - case GL_CLAMP: - ti->tClamp = GR_TEXTURECLAMP_CLAMP; - break; - case GL_REPEAT: - ti->tClamp = GR_TEXTURECLAMP_WRAP; - break; - case GL_MIRRORED_REPEAT: - ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT; - 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; - } -} - - -/* - * Called via glDeleteTextures to delete a texture object. - * Here, we delete the Glide data associated with the texture. - */ -static void -tdfxDeleteTexture(struct gl_context * ctx, struct gl_texture_object *tObj) -{ - if (ctx && ctx->DriverCtx) { - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTMFreeTexture(fxMesa, tObj); - fxMesa->new_state |= TDFX_NEW_TEXTURE; - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); - } -} - - -/* - * Return true if texture is resident, false otherwise. - */ -static GLboolean -tdfxIsTextureResident(struct gl_context *ctx, struct gl_texture_object *tObj) -{ - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - return (GLboolean) (ti && ti->isInTM); -} - - - -/* - * Convert a gl_color_table texture palette to Glide's format. - */ -static GrTexTable_t -convertPalette(FxU32 data[256], const struct gl_color_table *table) -{ - const GLubyte *tableUB = table->TableUB; - GLint width = table->Size; - FxU32 r, g, b, a; - GLint i; - - switch (table->_BaseFormat) { - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - 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; - } - return GR_TEXTABLE_PALETTE; - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - 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; - } - return GR_TEXTABLE_PALETTE; - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - default: - /* XXX fixme: how can this happen? */ - _mesa_error(NULL, GL_INVALID_ENUM, "convertPalette: table->_BaseFormat == %s", - _mesa_lookup_enum_by_nr(table->_BaseFormat)); - return GR_TEXTABLE_PALETTE; - } -} - - - -static void -tdfxUpdateTexturePalette(struct gl_context * ctx, struct gl_texture_object *tObj) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (tObj) { - /* per-texture palette */ - tdfxTexInfo *ti; - - /* This might be a proxy texture. */ - if (!tObj->Palette.TableUB) - return; - - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = TDFX_TEXTURE_DATA(tObj); - assert(ti); - ti->paltype = convertPalette(ti->palette.data, &tObj->Palette); - /*tdfxTexInvalidate(ctx, tObj);*/ - } - else { - /* global texture palette */ - fxMesa->TexPalette.Type = convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette); - fxMesa->TexPalette.Data = &(fxMesa->glbPalette.data); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX too heavy-handed */ -} - - -/**********************************************************************/ -/**** NEW TEXTURE IMAGE FUNCTIONS ****/ -/**********************************************************************/ - -#if 000 -static FxBool TexusFatalError = FXFALSE; -static FxBool TexusError = FXFALSE; - -#define TX_DITHER_NONE 0x00000000 - -static void -fxTexusError(const char *string, FxBool fatal) -{ - _mesa_problem(NULL, string); - /* - * Just propagate the fatal value up. - */ - TexusError = FXTRUE; - TexusFatalError = fatal; -} -#endif - - -static gl_format -tdfxChooseTextureFormat( struct gl_context *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: - case GL_COMPRESSED_ALPHA: - return MESA_FORMAT_A8; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - return MESA_FORMAT_L8; - case 2: - case GL_LUMINANCE_ALPHA: - 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 GL_COMPRESSED_LUMINANCE_ALPHA: - return MESA_FORMAT_AL88; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return MESA_FORMAT_I8; - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - return MESA_FORMAT_RGB565; - case GL_COMPRESSED_RGB: - /* intentional fall-through */ - case 3: - case GL_RGB: - if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) { - return MESA_FORMAT_RGB565; - } - /* intentional fall through */ - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return (allow32bpt) ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - case GL_RGBA2: - case GL_RGBA4: - return MESA_FORMAT_ARGB4444; - case GL_COMPRESSED_RGBA: - /* intentional fall-through */ - case 4: - case GL_RGBA: - if ( srcFormat == GL_BGRA ) { - if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) { - return MESA_FORMAT_ARGB8888; - } - else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { - return MESA_FORMAT_ARGB4444; - } - else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { - return MESA_FORMAT_ARGB1555; - } - } - /* intentional fall through */ - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return allow32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - 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_FORMAT_CI8; - /* GL_EXT_texture_compression_s3tc */ - /* GL_S3_s3tc */ - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return MESA_FORMAT_RGBA_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return MESA_FORMAT_RGBA_DXT5; - /* GL_3DFX_texture_compression_FXT1 */ - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - default: - _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat"); - return MESA_FORMAT_NONE; - } -} - - -/* - * Return the Glide format for the given mesa texture format. - */ -static GrTextureFormat_t -fxGlideFormat(GLint mesaFormat) -{ - 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; - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - return GR_TEXFMT_ARGB_CMP_FXT1; - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - return GR_TEXFMT_ARGB_CMP_DXT1; - case MESA_FORMAT_RGBA_DXT3: - return GR_TEXFMT_ARGB_CMP_DXT3; - case MESA_FORMAT_RGBA_DXT5: - return GR_TEXFMT_ARGB_CMP_DXT5; - default: - _mesa_problem(NULL, "Unexpected format in fxGlideFormat"); - return 0; - } -} - - -/* 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. - */ -extern void -fxt1_decode_1 (const void *texture, int width, - int i, int j, unsigned char *rgba); - -static void -fetch_intensity8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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 void -fetch_luminance8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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, GLchan * rgba) -{ - 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] = 255; - rgba[GCOMP] = 255; - rgba[BCOMP] = 255; - rgba[ACOMP] = *texel; -} - - -static void -fetch_index8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * indexOut) -{ - 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; - *indexOut = *texel; -} - - -static void -fetch_luminance8_alpha8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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 -fetch_r5g6b5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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; -} - - -static void -fetch_r4g4b4a4(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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; -} - - -static void -fetch_r5g5b5a1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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; -} - - -static void -fetch_a8r8g8b8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - 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); -} - - -static void -fetch_rgb_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - fxt1_decode_1(texImage->Data, mml->width, i, j, rgba); - rgba[ACOMP] = 255; -} - - -static void -fetch_rgba_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - fxt1_decode_1(texImage->Data, mml->width, i, j, rgba); -} - - -static void -fetch_rgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - /* XXX Get fetch func from _mesa_get_texel_fetch_func() - _mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba); - */ -} - - -static void -fetch_rgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - /* XXX Get fetch func from _mesa_get_texel_fetch_func() - _mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba); - */ -} - - -static void -fetch_rgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - /* XXX Get fetch func from _mesa_get_texel_fetch_func() - _mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba); - */ -} - - -static void -fetch_rgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - /* XXX Get fetch func from _mesa_get_texel_fetch_func() - _mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba); - */ -} - - -static FetchTexelFuncC -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; - case MESA_FORMAT_RGB_FXT1: - return &fetch_rgb_fxt1; - case MESA_FORMAT_RGBA_FXT1: - return &fetch_rgba_fxt1; - case MESA_FORMAT_RGB_DXT1: - return &fetch_rgb_dxt1; - case MESA_FORMAT_RGBA_DXT1: - return &fetch_rgba_dxt1; - case MESA_FORMAT_RGBA_DXT3: - return &fetch_rgba_dxt3; - case MESA_FORMAT_RGBA_DXT5: - return &fetch_rgba_dxt5; - default: - _mesa_problem(NULL, "Unexpected format in fxFetchFunction"); - return NULL; - } -} - - -static GLboolean -adjust2DRatio (struct gl_context *ctx, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - tdfxMipMapLevel *mml, - struct gl_texture_image *texImage, - GLint texelBytes, - GLint dstRowStride) -{ - const GLint newWidth = width * mml->wScale; - const GLint newHeight = height * mml->hScale; - GLvoid *tempImage; - GLuint dstImageOffsets = 0; - - if (!_mesa_is_format_compressed(texImage->TexFormat)) { - GLubyte *destAddr; - - tempImage = MALLOC(width * height * texelBytes); - if (!tempImage) { - return GL_FALSE; - } - - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, tempImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - width * texelBytes, /* dstRowStride */ - &dstImageOffsets, - width, height, 1, - format, type, pixels, packing); - - /* now rescale */ - /* 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, - width, - dstRowStride, /* dst stride */ - width, height, - newWidth, newHeight, - tempImage, destAddr); - } else { - const GLint rawBytes = 4; - GLvoid *rawImage = MALLOC(width * height * rawBytes); - - if (!rawImage) { - return GL_FALSE; - } - tempImage = MALLOC(newWidth * newHeight * rawBytes); - if (!tempImage) { - FREE(rawImage); - return GL_FALSE; - } - /* unpack image, apply transfer ops and store in rawImage */ - _mesa_texstore(ctx, 2, GL_RGBA, - MESA_FORMAT_RGBA8888_REV, rawImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - width * rawBytes, /* dstRowStride */ - &dstImageOffsets, - width, height, 1, - format, type, pixels, packing); - _mesa_rescale_teximage2d(rawBytes, - width, - newWidth * rawBytes, /* dst stride */ - width, height, /* src */ - newWidth, newHeight, /* dst */ - rawImage /*src*/, tempImage /*dst*/ ); - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, texImage->Data, - xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */ - dstRowStride, - &dstImageOffsets, - newWidth, newHeight, 1, - GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking); - FREE(rawImage); - } - - FREE(tempImage); - - return GL_TRUE; -} - - -static void -tdfxTexImage2D(struct gl_context *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); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - GLint texelBytes, dstRowStride; - GLuint mesaFormat; - - /* - printf("TexImage id=%d int 0x%x format 0x%x type 0x%x %dx%d\n", - texObj->Name, texImage->InternalFormat, format, type, - texImage->Width, texImage->Height); - */ - - 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); - } - assert(ti); - - 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; - -#if FX_COMPRESS_S3TC_AS_FXT1_HACK - /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */ - /* [dBorca] we should update texture's attribute, then, - * because if the application asks us to decompress, we - * have to know the REAL format! Also, DXT3/5 might not - * be correct, since it would mess with "compressedSize". - * Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3. - */ - if (_mesa_is_format_compressed(texImage->TexFormat)) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - internalFormat = GL_COMPRESSED_RGB_FXT1_3DFX; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - internalFormat = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - texImage->InternalFormat = internalFormat; - } -#endif -#if FX_TC_NAPALM - if (fxMesa->type >= GR_SSTTYPE_Voodoo4) { - GLenum texNapalm = 0; - if (internalFormat == GL_COMPRESSED_RGB) { - texNapalm = GL_COMPRESSED_RGB_FXT1_3DFX; - } else if (internalFormat == GL_COMPRESSED_RGBA) { - texNapalm = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - if (texNapalm) { - texImage->InternalFormat = internalFormat = texNapalm; - _mesa_is_format_compressed(texImage->TexFormat) = GL_TRUE; - } - } -#endif - - mesaFormat = texImage->TexFormat; - mml->glideFormat = fxGlideFormat(mesaFormat); - ti->info.format = mml->glideFormat; - texImage->FetchTexelc = fxFetchFunction(mesaFormat); - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - - if (_mesa_is_format_compressed(texImage->TexFormat)) { - GLuint compressedSize = _mesa_format_image_size(mesaFormat, mml->width, - mml->height, 1); - dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - texImage->Data = _mesa_alloc_texmemory(compressedSize); - } else { - dstRowStride = mml->width * texelBytes; - texImage->Data = _mesa_alloc_texmemory(mml->width * mml->height * texelBytes); - } - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - - if (pixels != NULL) { - if (mml->wScale != 1 || mml->hScale != 1) { - /* rescale image to overcome 1:8 aspect limitation */ - if (!adjust2DRatio(ctx, - 0, 0, - width, height, - format, type, pixels, - packing, - mml, - texImage, - texelBytes, - dstRowStride) - ) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - else { - /* no rescaling needed */ - /* unpack image, apply transfer ops and store in texImage->Data */ - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - format, type, pixels, packing); - } - } - - RevalidateTexture(ctx, texObj); - - ti->reloadImages = GL_TRUE; - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -static void -tdfxTexSubImage2D(struct gl_context *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, dstRowStride; - - 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->_BaseFormat); - - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - if (_mesa_is_format_compressed(texImage->TexFormat)) { - dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - } else { - dstRowStride = mml->width * texelBytes; - } - - if (mml->wScale != 1 || mml->hScale != 1) { - /* need to rescale subimage to match mipmap level's rescale factors */ - if (!adjust2DRatio(ctx, - xoffset, yoffset, - width, height, - format, type, pixels, - packing, - mml, - texImage, - texelBytes, - dstRowStride) - ) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - return; - } - } - else { - /* no rescaling needed */ - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, texImage->Data, - xoffset, yoffset, 0, - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - 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 */ -} - - -static void -tdfxTexImage1D(struct gl_context *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) -{ - tdfxTexImage2D(ctx, target, level, - internalFormat, width, 1, border, - format, type, pixels, - packing, - texObj, - texImage); -} - -static void -tdfxTexSubImage1D(struct gl_context *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 ) -{ - tdfxTexSubImage2D(ctx, target, level, - xoffset, 0, - width, 1, - format, type, - pixels, - packing, - texObj, - texImage); -} - -/**********************************************************************/ -/**** COMPRESSED TEXTURE IMAGE FUNCTIONS ****/ -/**********************************************************************/ - -static void -tdfxCompressedTexImage2D (struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - gl_format mesaFormat; - GLuint compressedSize = 0; - - if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) { - fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n", - texObj->Name, internalFormat, - width, height); - } - - if ((target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) || texImage->Border > 0) { - _mesa_problem(NULL, "tdfx: unsupported texture in tdfxCompressedTexImg()\n"); - return; - } - - ti = TDFX_TEXTURE_DATA(texObj); - if (!ti) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - ti = TDFX_TEXTURE_DATA(texObj); - } - assert(ti); - - mml = TDFX_TEXIMAGE_DATA(texImage); - if (!mml) { - texImage->DriverData = CALLOC(sizeof(tdfxMipMapLevel)); - if (!texImage->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - mml = TDFX_TEXIMAGE_DATA(texImage); - } - - tdfxTexGetInfo(ctx, width, height, NULL, NULL, NULL, NULL, - &mml->wScale, &mml->hScale); - - mml->width = width * mml->wScale; - mml->height = height * mml->hScale; - - - /* Determine the appropriate Glide texel format, - * given the user's internal texture format hint. - */ - mesaFormat = texImage->TexFormat; - mml->glideFormat = fxGlideFormat(mesaFormat); - ti->info.format = mml->glideFormat; - texImage->FetchTexelc = fxFetchFunction(mesaFormat); - - /* allocate new storage for texture image, if needed */ - if (!texImage->Data) { - compressedSize = _mesa_format_image_size(mesaFormat, mml->width, - mml->height, 1); - texImage->Data = _mesa_alloc_texmemory(compressedSize); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } - - /* save the texture data */ - if (mml->wScale != 1 || mml->hScale != 1) { - /* [dBorca] Hack alert: - * now we're screwed. We can't decompress, - * unless we do it in HW (via textureBuffer). - * We still have some chances: - * 1) we got FXT1 textures - we CAN decompress, rescale for - * aspectratio, then compress back. - * 2) there is a chance that MIN("s", "t") won't be overflowed. - * Thus, we don't care about textureclamp and we could lower - * MIN("uscale", "vscale") below 32. We still have to have - * our data aligned inside a 8:1 rectangle. - * 3) just in case if MIN("s", "t") gets overflowed with GL_REPEAT, - * we replicate the data over the padded area. - * For now, we take 2) + 3) but texelfetchers will be wrong! - */ - const GLuint mesaFormat = texImage->TexFormat; - GLuint srcRowStride = _mesa_format_row_stride(mesaFormat, width); - - GLuint destRowStride = _mesa_format_row_stride(mesaFormat, - mml->width); - - _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4, - destRowStride, (mml->height+3) / 4, - 1, data, srcRowStride, - texImage->Data); - ti->padded = GL_TRUE; - } else { - memcpy(texImage->Data, data, compressedSize); - } - - RevalidateTexture(ctx, texObj); - - ti->reloadImages = GL_TRUE; - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -static void -tdfxCompressedTexSubImage2D( struct gl_context *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); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - GLint destRowStride, srcRowStride; - GLint i, rows; - GLubyte *dest; - const GLuint mesaFormat = texImage->TexFormat; - - if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) { - fprintf(stderr, "tdfxCompressedTexSubImage2D: id=%d\n", texObj->Name); - } - - ti = TDFX_TEXTURE_DATA(texObj); - assert(ti); - mml = TDFX_TEXIMAGE_DATA(texImage); - assert(mml); - - srcRowStride = _mesa_format_row_stride(mesaFormat, width); - - destRowStride = _mesa_format_row_stride(mesaFormat, mml->width); - dest = _mesa_compressed_image_address(xoffset, yoffset, 0, - mesaFormat, - mml->width, - (GLubyte*) texImage->Data); - - rows = height / 4; /* [dBorca] hardcoded 4, but works for FXT1/DXTC */ - - for (i = 0; i < rows; i++) { - memcpy(dest, data, srcRowStride); - dest += destRowStride; - data = (GLvoid *)((intptr_t)data + (intptr_t)srcRowStride); - } - - /* [dBorca] Hack alert: - * see fxDDCompressedTexImage2D for caveats - */ - if (mml->wScale != 1 || mml->hScale != 1) { - srcRowStride = _mesa_format_row_stride(mesaFormat, texImage->Width); - - destRowStride = _mesa_format_row_stride(mesaFormat, mml->width); - _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4, - destRowStride, mml->height / 4, - 1, texImage->Data, destRowStride, - texImage->Data); - } - - RevalidateTexture(ctx, texObj); - - ti->reloadImages = GL_TRUE; - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -#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"); - } -} -#endif - - -GLboolean -tdfxTestProxyTexImage(struct gl_context *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 *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - /*JJJ wrong*/ - case GL_PROXY_TEXTURE_2D: - { - struct gl_texture_object *tObj; - tdfxTexInfo *ti; - int memNeeded; - - tObj = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = TDFX_TEXTURE_DATA(tObj); - assert(ti); - - /* assign the parameters to test against */ - tObj->Image[0][level]->Width = width; - tObj->Image[0][level]->Height = height; - tObj->Image[0][level]->Border = border; -#if 0 - tObj->Image[0][level]->InternalFormat = internalFormat; -#endif - if (level == 0) { - /* don't use mipmap levels > 0 */ - tObj->Sampler.MinFilter = tObj->Sampler.MagFilter = GL_NEAREST; - } - else { - /* test with all mipmap levels */ - tObj->Sampler.MinFilter = GL_LINEAR_MIPMAP_LINEAR; - tObj->Sampler.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 */ - } -} - - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -tdfxNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - return obj; -} - - -void tdfxInitTextureFuncs( struct dd_function_table *functions ) -{ - functions->BindTexture = tdfxBindTexture; - functions->NewTextureObject = tdfxNewTextureObject; - functions->DeleteTexture = tdfxDeleteTexture; - functions->TexEnv = tdfxTexEnv; - functions->TexParameter = tdfxTexParameter; - functions->ChooseTextureFormat = tdfxChooseTextureFormat; - functions->TexImage1D = tdfxTexImage1D; - functions->TexSubImage1D = tdfxTexSubImage1D; - functions->TexImage2D = tdfxTexImage2D; - functions->TexSubImage2D = tdfxTexSubImage2D; - functions->IsTextureResident = tdfxIsTextureResident; - functions->CompressedTexImage2D = tdfxCompressedTexImage2D; - functions->CompressedTexSubImage2D = tdfxCompressedTexSubImage2D; - functions->UpdateTexturePalette = tdfxUpdateTexturePalette; - functions->GenerateMipmap = tdfxGenerateMipmap; -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.h b/src/mesa/drivers/dri/tdfx/tdfx_tex.h deleted file mode 100644 index 26885fae3e3..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_tex.h +++ /dev/null @@ -1,101 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#ifndef _TDFX_TEX_H_ -#define _TDFX_TEX_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(struct gl_context * ctx, struct gl_texture_object *tObj); - - -#if 000 /* DEAD? */ -extern void -fxDDTexUseGlobalPalette(struct gl_context * ctx, GLboolean state); -#endif - -extern GLboolean -tdfxTestProxyTexImage(struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border); - -extern GLvoid * -tdfxDDGetTexImage(struct gl_context * ctx, GLenum target, GLint level, - const struct gl_texture_object *texObj, - GLenum * formatOut, GLenum * typeOut, - GLboolean * freeImageOut); - -extern void -tdfxDDGetCompressedTexImage( struct gl_context *ctx, GLenum target, - GLint lod, void *image, - const struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - -extern GLint -tdfxSpecificCompressedTexFormat(struct gl_context *ctx, - GLint internalFormat, - GLint numDimensions); - -extern GLint -tdfxBaseCompressedTexFormat(struct gl_context *ctx, - GLint internalFormat); - -extern GLboolean -tdfxDDIsCompressedFormat(struct gl_context *ctx, GLint internalFormat); - -extern GLsizei -tdfxDDCompressedImageSize(struct gl_context *ctx, - GLenum intFormat, - GLuint numDimensions, - GLuint width, - GLuint height, - GLuint depth); - - -extern void -tdfxInitTextureFuncs( struct dd_function_table *functions ); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texman.c b/src/mesa/drivers/dri/tdfx/tdfx_texman.c deleted file mode 100644 index 1160ae2d0bc..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_texman.c +++ /dev/null @@ -1,994 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#include "tdfx_context.h" -#include "tdfx_texman.h" -#include "main/texobj.h" -#include "main/hash.h" - - -#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 -VerifyFreeList(tdfxContextPtr fxMesa, FxU32 tmu) -{ - 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 _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj - = _mesa_lookup_texture(fxMesa->glCtx, id); - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - 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 -dump_texmem(tdfxContextPtr fxMesa) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct _mesa_HashTable *textures = mesaShared->TexObjects; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxMemRange *r; - FxU32 prev; - GLuint id; - - printf("DUMP Objects:\n"); - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *obj - = _mesa_lookup_texture(fxMesa->glCtx, id); - 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; - } - -} -#endif - - - -#ifdef TEXSANITY -static void -fubar(void) -{ -} - -/* - * Sanity Check - */ -static void -sanity(tdfxContextPtr fxMesa) -{ - 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 * -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. - */ -void -tdfxTMInit(tdfxContextPtr fxMesa) -{ - 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. - */ -void -tdfxTMClose(tdfxContextPtr fxMesa) -{ - 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. - * We keep a linked list of free/available tdfxMemRange structs to - * avoid extra malloc/free calls. - */ -#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 - * existing texture to make room for the new one. This function - * determins the texture to throw out. - */ -static struct gl_texture_object * -FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu) -{ - const GLuint bindnumber = fxMesa->texBindNumber; - struct gl_texture_object *oldestObj, *lowestPriorityObj; - GLfloat lowestPriority; - GLuint oldestAge; - GLuint id; - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - - oldestObj = NULL; - oldestAge = 0; - - lowestPriority = 1.0F; - lowestPriorityObj = NULL; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *obj - = _mesa_lookup_texture(fxMesa->glCtx, id); - 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; - } -} - - -#if 0 -static void -FlushTexMemory(tdfxContextPtr fxMesa) -{ - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *obj - = _mesa_lookup_texture(fxMesa->glCtx, id); - 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. - * <tmu> is the texture unit. - * <size> is the texture size in bytes. - */ -static FxU32 -FindStartAddr(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 size) -{ - 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 - - 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, "%s: extreme texmem fragmentation", __FUNCTION__); - _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, "%s: extreme texmem fragmentation", __FUNCTION__); - _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. - */ -static void -RemoveRange_NoLock(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range) -{ - 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 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. - * <tmu> is the texture unit - * <texmemsize> is the number of bytes to allocate - */ -static tdfxMemRange * -AllocTexMem(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 texmemsize) -{ - FxU32 startAddr; - startAddr = FindStartAddr(fxMesa, tmu, texmemsize); - if (startAddr == BAD_ADDRESS) { - _mesa_problem(fxMesa->glCtx, "%s returned NULL! tmu=%d texmemsize=%d", - __FUNCTION__, (int) tmu, (int) texmemsize); - 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. - */ -void -tdfxTMDownloadTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj) -{ - 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[0][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[0][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[0][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[0][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[0][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[0][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[0][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[0][l]->Data); - } - } - break; - default: - _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)targetTMU); - return; - } -} - - -void -tdfxTMReloadMipMapLevel(struct gl_context *ctx, struct gl_texture_object *tObj, - GLint level) -{ - 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[0][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[0][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[0][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[0][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[0][level]->Data); - break; - - default: - _mesa_problem(ctx, "%s: bad tmu (%d)", __FUNCTION__, (int)tmu); - break; - } - UNLOCK_HARDWARE(fxMesa); -} - - -/* - * Allocate space for the given texture in texture memory then - * download (copy) it into that space. - */ -void -tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj, - FxU32 targetTMU ) -{ - 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, "%s: bad tmu (%d)", __FUNCTION__, (int)targetTMU); - return; - } - - ti->reloadImages = GL_TRUE; - ti->isInTM = GL_TRUE; - - fxMesa->stats.texUpload++; -} - - -/* - * Move the given texture out of hardware texture memory. - * This deallocates the texture's memory space. - */ -void -tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj ) -{ - 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: %s(%p (%d))\n", __FUNCTION__, (void *)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); - (void) shared; - RemoveRange_NoLock(fxMesa, TDFX_TMU0, ti->tm[TDFX_TMU0]); - RemoveRange_NoLock(fxMesa, TDFX_TMU1, ti->tm[TDFX_TMU1]); - break; - default: - _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)ti->whichTMU); - return; - } - - ti->isInTM = GL_FALSE; - ti->tm[0] = NULL; - ti->tm[1] = NULL; - ti->whichTMU = TDFX_TMU_NONE; - - /* - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - */ -} - - -/* - * Called via glDeleteTexture to delete a texture object. - */ -void -tdfxTMFreeTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj) -{ - 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 - * texture memory for the new context. - */ -void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa ) -{ - struct gl_context *ctx = fxMesa->glCtx; - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj - = _mesa_lookup_texture(fxMesa->glCtx, id); - tdfxTexInfo *ti = TDFX_TEXTURE_DATA( tObj ); - if ( ti && ti->isInTM ) { - int i; - for ( i = 0 ; i < MAX_TEXTURE_UNITS ; i++ ) { - if ( ctx->Texture.Unit[i]._Current == tObj ) { - tdfxTMDownloadTexture( fxMesa, tObj ); - break; - } - } - if ( i == MAX_TEXTURE_UNITS ) { - tdfxTMMoveOutTM_NoLock( fxMesa, tObj ); - } - } - } - /* - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - */ -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texman.h b/src/mesa/drivers/dri/tdfx/tdfx_texman.h deleted file mode 100644 index 87bdc3fea93..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_texman.h +++ /dev/null @@ -1,83 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#ifndef __TDFX_TEXMAN_H__ -#define __TDFX_TEXMAN_H__ - - -#include "tdfx_lock.h" - - -extern void tdfxTMInit( tdfxContextPtr fxMesa ); - -extern void tdfxTMClose( tdfxContextPtr fxMesa ); - -extern void tdfxTMDownloadTexture(tdfxContextPtr fxMesa, - struct gl_texture_object *tObj); - -extern void tdfxTMReloadMipMapLevel( struct gl_context *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/src/mesa/drivers/dri/tdfx/tdfx_texstate.c b/src/mesa/drivers/dri/tdfx/tdfx_texstate.c deleted file mode 100644 index 227f36be65d..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_texstate.c +++ /dev/null @@ -1,2218 +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. - */ - -/* - * New fixes: - * Daniel Borca <[email protected]>, 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#include "tdfx_state.h" -#include "tdfx_texman.h" -#include "tdfx_texstate.h" - - -/* ============================================================= - * Texture - */ - -/* - * These macros are used below when handling COMBINE_EXT. - */ -#define TEXENV_OPERAND_INVERTED(operand) \ - (((operand) == GL_ONE_MINUS_SRC_ALPHA) \ - || ((operand) == GL_ONE_MINUS_SRC_COLOR)) -#define TEXENV_OPERAND_ALPHA(operand) \ - (((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA)) -#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha) \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CALPHA; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITALPHA; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedAlpha; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } - -#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \ - if (!TEXENV_OPERAND_ALPHA(operand)) { \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_RGB; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CCOLOR; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITRGB; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedColor; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } \ - } else { \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CALPHA; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITALPHA; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedAlpha; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } \ - } - -#define TEXENV_SETUP_MODE_RGB(param, operand) \ - switch (operand) { \ - case GL_SRC_COLOR: \ - case GL_SRC_ALPHA: \ - param = GR_FUNC_MODE_X; \ - break; \ - case GL_ONE_MINUS_SRC_ALPHA: \ - case GL_ONE_MINUS_SRC_COLOR: \ - param = GR_FUNC_MODE_ONE_MINUS_X; \ - break; \ - default: \ - param = GR_FUNC_MODE_ZERO; \ - break; \ - } - -#define TEXENV_SETUP_MODE_A(param, operand) \ - switch (operand) { \ - case GL_SRC_ALPHA: \ - param = GR_FUNC_MODE_X; \ - break; \ - case GL_ONE_MINUS_SRC_ALPHA: \ - param = GR_FUNC_MODE_ONE_MINUS_X; \ - break; \ - default: \ - param = GR_FUNC_MODE_ZERO; \ - break; \ - } - - - -/* - * Setup a texture environment on Voodoo5. - * Return GL_TRUE for success, GL_FALSE for failure. - * If we fail, we'll have to use software rendering. - */ -static GLboolean -SetupTexEnvNapalm(struct gl_context *ctx, GLboolean useIteratedRGBA, - const struct gl_texture_unit *texUnit, GLenum baseFormat, - struct tdfx_texcombine_ext *env) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrTCCUColor_t incomingRGB, incomingAlpha; - const GLenum envMode = texUnit->EnvMode; - - if (useIteratedRGBA) { - incomingRGB = GR_CMBX_ITRGB; - incomingAlpha = GR_CMBX_ITALPHA; - } - else { - incomingRGB = GR_CMBX_OTHER_TEXTURE_RGB; - incomingAlpha = GR_CMBX_OTHER_TEXTURE_ALPHA; - } - - /* invariant: */ - env->Color.Shift = 0; - env->Color.Invert = FXFALSE; - env->Alpha.Shift = 0; - env->Alpha.Invert = FXFALSE; - - switch (envMode) { - case GL_REPLACE: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceA = incomingRGB; - } - else { - /* Rv = Rt */ - env->Color.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB; - } - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceD = incomingAlpha; - } - else { - /* Av = At */ - env->Alpha.SourceD = GR_CMBX_LOCAL_TEXTURE_ALPHA; - } - env->Alpha.SourceA = GR_CMBX_ITALPHA; - env->Alpha.ModeA = GR_FUNC_MODE_ZERO; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXFALSE; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_MODULATE: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - } - else { - /* Result = Frag * Tex */ - env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.InvertC = FXFALSE; - } - env->Color.SourceA = incomingRGB; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - } - else { - /* Av = Af * At */ - env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.SourceC = incomingAlpha; - env->Alpha.InvertC = FXFALSE; - } - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_DECAL: - /* -- Setup RGB combiner */ - if (baseFormat == GL_RGB) { - /* Rv = Rt */ - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_X; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - } - else { - /* Rv = Rf * (1 - At) + Rt * At */ - env->Color.SourceB = incomingRGB; - env->Color.ModeB = GR_FUNC_MODE_NEGATIVE_X; - env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Color.InvertC = FXFALSE; - env->Color.SourceD = GR_CMBX_B; - env->Color.InvertD = FXFALSE; - } - env->Color.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.ModeA = GR_FUNC_MODE_X; - /* -- Setup Alpha combiner */ - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_BLEND: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceA = incomingRGB; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - } - else { - /* Rv = Rf * (1 - Rt) + Rc * Rt */ - env->Color.SourceA = GR_CMBX_TMU_CCOLOR; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = incomingRGB; - env->Color.ModeB = GR_FUNC_MODE_NEGATIVE_X; - env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.InvertC = FXFALSE; - env->Color.SourceD = GR_CMBX_B; - env->Color.InvertD = FXFALSE; - } - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ZERO; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - } - else if (baseFormat == GL_INTENSITY) { - /* Av = Af * (1 - It) + Ac * It */ - env->Alpha.SourceA = GR_CMBX_TMU_CALPHA; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = incomingAlpha; - env->Alpha.ModeB = GR_FUNC_MODE_NEGATIVE_X; - env->Alpha.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.InvertC = FXFALSE; - env->Alpha.SourceD = GR_CMBX_B; - env->Alpha.InvertD = FXFALSE; - } - else { - /* Av = Af * At */ - env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = incomingAlpha; - env->Alpha.InvertC = FXFALSE; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - } - /* Also have to set up the tex env constant color */ - env->EnvColor = PACK_RGBA32(texUnit->EnvColor[0] * 255.0F, - texUnit->EnvColor[1] * 255.0F, - texUnit->EnvColor[2] * 255.0F, - texUnit->EnvColor[3] * 255.0F); - break; - case GL_ADD: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - } - else { - /* Rv = Rf + Tt */ - env->Color.SourceB = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.ModeB = GR_FUNC_MODE_X; - } - env->Color.SourceA = incomingRGB; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - - } - else if (baseFormat == GL_INTENSITY) { - /* Av = Af + It */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.SourceB = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_X; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - } - else { - /* Av = Af * At */ - env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = incomingAlpha; - env->Alpha.InvertC = FXFALSE; - } - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_COMBINE_EXT: - { - FxU32 A_RGB, B_RGB, C_RGB, D_RGB; - FxU32 Amode_RGB, Bmode_RGB; - FxBool Cinv_RGB, Dinv_RGB, Ginv_RGB; - FxU32 Shift_RGB; - FxU32 A_A, B_A, C_A, D_A; - FxU32 Amode_A, Bmode_A; - FxBool Cinv_A, Dinv_A, Ginv_A; - FxU32 Shift_A; - - /* - * - * In the formulas below, we write: - * o "1(x)" for the identity function applied to x, - * so 1(x) = x. - * o "0(x)" for the constant function 0, so - * 0(x) = 0 for all values of x. - * - * Calculate the color combination. - */ - Shift_RGB = texUnit->Combine.ScaleShiftRGB; - Shift_A = texUnit->Combine.ScaleShiftA; - switch (texUnit->Combine.ModeRGB) { - case GL_REPLACE: - /* - * The formula is: Arg0 - * We implement this by the formula: - * (Arg0 + 0(0))*(1-0) + 0 - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO; - Bmode_RGB = GR_FUNC_MODE_ZERO; - Cinv_RGB = FXTRUE; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_MODULATE: - /* - * The formula is: Arg0 * Arg1 - * - * We implement this by the formula - * (Arg0 + 0(0)) * Arg1 + 0(0) - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - B_RGB = GR_CMBX_ZERO; - Bmode_RGB = GR_CMBX_ZERO; - TEXENV_SETUP_ARG_RGB(C_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - Cinv_RGB = TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandRGB[1]); - D_RGB = GR_CMBX_ZERO; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_ADD: - /* - * The formula is Arg0 + Arg1 - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - TEXENV_SETUP_ARG_RGB(B_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Bmode_RGB, - texUnit->Combine.OperandRGB[1]); - C_RGB = D_RGB = GR_CMBX_ZERO; - Cinv_RGB = FXTRUE; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_ADD_SIGNED_EXT: - /* - * The formula is: Arg0 + Arg1 - 0.5. - * We compute this by calculating: - * (Arg0 - 1/2) + Arg1 if op0 is SRC_{COLOR,ALPHA} - * Arg0 + (Arg1 - 1/2) if op1 is SRC_{COLOR,ALPHA} - * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA} - * we cannot implement the formula properly. - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_ARG_RGB(B_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[0])) { - /* - * A is not inverted. So, choose it. - */ - Amode_RGB = GR_FUNC_MODE_X_MINUS_HALF; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandRGB[1])) { - Bmode_RGB = GR_FUNC_MODE_X; - } - else { - Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X; - } - } - else { - /* - * A is inverted, so try to subtract 1/2 - * from B. - */ - Amode_RGB = GR_FUNC_MODE_ONE_MINUS_X; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandRGB[1])) { - Bmode_RGB = GR_FUNC_MODE_X_MINUS_HALF; - } - else { - /* - * Both are inverted. This is the case - * we cannot handle properly. We just - * choose to not add the - 1/2. - */ - Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X; - return GL_FALSE; - } - } - C_RGB = D_RGB = GR_CMBX_ZERO; - Cinv_RGB = FXTRUE; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_INTERPOLATE_EXT: - /* - * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2). - * We compute this by the formula: - * (Arg0 - Arg1) * Arg2 + Arg1 - * == Arg0 * Arg2 - Arg1 * Arg2 + Arg1 - * == Arg0 * Arg2 + Arg1 * (1 - Arg2) - * However, if both Arg1 is ONE_MINUS_X, the HW does - * not support it properly. - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - TEXENV_SETUP_ARG_RGB(B_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - if (TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[1])) { - /* - * This case is wrong. - */ - Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X; - return GL_FALSE; - } - else { - Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X; - } - /* - * The Source/Operand for the C value must - * specify some kind of alpha value. - */ - TEXENV_SETUP_ARG_A(C_RGB, - texUnit->Combine.SourceRGB[2], - texUnit->Combine.OperandRGB[2], - incomingAlpha); - Cinv_RGB = FXFALSE; - D_RGB = GR_CMBX_B; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - default: - /* - * This is here mostly to keep from getting - * a compiler warning about these not being set. - * However, this should set all the texture values - * to zero. - */ - A_RGB = B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO; - Amode_RGB = Bmode_RGB = GR_FUNC_MODE_X; - Cinv_RGB = Dinv_RGB = Ginv_RGB = FXFALSE; - break; - } - /* - * Calculate the alpha combination. - */ - switch (texUnit->Combine.ModeA) { - case GL_REPLACE: - /* - * The formula is: Arg0 - * We implement this by the formula: - * (Arg0 + 0(0))*(1-0) + 0 - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - B_A = GR_CMBX_ITALPHA; - Bmode_A = GR_FUNC_MODE_ZERO; - C_A = D_A = GR_CMBX_ZERO; - Cinv_A = FXTRUE; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_MODULATE: - /* - * The formula is: Arg0 * Arg1 - * - * We implement this by the formula - * (Arg0 + 0(0)) * Arg1 + 0(0) - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - B_A = GR_CMBX_ZERO; - Bmode_A = GR_CMBX_ZERO; - TEXENV_SETUP_ARG_A(C_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - Cinv_A = TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandA[1]); - D_A = GR_CMBX_ZERO; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_ADD: - /* - * The formula is Arg0 + Arg1 - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - TEXENV_SETUP_ARG_A(B_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - TEXENV_SETUP_MODE_A(Bmode_A, - texUnit->Combine.OperandA[1]); - C_A = D_A = GR_CMBX_ZERO; - Cinv_A = FXTRUE; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_ADD_SIGNED_EXT: - /* - * The formula is: Arg0 + Arg1 - 0.5. - * We compute this by calculating: - * (Arg0 - 1/2) + Arg1 if op0 is SRC_{COLOR,ALPHA} - * Arg0 + (Arg1 - 1/2) if op1 is SRC_{COLOR,ALPHA} - * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA} - * we cannot implement the formula properly. - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_ARG_A(B_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandA[0])) { - /* - * A is not inverted. So, choose it. - */ - Amode_A = GR_FUNC_MODE_X_MINUS_HALF; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandA[1])) { - Bmode_A = GR_FUNC_MODE_X; - } else { - Bmode_A = GR_FUNC_MODE_ONE_MINUS_X; - } - } else { - /* - * A is inverted, so try to subtract 1/2 - * from B. - */ - Amode_A = GR_FUNC_MODE_ONE_MINUS_X; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandA[1])) { - Bmode_A = GR_FUNC_MODE_X_MINUS_HALF; - } else { - /* - * Both are inverted. This is the case - * we cannot handle properly. We just - * choose to not add the - 1/2. - */ - Bmode_A = GR_FUNC_MODE_ONE_MINUS_X; - return GL_FALSE; - } - } - C_A = D_A = GR_CMBX_ZERO; - Cinv_A = FXTRUE; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_INTERPOLATE_EXT: - /* - * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2). - * We compute this by the formula: - * (Arg0 - Arg1) * Arg2 + Arg1 - * == Arg0 * Arg2 - Arg1 * Arg2 + Arg1 - * == Arg0 * Arg2 + Arg1 * (1 - Arg2) - * However, if both Arg1 is ONE_MINUS_X, the HW does - * not support it properly. - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - TEXENV_SETUP_ARG_A(B_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandA[1])) { - Bmode_A = GR_FUNC_MODE_NEGATIVE_X; - } - else { - /* - * This case is wrong. - */ - Bmode_A = GR_FUNC_MODE_NEGATIVE_X; - return GL_FALSE; - } - /* - * The Source/Operand for the C value must - * specify some kind of alpha value. - */ - TEXENV_SETUP_ARG_A(C_A, - texUnit->Combine.SourceA[2], - texUnit->Combine.OperandA[2], - incomingAlpha); - Cinv_A = FXFALSE; - D_A = GR_CMBX_B; - Dinv_A = Ginv_A = FXFALSE; - break; - default: - /* - * This is here mostly to keep from getting - * a compiler warning about these not being set. - * However, this should set all the alpha values - * to one. - */ - A_A = B_A = C_A = D_A = GR_CMBX_ZERO; - Amode_A = Bmode_A = GR_FUNC_MODE_X; - Cinv_A = Dinv_A = FXFALSE; - Ginv_A = FXTRUE; - break; - } - /* - * Save the parameters. - */ - env->Color.SourceA = A_RGB; - env->Color.ModeA = Amode_RGB; - env->Color.SourceB = B_RGB; - env->Color.ModeB = Bmode_RGB; - env->Color.SourceC = C_RGB; - env->Color.InvertC = Cinv_RGB; - env->Color.SourceD = D_RGB; - env->Color.InvertD = Dinv_RGB; - env->Color.Shift = Shift_RGB; - env->Color.Invert = Ginv_RGB; - env->Alpha.SourceA = A_A; - env->Alpha.ModeA = Amode_A; - env->Alpha.SourceB = B_A; - env->Alpha.ModeB = Bmode_A; - env->Alpha.SourceC = C_A; - env->Alpha.InvertC = Cinv_A; - env->Alpha.SourceD = D_A; - env->Alpha.InvertD = Dinv_A; - env->Alpha.Shift = Shift_A; - env->Alpha.Invert = Ginv_A; - env->EnvColor = PACK_RGBA32(texUnit->EnvColor[0] * 255.0F, - texUnit->EnvColor[1] * 255.0F, - texUnit->EnvColor[2] * 255.0F, - texUnit->EnvColor[3] * 255.0F); - } - break; - - default: - _mesa_problem(ctx, "%s: Bad envMode", __FUNCTION__); - } - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; - - fxMesa->ColorCombineExt.SourceA = GR_CMBX_TEXTURE_RGB; - fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X, - fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_X; - fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertC = FXTRUE; - fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertD = FXFALSE; - fxMesa->ColorCombineExt.Shift = 0; - fxMesa->ColorCombineExt.Invert = FXFALSE; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - fxMesa->AlphaCombineExt.SourceA = GR_CMBX_TEXTURE_ALPHA; - fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertC = FXTRUE; - fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertD = FXFALSE; - fxMesa->AlphaCombineExt.Shift = 0; - fxMesa->AlphaCombineExt.Invert = FXFALSE; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - return GL_TRUE; /* success */ -} - - - -/* - * Setup the Voodoo3 texture environment for a single texture unit. - * Return GL_TRUE for success, GL_FALSE for failure. - * If failure, we'll use software rendering. - */ -static GLboolean -SetupSingleTexEnvVoodoo3(struct gl_context *ctx, int unit, - GLenum envMode, GLenum baseFormat) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrCombineLocal_t localc, locala; - struct tdfx_combine alphaComb, colorComb; - - if (1 /*iteratedRGBA*/) - localc = locala = GR_COMBINE_LOCAL_ITERATED; - else - localc = locala = GR_COMBINE_LOCAL_CONSTANT; - - switch (envMode) { - case GL_DECAL: - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - break; - case GL_MODULATE: - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - if (baseFormat == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_LOCAL; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - } - break; - - case GL_BLEND: - /* - * XXX we can't do real GL_BLEND mode. These settings assume that - * the TexEnv color is black and incoming fragment color is white. - */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - } - else if (baseFormat == GL_INTENSITY) { - /* Av = Af * (1 - It) + Ac * It */ - alphaComb.Function = GR_COMBINE_FUNCTION_BLEND; - alphaComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_CONSTANT; - alphaComb.Invert = FXFALSE; - } - else { - /* Av = Af * At */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - if (baseFormat == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_RGB; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_CONSTANT; - colorComb.Invert = FXTRUE; - } - fxMesa->Color.MonoColor = PACK_RGBA32( - ctx->Texture.Unit[unit].EnvColor[0] * 255.0f, - ctx->Texture.Unit[unit].EnvColor[1] * 255.0f, - ctx->Texture.Unit[unit].EnvColor[2] * 255.0f, - ctx->Texture.Unit[unit].EnvColor[3] * 255.0f); - fxMesa->dirty |= TDFX_UPLOAD_CONSTANT_COLOR; - break; - - case GL_REPLACE: - if ((baseFormat == GL_RGB) || (baseFormat == GL_LUMINANCE)) { - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - } - else { - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - if (baseFormat == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - } - break; - - case GL_ADD: - if (baseFormat == GL_ALPHA || - baseFormat == GL_LUMINANCE_ALPHA || - baseFormat == GL_RGBA) { - /* product of texel and fragment alpha */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - else if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* fragment alpha is unchanged */ - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - } - else { - ASSERT(baseFormat == GL_INTENSITY); - /* sum of texel and fragment alpha */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - if (baseFormat == GL_ALPHA) { - /* rgb unchanged */ - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - /* sum of texel and fragment rgb */ - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - } - break; - - default: { - (void) memcpy(&colorComb, &fxMesa->ColorCombine, sizeof(colorComb)); - (void) memcpy(&alphaComb, &fxMesa->AlphaCombine, sizeof(alphaComb)); - _mesa_problem(ctx, "bad texture env mode in %s", __FUNCTION__); - } - } - - if (colorComb.Function != fxMesa->ColorCombine.Function || - colorComb.Factor != fxMesa->ColorCombine.Factor || - colorComb.Local != fxMesa->ColorCombine.Local || - colorComb.Other != fxMesa->ColorCombine.Other || - colorComb.Invert != fxMesa->ColorCombine.Invert) { - fxMesa->ColorCombine = colorComb; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - } - - if (alphaComb.Function != fxMesa->AlphaCombine.Function || - alphaComb.Factor != fxMesa->AlphaCombine.Factor || - alphaComb.Local != fxMesa->AlphaCombine.Local || - alphaComb.Other != fxMesa->AlphaCombine.Other || - alphaComb.Invert != fxMesa->AlphaCombine.Invert) { - fxMesa->AlphaCombine = alphaComb; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - } - return GL_TRUE; -} - - -/* - * Setup the Voodoo3 texture environment for dual texture units. - * Return GL_TRUE for success, GL_FALSE for failure. - * If failure, we'll use software rendering. - */ -static GLboolean -SetupDoubleTexEnvVoodoo3(struct gl_context *ctx, int tmu0, - GLenum envMode0, GLenum baseFormat0, - GLenum envMode1, GLenum baseFormat1) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - const GrCombineLocal_t locala = GR_COMBINE_LOCAL_ITERATED; - const GrCombineLocal_t localc = GR_COMBINE_LOCAL_ITERATED; - const int tmu1 = 1 - tmu0; - - if (envMode0 == GL_MODULATE && envMode1 == GL_MODULATE) { - GLboolean isalpha[TDFX_NUM_TMU]; - - isalpha[tmu0] = (baseFormat0 == GL_ALPHA); - isalpha[tmu1] = (baseFormat1 == GL_ALPHA); - - if (isalpha[TDFX_TMU1]) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - if (isalpha[TDFX_TMU0]) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode0 == GL_REPLACE && envMode1 == GL_BLEND) { /* Quake */ - if (tmu0 == TDFX_TMU1) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode0 == GL_REPLACE && envMode1 == GL_MODULATE) { - /* Quake 2/3 */ - if (tmu1 == TDFX_TMU1) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXTRUE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - if (baseFormat0 == GL_RGB) { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - } - else if (envMode0 == GL_MODULATE && envMode1 == GL_ADD) { - /* Quake 3 sky */ - GLboolean isalpha[TDFX_NUM_TMU]; - - isalpha[tmu0] = (baseFormat0 == GL_ALPHA); - isalpha[tmu1] = (baseFormat1 == GL_ALPHA); - - if (isalpha[TDFX_TMU1]) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - if (isalpha[TDFX_TMU0]) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode0 == GL_REPLACE && envMode1 == GL_ADD) { - /* Vulpine sky */ - GLboolean isalpha[TDFX_NUM_TMU]; - - isalpha[tmu0] = (baseFormat0 == GL_ALPHA); - isalpha[tmu1] = (baseFormat1 == GL_ALPHA); - - if (isalpha[TDFX_TMU1]) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - - if (isalpha[TDFX_TMU0]) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } else { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode1 == GL_REPLACE) { - /* Homeworld2 */ - - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - - if ((baseFormat0 == GL_RGB) || (baseFormat0 == GL_LUMINANCE)) { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } else { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - if (baseFormat0 == GL_ALPHA) { - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->ColorCombine.Invert = FXFALSE; - } else { - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - } - } - else { - _mesa_problem(ctx, "%s: Unexpected dual texture mode encountered", __FUNCTION__); - return GL_FALSE; - } - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - return GL_TRUE; -} - - -/* - * This function makes sure that the correct mipmap levels are loaded - * in the right places in memory and then makes the Glide calls to - * setup the texture source pointers. - */ -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 struct gl_context *ctx = fxMesa->glCtx; - - /* Make sure we're not loaded incorrectly */ - if (ti->isInTM && !shared->umaTexMemory) { - /* if doing filtering between mipmap levels, alternate mipmap levels - * must be in alternate TMUs. - */ - if (ti->LODblend) { - if (ti->whichTMU != TDFX_TMU_SPLIT) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj); - } - else { - if (ti->whichTMU == TDFX_TMU_SPLIT) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj); - } - } - - /* Make sure we're loaded correctly */ - if (!ti->isInTM) { - /* Have to download the texture */ - if (shared->umaTexMemory) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); - } - else { - /* Voodoo3 (split texture memory) */ - 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->haveTwoTMUs) { - GLint memReq = fxMesa->Glide.grTexTextureMemRequired( - GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - if (shared->freeTexMem[TDFX_TMU0] > memReq) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); - } - else { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU1); - } - } - else -#endif - { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); - } - } - } - } - - if (ti->LODblend && ti->whichTMU == TDFX_TMU_SPLIT) { - /* mipmap levels split between texture banks */ - GLint u; - - if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) { - fxMesa->TexPalette.Type = ti->paltype; - fxMesa->TexPalette.Data = &(ti->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - - for (u = 0; u < 2; u++) { - 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 = ti->tm[TDFX_TMU0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD; - 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 = &(ti->info); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; - } - else { - FxU32 tmu; - - if (ti->whichTMU == TDFX_TMU_BOTH) - tmu = TDFX_TMU0; - else - tmu = ti->whichTMU; - - if (shared->umaTexMemory) { - assert(ti->whichTMU == TDFX_TMU0); - assert(tmu == TDFX_TMU0); - } - - if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) { - fxMesa->TexPalette.Type = ti->paltype; - fxMesa->TexPalette.Data = &(ti->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - - /* KW: The alternative is to do the download to the other tmu. If - * we get to this point, I think it means we are thrashing the - * texture memory, so perhaps it's not a good idea. - */ - - 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 = 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; - } - - /* Glide texture source info */ - fxMesa->TexSource[0].Info = NULL; - fxMesa->TexSource[1].Info = NULL; - if (ti->tm[tmu]) { - fxMesa->TexSource[tmu].StartAddress = ti->tm[tmu]->startAddr; - fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu].Info = &(ti->info); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; - } - } - - fxMesa->sScale0 = ti->sScale; - fxMesa->tScale0 = ti->tScale; -} - -static void -selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend) -{ - if (LODblend) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - - if (fxMesa->haveTwoTMUs) { - const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - int tmu; - - if (shared->umaTexMemory) - tmu = GR_TMU0; - else - tmu = GR_TMU1; - - fxMesa->TexCombine[tmu].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[tmu].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[tmu].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[tmu].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[tmu].InvertRGB = FXFALSE; - fxMesa->TexCombine[tmu].InvertAlpha = FXFALSE; - } - fxMesa->tmuSrc = TDFX_TMU_SPLIT; - } - else { - if (tmu != TDFX_TMU1) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - 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; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - fxMesa->tmuSrc = TDFX_TMU0; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */ - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - fxMesa->tmuSrc = TDFX_TMU1; - } - } - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; -} - -#if 0 -static void print_state(tdfxContextPtr fxMesa) -{ - struct gl_context *ctx = fxMesa->glCtx; - struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current; - GLenum base0 = tObj0->Image[0][tObj0->BaseLevel] ? tObj0->Image[0][tObj0->BaseLevel]->Format : 99; - GLenum base1 = tObj1->Image[0][tObj1->BaseLevel] ? tObj1->Image[0][tObj1->BaseLevel]->Format : 99; - - printf("Unit 0: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[0]._ReallyEnabled, - fxMesa->TexState.Enabled[0]); - 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, - fxMesa->TexState.Enabled[1]); - printf(" EnvMode: GL=0x%x Gr:0x%x\n", ctx->Texture.Unit[1].EnvMode, - fxMesa->TexState.EnvMode[1]); - printf(" BaseFmt: GL=0x%x Gr:0x%x\n", base1, fxMesa->TexState.TexFormat[1]); -} -#endif - -/* - * When we're only using a single texture unit, we always use the 0th - * Glide/hardware unit, regardless if it's GL_TEXTURE0_ARB or GL_TEXTURE1_ARB - * that's enalbed. - * Input: ctx - the context - * unit - the OpenGL texture unit to use. - */ -static void setupTextureSingleTMU(struct gl_context * ctx, GLuint unit) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - struct gl_texture_object *tObj; - int tmu; - GLenum envMode, baseFormat; - - tObj = ctx->Texture.Unit[unit]._Current; - if (tObj->Image[0][tObj->BaseLevel]->Border > 0) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE); - return; - } - - setupSingleTMU(fxMesa, tObj); - - ti = TDFX_TEXTURE_DATA(tObj); - if (ti->whichTMU == TDFX_TMU_BOTH) - tmu = TDFX_TMU0; - else - tmu = ti->whichTMU; - - if (fxMesa->tmuSrc != tmu) { - selectSingleTMUSrc(fxMesa, tmu, ti->LODblend); - } - - if (ti->reloadImages) - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES; - - /* Check if we really need to update the texenv state */ - envMode = ctx->Texture.Unit[unit].EnvMode; - baseFormat = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - - if (TDFX_IS_NAPALM(fxMesa)) { - /* see if we really need to update the unit */ - if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled || - envMode != fxMesa->TexState.EnvMode[0] || - envMode == GL_COMBINE_EXT || - baseFormat != fxMesa->TexState.TexFormat[0]*/) { - struct tdfx_texcombine_ext *otherEnv; - if (!SetupTexEnvNapalm(ctx, GL_TRUE, - &ctx->Texture.Unit[unit], baseFormat, - &fxMesa->TexCombineExt[0])) { - /* software fallback */ - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - /* disable other unit */ - otherEnv = &fxMesa->TexCombineExt[1]; - otherEnv->Color.SourceA = GR_CMBX_ZERO; - otherEnv->Color.ModeA = GR_FUNC_MODE_ZERO; - otherEnv->Color.SourceB = GR_CMBX_ZERO; - otherEnv->Color.ModeB = GR_FUNC_MODE_ZERO; - otherEnv->Color.SourceC = GR_CMBX_ZERO; - otherEnv->Color.InvertC = FXFALSE; - otherEnv->Color.SourceD = GR_CMBX_ZERO; - otherEnv->Color.InvertD = FXFALSE; - otherEnv->Color.Shift = 0; - otherEnv->Color.Invert = FXFALSE; - otherEnv->Alpha.SourceA = GR_CMBX_ITALPHA; - otherEnv->Alpha.ModeA = GR_FUNC_MODE_ZERO; - otherEnv->Alpha.SourceB = GR_CMBX_ITALPHA; - otherEnv->Alpha.ModeB = GR_FUNC_MODE_ZERO; - otherEnv->Alpha.SourceC = GR_CMBX_ZERO; - otherEnv->Alpha.InvertC = FXFALSE; - otherEnv->Alpha.SourceD = GR_CMBX_ZERO; - otherEnv->Alpha.InvertD = FXFALSE; - otherEnv->Alpha.Shift = 0; - otherEnv->Alpha.Invert = FXFALSE; - -#if 0/*JJJ*/ - fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled; - fxMesa->TexState.EnvMode[0] = envMode; - fxMesa->TexState.TexFormat[0] = baseFormat; - fxMesa->TexState.EnvMode[1] = 0; - fxMesa->TexState.TexFormat[1] = 0; -#endif - } - } - else { - /* Voodoo3 */ - - /* see if we really need to update the unit */ - if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled || - envMode != fxMesa->TexState.EnvMode[0] || - envMode == GL_COMBINE_EXT || - baseFormat != fxMesa->TexState.TexFormat[0]*/) { - if (!SetupSingleTexEnvVoodoo3(ctx, unit, envMode, baseFormat)) { - /* software fallback */ - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } -#if 0/*JJJ*/ - fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled; - fxMesa->TexState.EnvMode[0] = envMode; - fxMesa->TexState.TexFormat[0] = baseFormat; - fxMesa->TexState.EnvMode[1] = 0; - fxMesa->TexState.TexFormat[1] = 0; -#endif - } - } -} - - -static void -setupDoubleTMU(tdfxContextPtr fxMesa, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1) -{ -#define T0_NOT_IN_TMU 0x01 -#define T1_NOT_IN_TMU 0x02 -#define T0_IN_TMU0 0x04 -#define T1_IN_TMU0 0x08 -#define T0_IN_TMU1 0x10 -#define T1_IN_TMU1 0x20 - - const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - const struct gl_context *ctx = fxMesa->glCtx; - tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0); - tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1); - GLuint tstate = 0; - int tmu0 = 0, tmu1 = 1; - - if (shared->umaTexMemory) { - if (!ti0->isInTM) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0); - assert(ti0->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 (ti0->whichTMU == TDFX_TMU1) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj0); - if (ti1->whichTMU == TDFX_TMU0) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj1); - - if (ti0->isInTM) { - switch (ti0->whichTMU) { - case TDFX_TMU0: - tstate |= T0_IN_TMU0; - break; - case TDFX_TMU1: - tstate |= T0_IN_TMU1; - break; - case TDFX_TMU_BOTH: - tstate |= T0_IN_TMU0 | T0_IN_TMU1; - break; - case TDFX_TMU_SPLIT: - tstate |= T0_NOT_IN_TMU; - break; - } - } - else - tstate |= T0_NOT_IN_TMU; - - if (ti1->isInTM) { - switch (ti1->whichTMU) { - case TDFX_TMU0: - tstate |= T1_IN_TMU0; - break; - case TDFX_TMU1: - tstate |= T1_IN_TMU1; - break; - case TDFX_TMU_BOTH: - tstate |= T1_IN_TMU0 | T1_IN_TMU1; - break; - case TDFX_TMU_SPLIT: - tstate |= T1_NOT_IN_TMU; - break; - } - } - else - tstate |= T1_NOT_IN_TMU; - - /* Move texture maps into TMUs */ - - if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) || - ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) { - if (tObj0 == tObj1) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU_BOTH); - } - else { - /* Find the minimal way to correct the situation */ - if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) { - /* We have one in the standard order, setup the other */ - if (tstate & T0_IN_TMU0) { - /* T0 is in TMU0, put T1 in TMU1 */ - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1); - } - else { - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0); - } - /* tmu0 and tmu1 are setup */ - } - else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) { - /* we have one in the reverse order, setup the other */ - if (tstate & T1_IN_TMU0) { - /* T1 is in TMU0, put T0 in TMU1 */ - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU1); - } - else { - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0); - } - tmu0 = 1; - tmu1 = 0; - } - else { /* Nothing is loaded */ - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0); - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1); - /* tmu0 and tmu1 are setup */ - } - } - } - } - - ti0->lastTimeUsed = fxMesa->texBindNumber; - ti1->lastTimeUsed = fxMesa->texBindNumber; - - - if (!ctx->Texture.SharedPalette) { - if (ti0->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti0->paltype; - fxMesa->TexPalette.Data = &(ti0->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - else if (ti1->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti1->paltype; - fxMesa->TexPalette.Data = &(ti1->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - else { - fxMesa->TexPalette.Data = NULL; - } - } - - /* - * Setup Unit 0 - */ - 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 = &(ti0->info); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; - - 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 = 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; - } - - /* - * Setup Unit 1 - */ - 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 = &(ti1->info); - } - else { - 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 = &(ti1->info); - } - - 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 = 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 = ti0->sScale; - fxMesa->tScale0 = ti0->tScale; - fxMesa->sScale1 = ti1->sScale; - fxMesa->tScale1 = ti1->tScale; - -#undef T0_NOT_IN_TMU -#undef T1_NOT_IN_TMU -#undef T0_IN_TMU0 -#undef T1_IN_TMU0 -#undef T0_IN_TMU1 -#undef T1_IN_TMU1 -} - -static void setupTextureDoubleTMU(struct gl_context * ctx) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current; - tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0); - tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1); - struct gl_texture_image *baseImage0 = tObj0->Image[0][tObj0->BaseLevel]; - struct gl_texture_image *baseImage1 = tObj1->Image[0][tObj1->BaseLevel]; -#if 0/*JJJ*/ - const GLenum envMode0 = ctx->Texture.Unit[0].EnvMode; - const GLenum envMode1 = ctx->Texture.Unit[1].EnvMode; -#endif - - if (baseImage0->Border > 0 || baseImage1->Border > 0) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE); - return; - } - - setupDoubleTMU(fxMesa, tObj0, tObj1); - - if (ti0->reloadImages || ti1->reloadImages) - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES; - - fxMesa->tmuSrc = TDFX_TMU_BOTH; - - if (TDFX_IS_NAPALM(fxMesa)) { - /* Remember, Glide has its texture units numbered in backward - * order compared to OpenGL. - */ - GLboolean hw1 = GL_TRUE, hw2 = GL_TRUE; - - /* check if we really need to update glide unit 1 */ - if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled || - envMode0 != fxMesa->TexState.EnvMode[1] || - envMode0 == GL_COMBINE_EXT || - baseImage0->Format != fxMesa->TexState.TexFormat[1] || - (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) { - hw1 = SetupTexEnvNapalm(ctx, GL_TRUE, &ctx->Texture.Unit[0], - baseImage0->_BaseFormat, &fxMesa->TexCombineExt[1]); -#if 0/*JJJ*/ - fxMesa->TexState.EnvMode[1] = envMode0; - fxMesa->TexState.TexFormat[1] = baseImage0->_BaseFormat; - fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled; -#endif - } - - /* check if we really need to update glide unit 0 */ - if (1/*fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled || - envMode1 != fxMesa->TexState.EnvMode[0] || - envMode1 == GL_COMBINE_EXT || - baseImage1->_BaseFormat != fxMesa->TexState.TexFormat[0] || - (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) { - hw2 = SetupTexEnvNapalm(ctx, GL_FALSE, &ctx->Texture.Unit[1], - baseImage1->_BaseFormat, &fxMesa->TexCombineExt[0]); -#if 0/*JJJ*/ - fxMesa->TexState.EnvMode[0] = envMode1; - fxMesa->TexState.TexFormat[0] = baseImage1->_BaseFormat; - fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled; -#endif - } - - - if (!hw1 || !hw2) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - } - else { - int unit0, unit1; - if ((ti0->whichTMU == TDFX_TMU1) || (ti1->whichTMU == TDFX_TMU0)) - unit0 = 1; - else - unit0 = 0; - unit1 = 1 - unit0; - - if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled || - fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled || - envMode0 != fxMesa->TexState.EnvMode[unit0] || - envMode0 == GL_COMBINE_EXT || - envMode1 != fxMesa->TexState.EnvMode[unit1] || - envMode1 == GL_COMBINE_EXT || - baseImage0->_BaseFormat != fxMesa->TexState.TexFormat[unit0] || - baseImage1->_BaseFormat != fxMesa->TexState.TexFormat[unit1] || - (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) { - - if (!SetupDoubleTexEnvVoodoo3(ctx, unit0, - ctx->Texture.Unit[0].EnvMode, baseImage0->_BaseFormat, - ctx->Texture.Unit[1].EnvMode, baseImage1->_BaseFormat)) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - -#if 0/*JJJ*/ - fxMesa->TexState.EnvMode[unit0] = envMode0; - fxMesa->TexState.TexFormat[unit0] = baseImage0->_BaseFormat; - fxMesa->TexState.EnvMode[unit1] = envMode1; - fxMesa->TexState.TexFormat[unit1] = baseImage1->_BaseFormat; - fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled; - fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled; -#endif - } - } -} - - -void -tdfxUpdateTextureState( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_FALSE); - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_FALSE); - - if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[1]._ReallyEnabled == 0) { - LOCK_HARDWARE( fxMesa ); /* XXX remove locking eventually */ - setupTextureSingleTMU(ctx, 0); - UNLOCK_HARDWARE( fxMesa ); - } - else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 && - ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - LOCK_HARDWARE( fxMesa ); - setupTextureSingleTMU(ctx, 1); - UNLOCK_HARDWARE( fxMesa ); - } - else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - LOCK_HARDWARE( fxMesa ); - setupTextureDoubleTMU(ctx); - UNLOCK_HARDWARE( fxMesa ); - } - else { - /* 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; - fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertC = FXTRUE; - fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertD = FXFALSE; - fxMesa->ColorCombineExt.Shift = 0; - fxMesa->ColorCombineExt.Invert = FXFALSE; - fxMesa->AlphaCombineExt.SourceA = GR_CMBX_ITALPHA; - fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertC = FXTRUE; - fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertD = FXFALSE; - fxMesa->AlphaCombineExt.Shift = 0; - fxMesa->AlphaCombineExt.Invert = FXFALSE; - } - else { - /* Voodoo 3*/ - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - - fxMesa->TexState.Enabled[0] = 0; - fxMesa->TexState.Enabled[1] = 0; - fxMesa->TexState.EnvMode[0] = 0; - fxMesa->TexState.EnvMode[1] = 0; - - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - - if (ctx->Texture.Unit[0]._ReallyEnabled != 0 || - ctx->Texture.Unit[1]._ReallyEnabled != 0) { - /* software texture (cube map, rect tex, etc */ - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - } -} - - - -/* - * 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( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current; - 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 = ti0->paltype; - fxMesa->TexPalette.Data = &(ti0->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - else if (ti1 && ti1->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti1->paltype; - fxMesa->TexPalette.Data = &(ti1->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - } - if (ti1) { - fxMesa->sScale1 = ti1->sScale; - fxMesa->tScale1 = ti1->tScale; - } - - if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[0]._ReallyEnabled == 0) { - /* Only unit 0 2D enabled */ - if (shared->umaTexMemory) { - assert(ti0); - fxMesa->TexSource[0].StartAddress = ti0->tm[0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[0].Info = &(ti0->info); - } - else { - assert(ti0); - 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 = &(ti0->info); - fxMesa->TexSource[1].StartAddress = ti0->tm[TDFX_TMU1]->startAddr; - fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN; - 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 (ti0->tm[tmu]) { - fxMesa->TexSource[tmu].StartAddress = ti0->tm[tmu]->startAddr; - fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu].Info = &(ti0->info); - } - } - } - } - else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 && - ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - /* Only unit 1 2D enabled */ - if (shared->umaTexMemory) { - fxMesa->TexSource[0].StartAddress = ti1->tm[0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[0].Info = &(ti1->info); - } - } - else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - /* Both 2D enabled */ - if (shared->umaTexMemory) { - const FxU32 tmu0 = 0, tmu1 = 1; - - assert(ti0); - fxMesa->TexSource[tmu0].StartAddress = ti0->tm[0]->startAddr; - fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu0].Info = &(ti0->info); - - assert(ti1); - fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr; - fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu1].Info = &(ti1->info); - } - else { - const FxU32 tmu0 = 0, tmu1 = 1; - - assert(ti0); - fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr; - fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu0].Info = &(ti0->info); - - assert(ti1); - fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr; - fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu1].Info = &(ti1->info); - } - } - - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texstate.h b/src/mesa/drivers/dri/tdfx/tdfx_texstate.h deleted file mode 100644 index 92ac3a37eb9..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_texstate.h +++ /dev/null @@ -1,43 +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. - */ - -/* - * Original rewrite: - * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes <[email protected]> - * Brian Paul <[email protected]> - * - */ - -#ifndef __TDFX_TEXSTATE_H__ -#define __TDFX_TEXSTATE_H__ - -extern void tdfxUpdateTextureState( struct gl_context *ctx ); -extern void tdfxUpdateTextureBinding( struct gl_context *ctx ); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/src/mesa/drivers/dri/tdfx/tdfx_tris.c deleted file mode 100644 index 1f8cf6cde19..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_tris.c +++ /dev/null @@ -1,1291 +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. - */ - -/* New fixes: - * Daniel Borca <[email protected]>, 19 Jul 2004 - * - * Authors: - * Keith Whitwell <[email protected]> - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/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( struct gl_context *ctx, GLenum prim ); -static void tdfxRenderPrimitive( struct gl_context *ctx, GLenum prim ); - -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 -}; - -/*********************************************************************** - * 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 { \ - tdfxVertex *_v_[4]; \ - _v_[0] = d; \ - _v_[1] = a; \ - _v_[2] = b; \ - _v_[3] = c; \ - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ - /*fxMesa->Glide.grDrawTriangle( a, b, d );*/\ - /*fxMesa->Glide.grDrawTriangle( b, c, d );*/\ - } \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_line( fxMesa, v0, v1 ); \ - else { \ - v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \ - v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \ - v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \ - v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \ - fxMesa->Glide.grDrawLine( v0, v1 ); \ - v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \ - v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \ - v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \ - v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \ - } \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_point( fxMesa, v0 ); \ - else { \ - v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \ - v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \ - fxMesa->Glide.grDrawPoint( v0 ); \ - v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \ - v0->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( struct gl_context *ctx, const tdfxVertex *src, SWvertex *dst) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) { - dst->attrib[FRAG_ATTRIB_WPOS][0] = src->x - fxMesa->x_offset; - dst->attrib[FRAG_ATTRIB_WPOS][1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset); - dst->attrib[FRAG_ATTRIB_WPOS][2] = src->z; - dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0; - - dst->color[0] = src->color[2]; - dst->color[1] = src->color[1]; - dst->color[2] = src->color[0]; - dst->color[3] = src->color[3]; - } - else { - GLfloat w = 1.0 / src->rhw; - - dst->attrib[FRAG_ATTRIB_WPOS][0] = src->x - fxMesa->x_offset; - dst->attrib[FRAG_ATTRIB_WPOS][1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset); - dst->attrib[FRAG_ATTRIB_WPOS][2] = src->z; - dst->attrib[FRAG_ATTRIB_WPOS][3] = src->rhw; - - dst->color[0] = src->color[2]; - dst->color[1] = src->color[1]; - dst->color[2] = src->color[0]; - dst->color[3] = src->color[3]; - - dst->attrib[FRAG_ATTRIB_TEX0][0] = 1.0 / fxMesa->sScale0 * w * src->tu0; - dst->attrib[FRAG_ATTRIB_TEX0][1] = 1.0 / fxMesa->tScale0 * w * src->tv0; - if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ1 || fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) { - dst->attrib[FRAG_ATTRIB_TEX0][3] = w * src->tq0; - } else { - dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0; - } - - if (fxMesa->SetupIndex & TDFX_TEX1_BIT) { - dst->attrib[FRAG_ATTRIB_TEX1][0] = 1.0 / fxMesa->sScale1 * w * src->tu1; - dst->attrib[FRAG_ATTRIB_TEX1][1] = 1.0 / fxMesa->tScale1 * w * src->tv1; - if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) { - dst->attrib[FRAG_ATTRIB_TEX1][3] = w * src->tq1; - } else { - dst->attrib[FRAG_ATTRIB_TEX1][3] = 1.0; - } - } - } - - dst->pointSize = ctx->Point.Size; -} - - -static void -tdfx_fallback_tri( tdfxContextPtr fxMesa, - tdfxVertex *v0, - tdfxVertex *v1, - tdfxVertex *v2 ) -{ - struct gl_context *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 ) -{ - struct gl_context *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 ) -{ - struct gl_context *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( struct gl_context *ctx, const tdfxVertex *v ) -{ - tdfxContextPtr tmesa = TDFX_CONTEXT( ctx ); - - fprintf(stderr, "vertex at %p\n", (void *)v); - - if (tmesa->vertexFormat == TDFX_LAYOUT_TINY) { - fprintf(stderr, "x %f y %f z %f\n", v->x, v->y, v->z); - } - else { - fprintf(stderr, "x %f y %f z %f oow %f\n", - v->x, v->y, v->z, v->rhw); - } - fprintf(stderr, "r %d g %d b %d a %d\n", - v->color[0], - v->color[1], - v->color[2], - v->color[3]); - - 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_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 { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[TDFX_MAX_TRIFUNC]; - -#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_SPEC 0 -#define HAVE_HW_FLATSHADE 0 -#define HAVE_BACK_COLORS 0 -#define VERTEX tdfxVertex -#define TAB rast_tab - -#define DEPTH_SCALE 1.0 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) _v->x -#define VERT_Y(_v) _v->y -#define VERT_Z(_v) _v->z -#define AREA_IS_CCW( a ) (a < 0) -#define GET_VERTEX(e) (fxMesa->verts + (e)) - -#define VERT_SET_RGBA( dst, f ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[2], f[0]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[1], f[1]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[0], f[2]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[3], f[3]);\ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) \ - *(GLuint *)&v0->color = *(GLuint *)&v1->color - -#define VERT_SAVE_RGBA( idx ) \ - *(GLuint *)&color[idx] = *(GLuint *)&v[idx]->color - -#define VERT_RESTORE_RGBA( idx ) \ - *(GLuint *)&v[idx]->color = *(GLuint *)&color[idx] - -#define LOCAL_VARS(n) \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - GLubyte color[n][4]; \ - (void) color; - - - -/*********************************************************************** - * Functions to draw basic unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (fxMesa->raster_primitive != reduced_prim[x]) \ - tdfxRasterPrimitive( ctx, reduced_prim[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 "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#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_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 "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_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_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_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_fallback_flat -#include "tnl_dd/t_dd_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(); -} - - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - - -/* Accelerate vertex buffer rendering when renderindex == 0 and - * there is no clipping. - */ -#define INIT(x) tdfxRenderPrimitive( ctx, x ) - -static void tdfx_render_vb_points( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - INIT(GL_POINTS); - - /* Adjust point coords */ - for (i = start; i < count; i++) { - fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_POINTS, count-start, - fxVB + start, sizeof(tdfxVertex)); - /* restore point coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_line_strip( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - INIT(GL_LINE_STRIP); - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start, - fxVB + start, sizeof(tdfxVertex) ); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_line_loop( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - GLint j = start; - (void) flags; - - INIT(GL_LINE_LOOP); - - if (!(flags & PRIM_BEGIN)) { - j++; - } - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j, - fxVB + j, sizeof(tdfxVertex)); - - if (flags & PRIM_END) - fxMesa->Glide.grDrawLine( fxVB + (count - 1), - fxVB + start ); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_lines( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - INIT(GL_LINES); - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINES, count-start, - fxVB + start, sizeof(tdfxVertex)); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_triangles( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_TRIANGLES); - -#if 0 - /* [dBorca] - * apparently, this causes troubles with some programs (GLExcess); - * might be a bug in Glide... However, "grDrawVertexArrayContiguous" - * eventually calls "grDrawTriangle" for GR_TRIANGLES, so we're better - * off doing it by hand... - */ - fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLES, count-start, - fxVB + start, sizeof(tdfxVertex)); -#else - { - GLuint j; - for (j=start+2; j<count; j+=3) { - fxMesa->Glide.grDrawTriangle(fxVB + (j-2), fxVB + (j-1), fxVB + j); - } - } -#endif -} - - -static void tdfx_render_vb_tri_strip( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - int mode; - (void) flags; - - INIT(GL_TRIANGLE_STRIP); - -/* fprintf(stderr, "%s/%d\n", __FUNCTION__, 1<<shift); */ -/* if(!prevLockLine) abort(); */ - - mode = GR_TRIANGLE_STRIP; - - fxMesa->Glide.grDrawVertexArrayContiguous( mode, count-start, - fxVB + start, sizeof(tdfxVertex)); -} - - -static void tdfx_render_vb_tri_fan( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_TRIANGLE_FAN); - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start, - fxVB + start, sizeof(tdfxVertex) ); -} - -static void tdfx_render_vb_quads( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLuint i; - (void) flags; - - INIT(GL_QUADS); - - for (i = start + 3 ; i < count ; i += 4 ) { -#define VERT(x) (fxVB + (x)) - tdfxVertex *_v_[4]; - _v_[0] = VERT(i); - _v_[1] = VERT(i-3); - _v_[2] = VERT(i-2); - _v_[3] = VERT(i-1); - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_); - /*fxMesa->Glide.grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/ - /*fxMesa->Glide.grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/ -#undef VERT - } -} - -static void tdfx_render_vb_quad_strip( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_QUAD_STRIP); - - count -= (count-start)&1; - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, - count-start, fxVB + start, sizeof(tdfxVertex)); -} - -static void tdfx_render_vb_poly( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_POLYGON); - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_POLYGON, count-start, - fxVB + start, sizeof(tdfxVertex)); -} - -static void tdfx_render_vb_noop( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - (void) (ctx && start && count && flags); -} - -static void (*tdfx_render_tab_verts[GL_POLYGON+2])(struct gl_context *, - 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, -}; -#undef INIT - - -/**********************************************************************/ -/* Render whole (indexed) begin/end objects */ -/**********************************************************************/ - - -#define VERT(x) (tdfxVertex *)(vertptr + (x)) - -#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 ) \ - do { \ - tdfxVertex *_v_[4]; \ - _v_[0] = VERT(v3); \ - _v_[1] = VERT(v0); \ - _v_[2] = VERT(v1); \ - _v_[3] = VERT(v2); \ - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ - /*fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\ - /*fxMesa->Glide.grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\ - } while (0) - -#define INIT(x) tdfxRenderPrimitive( ctx, x ) - -#undef LOCAL_VARS -#define LOCAL_VARS \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - tdfxVertex *vertptr = fxMesa->verts; \ - 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 -#define ELT(x) elt[x] -#include "tnl_dd/t_dd_rendertmp.h" - -/* Verts, no clipping. - */ -#undef ELT -#undef TAG -#define TAG(x) tdfx_##x##_verts -#define ELT(x) x -/*#include "tnl_dd/t_dd_rendertmp.h"*/ - - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - - - -static void tdfxRenderClippedPoly( struct gl_context *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 ); -} - -static void tdfxRenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -static void tdfxFastRenderClippedPoly( struct gl_context *ctx, const GLuint *elts, - GLuint n ) -{ - int i; - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - tdfxVertex *vertptr = fxMesa->verts; - if (n == 3) { - fxMesa->Glide.grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) ); - } else if (n <= 32) { - tdfxVertex *newvptr[32]; - for (i = 0 ; i < n ; i++) { - newvptr[i] = VERT(elts[i]); - } - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr); - } else { - const tdfxVertex *start = VERT(elts[0]); - for (i = 2 ; i < n ; i++) { - fxMesa->Glide.grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) ); - } - } -} - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - -#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(struct gl_context *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 (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; - } - - 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 (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; - } - } -} - -/**********************************************************************/ -/* Use multipass rendering for cliprects */ -/**********************************************************************/ - - - -/* TODO: Benchmark this. - * TODO: Use single back-buffer cliprect where possible. - * NOTE: <pass> starts at 1, not zero! - */ -static GLboolean multipass_cliprect( struct gl_context *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( struct gl_context *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( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - tdfxCheckTexSizes( ctx ); - - 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; -} - - - -/* Always called between RenderStart and RenderFinish --> We already - * hold the lock. - */ -static void tdfxRasterPrimitive( struct gl_context *ctx, GLenum prim ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - 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( struct gl_context *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( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (fxMesa->RenderIndex & TDFX_FALLBACK_BIT) - _swrast_flush( ctx ); - - UNLOCK_HARDWARE(fxMesa); -} - - -/**********************************************************************/ -/* Manage total rasterization fallbacks */ -/**********************************************************************/ - -static char *fallbackStrings[] = { - "3D/Rect/Cube 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", - "Rasterization disable" -}; - - -static char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - - -void tdfxFallback( struct gl_context *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 (TDFX_DEBUG & DEBUG_VERBOSE_FALL) { - 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 (TDFX_DEBUG & DEBUG_VERBOSE_FALL) { - fprintf(stderr, "Tdfx end software fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } -} - - -void tdfxDDInitTriFuncs( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_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; - - (void) tdfx_print_vertex; -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.h b/src/mesa/drivers/dri/tdfx/tdfx_tris.h deleted file mode 100644 index 421b8e1c0d7..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_tris.h +++ /dev/null @@ -1,41 +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. - */ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - */ - -#ifndef TDFX_TRIS_INC -#define TDFX_TRIS_INC - -#include "main/mtypes.h" - -extern void tdfxDDInitTriFuncs( struct gl_context *ctx ); - - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_vb.c b/src/mesa/drivers/dri/tdfx/tdfx_vb.c deleted file mode 100644 index dafb6eccd99..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_vb.c +++ /dev/null @@ -1,347 +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. - * - * - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "tdfx_context.h" -#include "tdfx_vb.h" -#include "tdfx_render.h" - -static void copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - tdfxVertex *dst = fxMesa->verts + edst; - tdfxVertex *src = fxMesa->verts + esrc; - *(GLuint *)&dst->color = *(GLuint *)&src->color; -} - -static struct { - void (*emit)( struct gl_context *, GLuint, GLuint, void * ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( struct gl_context *ctx ); - GLuint vertex_format; -} setup_tab[TDFX_MAX_SETUP]; - - - - -#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) - - -static void interp_extras( struct gl_context *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /*fprintf(stderr, "%s\n", __FUNCTION__);*/ - - if (VB->BackfaceColorPtr) { - INTERP_4F( t, - GET_COLOR(VB->BackfaceColorPtr, dst), - GET_COLOR(VB->BackfaceColorPtr, out), - GET_COLOR(VB->BackfaceColorPtr, in) ); - } - - if (VB->EdgeFlag) { - VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; - } - - setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in, - force_boundary); -} - -static void copy_pv_extras( struct gl_context *ctx, GLuint dst, GLuint src ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->BackfaceColorPtr) { - COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst), - GET_COLOR(VB->BackfaceColorPtr, src) ); - } - - setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src); -} - - - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT) -#define TAG(x) x##_wg -#include "tdfx_vbtmp.h" - -/* Special for tdfx: fog requires w - */ -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT) -#define TAG(x) x##_wg_fog -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tdfx_vbtmp.h" - -#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" - -#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" - -#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" - -#define IND (TDFX_RGBA_BIT) -#define TAG(x) x##_g -#include "tdfx_vbtmp.h" - -#define IND (TDFX_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_TEX0_BIT|TDFX_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "tdfx_vbtmp.h" - - -/* fogc { */ -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgf -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgt0f -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgt0t1f -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgpt0f -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\ - TDFX_PTEX_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgpt0t1f -#include "tdfx_vbtmp.h" -/* fogc } */ - - -static void init_setup_tab( void ) -{ - init_wg(); - init_wg_fog(); - init_wgt0(); - init_wgt0t1(); - init_wgpt0(); - init_wgpt0t1(); - - init_g(); - init_t0(); - init_t0t1(); - init_gt0(); - init_gt0t1(); - - /* fogcoord */ - init_wgf(); - init_wgt0f(); - init_wgt0t1f(); - init_wgpt0f(); - init_wgpt0t1f(); -} - - -void tdfxPrintSetupFlags(char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%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," : "", - (flags & TDFX_FOGC_BIT) ? " fogc," : ""); -} - - - -void tdfxCheckTexSizes( struct gl_context *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; - - /* 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 tdfxBuildVertices( struct gl_context *ctx, GLuint start, GLuint end, - GLuint newinputs ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - tdfxVertex *v = fxMesa->verts + start; - - newinputs |= fxMesa->SetupNewInputs; - fxMesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= TDFX_RGBA_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= TDFX_FOGC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= TDFX_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= TDFX_TEX0_BIT|TDFX_TEX1_BIT; - - if (fxMesa->SetupIndex & TDFX_PTEX_BIT) - ind = ~0; - - ind &= fxMesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, end, v ); - } - } -} - - -void tdfxChooseVertexState( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - GLuint ind = TDFX_XYZ_BIT|TDFX_RGBA_BIT; - - fxMesa->tmu_source[0] = 0; - fxMesa->tmu_source[1] = 1; - - if (ctx->Texture._EnabledUnits & 0x2) { - if (ctx->Texture._EnabledUnits & 0x1) { - ind |= TDFX_TEX1_BIT; - } - ind |= TDFX_W_BIT|TDFX_TEX0_BIT; - fxMesa->tmu_source[0] = 1; - fxMesa->tmu_source[1] = 0; - } else if (ctx->Texture._EnabledUnits & 0x1) { - /* unit 0 enabled */ - ind |= TDFX_W_BIT|TDFX_TEX0_BIT; - } else if (fxMesa->Fog.Mode != GR_FOG_DISABLE) { - ind |= TDFX_W_BIT; - } - - if (fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT) { - ind |= TDFX_FOGC_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; - } - - if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) { - FLUSH_BATCH(fxMesa); - fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT; - fxMesa->vertexFormat = setup_tab[ind].vertex_format; - } -} - - - -void tdfxInitVB( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - - fxMesa->verts = _mesa_align_malloc(size * sizeof(tdfxVertex), 32); - fxMesa->vertexFormat = TDFX_LAYOUT_TINY; - fxMesa->SetupIndex = TDFX_XYZ_BIT|TDFX_RGBA_BIT; -} - - -void tdfxFreeVB( struct gl_context *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - if (fxMesa->verts) { - _mesa_align_free(fxMesa->verts); - fxMesa->verts = 0; - } -} diff --git a/src/mesa/drivers/dri/tdfx/tdfx_vb.h b/src/mesa/drivers/dri/tdfx/tdfx_vb.h deleted file mode 100644 index 238a076d87a..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_vb.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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"), - * 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. - * - * - */ - -#ifndef TDFXVB_INC -#define TDFXVB_INC - -#include "main/mtypes.h" - -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "math/m_xform.h" - -#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_FOGC_BIT 0x40 -#define TDFX_MAX_SETUP 0x80 - -#define _TDFX_NEW_RASTERSETUP (_NEW_TEXTURE | \ - _DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _NEW_FOG) - - -extern void tdfxValidateBuildProjVerts(struct gl_context *ctx, - GLuint start, GLuint count, - GLuint newinputs ); - -extern void tdfxPrintSetupFlags(char *msg, GLuint flags ); - -extern void tdfxInitVB( struct gl_context *ctx ); - -extern void tdfxFreeVB( struct gl_context *ctx ); - -extern void tdfxCheckTexSizes( struct gl_context *ctx ); - -extern void tdfxChooseVertexState( struct gl_context *ctx ); - -extern void tdfxBuildVertices( struct gl_context *ctx, GLuint start, GLuint end, - GLuint newinputs ); - -#endif diff --git a/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h b/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h deleted file mode 100644 index c593ce05eae..00000000000 --- a/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Authors: - * Keith Whitwell <[email protected]> - * Daniel Borca <[email protected]> - */ - - -#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] -#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] -#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] - - -static void TAG(emit)( struct gl_context *ctx, - GLuint start, GLuint end, - void *dest ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLuint tmu0_source = fxMesa->tmu_source[0]; - GLuint tmu1_source = fxMesa->tmu_source[1]; - GLfloat (*tc0)[4], (*tc1)[4]; - GLfloat (*col)[4]; - GLuint tc0_stride, tc1_stride, col_stride; - GLuint tc0_size, tc1_size, col_size; - GLfloat (*proj)[4] = VB->NdcPtr->data; - GLuint proj_stride = VB->NdcPtr->stride; - GLfloat (*fog)[4]; - GLuint fog_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__); */ - - if (IND & TDFX_TEX0_BIT) { - tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->stride; - tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->data; - u0scale = fxMesa->sScale0; - v0scale = fxMesa->tScale0; - if (IND & TDFX_PTEX_BIT) - tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->size; - } - - if (IND & TDFX_TEX1_BIT) { - tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->data; - tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->stride; - u1scale = fxMesa->sScale1; - v1scale = fxMesa->tScale1; - if (IND & TDFX_PTEX_BIT) - tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->size; - } - - if (IND & TDFX_RGBA_BIT) { - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; - col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size; - } - - if (IND & TDFX_FOGC_BIT) { - fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data; - fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride; - } - - { - /* 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_4F(col, start * col_stride); - if (IND & TDFX_FOGC_BIT) - STRIDE_4F(fog, start * fog_stride); - } - - for (i=start; i < end; i++, v++) { - if (IND & TDFX_XYZ_BIT) { - if (mask[i] == 0) { - /* unclipped */ - VIEWPORT_X(v->x, proj[0][0]); - VIEWPORT_Y(v->y, proj[0][1]); - VIEWPORT_Z(v->z, proj[0][2]); - v->rhw = proj[0][3]; - } else { - /* clipped */ - v->rhw = 1.0; - } - proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); - } - if (IND & TDFX_RGBA_BIT) { - UNCLAMPED_FLOAT_TO_UBYTE(v->color[0], col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(v->color[1], col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(v->color[2], col[0][0]); - if (col_size == 4) { - UNCLAMPED_FLOAT_TO_UBYTE(v->color[3], col[0][3]); - } else { - v->color[3] = 255; - } - STRIDE_4F(col, col_stride); - } - if (IND & TDFX_FOGC_BIT) { - v->fog = CLAMP(fog[0][0], 0.0f, 1.0f); - STRIDE_4F(fog, fog_stride); - } - if (IND & TDFX_TEX0_BIT) { - GLfloat w = v->rhw; - v->tu0 = tc0[0][0] * u0scale * w; - v->tv0 = tc0[0][1] * v0scale * w; - if (IND & TDFX_PTEX_BIT) { - v->tq0 = w; - if (tc0_size == 4) - v->tq0 = tc0[0][3] * w; - } - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); - } - if (IND & TDFX_TEX1_BIT) { - GLfloat w = v->rhw; - v->tu1 = tc1[0][0] * u1scale * w; - v->tv1 = tc1[0][1] * v1scale * w; - if (IND & TDFX_PTEX_BIT) { - v->tq1 = w; - if (tc1_size == 4) - v->tq1 = tc1[0][3] * w; - } - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); - } - } - } -} - - -static GLboolean TAG(check_tex_sizes)( struct gl_context *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->AttribPtr[_TNL_ATTRIB_TEX0] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1]; - - if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4) - return GL_FALSE; - } - - if (VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) - return GL_FALSE; - } - - return GL_TRUE; -} - - -static void TAG(interp)( struct gl_context *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 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; - tdfxVertex *dst = fxMesa->verts + edst; - const tdfxVertex *out = fxMesa->verts + eout; - const tdfxVertex *in = fxMesa->verts + ein; - const GLfloat wout = oow / out->rhw; - const GLfloat win = oow / in->rhw; - - VIEWPORT_X(dst->x, dstclip[0] * oow); - VIEWPORT_Y(dst->y, dstclip[1] * oow); - VIEWPORT_Z(dst->z, dstclip[2] * oow); - dst->rhw = oow; - - INTERP_UB( t, dst->color[0], out->color[0], in->color[0] ); - INTERP_UB( t, dst->color[1], out->color[1], in->color[1] ); - INTERP_UB( t, dst->color[2], out->color[2], in->color[2] ); - INTERP_UB( t, dst->color[3], out->color[3], in->color[3] ); - - if (IND & TDFX_FOGC_BIT) { - INTERP_F( t, dst->fog, out->fog, in->fog ); - } - - if (IND & TDFX_TEX0_BIT) { - INTERP_F( t, dst->tu0, out->tu0 * wout, in->tu0 * win ); - INTERP_F( t, dst->tv0, out->tv0 * wout, in->tv0 * win ); - if (IND & TDFX_PTEX_BIT) { - INTERP_F( t, dst->tq0, out->tq0 * wout, in->tq0 * win ); - } - } - if (IND & TDFX_TEX1_BIT) { - INTERP_F( t, dst->tu1, out->tu1 * wout, in->tu1 * win ); - INTERP_F( t, dst->tv1, out->tv1 * wout, in->tv1 * win ); - if (IND & TDFX_PTEX_BIT) { - INTERP_F( t, dst->tq1, out->tq1 * wout, in->tq1 * win ); - } - } -} - - -static void TAG(init)( void ) -{ -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - setup_tab[IND].emit = TAG(emit); - setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); - setup_tab[IND].interp = TAG(interp); - setup_tab[IND].copy_pv = copy_pv; - - if (IND & TDFX_TEX1_BIT) { - if (IND & TDFX_PTEX_BIT) { - setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ2; - } - else { - setup_tab[IND].vertex_format = TDFX_LAYOUT_MULTI; - } - } - else if (IND & TDFX_TEX0_BIT) { - if (IND & TDFX_PTEX_BIT) { - setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ1; - } else { - setup_tab[IND].vertex_format = TDFX_LAYOUT_SINGLE; - } - } - else if (IND & TDFX_W_BIT) { - setup_tab[IND].vertex_format = TDFX_LAYOUT_NOTEX; - } else { - setup_tab[IND].vertex_format = TDFX_LAYOUT_TINY; - } -} - - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/unichrome/Makefile b/src/mesa/drivers/dri/unichrome/Makefile deleted file mode 100644 index 373da6016e4..00000000000 --- a/src/mesa/drivers/dri/unichrome/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# src/mesa/drivers/dri/unichrome/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = unichrome_dri.so - -include ../Makefile.defines - -DRIVER_SOURCES = \ - via_context.c \ - via_fb.c \ - via_tex.c \ - via_ioctl.c \ - via_memcpy.c \ - via_render.c \ - via_screen.c \ - via_span.c \ - via_state.c \ - via_texcombine.c \ - via_tris.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - - -include ../Makefile.targets - diff --git a/src/mesa/drivers/dri/unichrome/server/via.h b/src/mesa/drivers/dri/unichrome/server/via.h deleted file mode 100644 index 2cfe6631efb..00000000000 --- a/src/mesa/drivers/dri/unichrome/server/via.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __VIA_H__ -#define __VIA_H__ - -typedef struct VIAInfo -{ - size_t registerSize; - void * registerHandle; - void * data; -} * VIAInfoPtr; - -#endif /* __VIA_H__ */ diff --git a/src/mesa/drivers/dri/unichrome/server/via_dri.h b/src/mesa/drivers/dri/unichrome/server/via_dri.h deleted file mode 100644 index c6eed03c1c9..00000000000 --- a/src/mesa/drivers/dri/unichrome/server/via_dri.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -/* - * Keep this file in perfect sync between the ddx and dri drivers. - * At least bump the VIA_DRIDDX_VERSION defines appropriately. - * - */ -#ifndef _VIA_DRI_H_ -#define _VIA_DRI_H_ 1 - -#define VIA_MAX_DRAWABLES 256 - -#define VIA_DRIDDX_VERSION_MAJOR 5 -#define VIA_DRIDDX_VERSION_MINOR 0 -#define VIA_DRIDDX_VERSION_PATCH 0 - -typedef int Bool; - -typedef struct { - drm_handle_t handle; - drmSize size; -} viaRegion, *viaRegionPtr; - -typedef struct { - viaRegion regs, agp; - int deviceID; - int width; - int height; - int mem; - int bytesPerPixel; - int priv1; - int priv2; - int fbOffset; - int fbSize; - Bool drixinerama; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; - int irqEnabled; - unsigned int scrnX, scrnY; - int sarea_priv_offset; - int ringBufActive; - unsigned int reg_pause_addr; -} VIADRIRec, *VIADRIPtr; - -typedef struct { - int dummy; -} VIAConfigPrivRec, *VIAConfigPrivPtr; - -typedef struct { - int dummy; -} VIADRIContextRec, *VIADRIContextPtr; - -#endif /* _VIA_DRI_H_ */ diff --git a/src/mesa/drivers/dri/unichrome/server/via_driver.h b/src/mesa/drivers/dri/unichrome/server/via_driver.h deleted file mode 100644 index cd3b038bfd9..00000000000 --- a/src/mesa/drivers/dri/unichrome/server/via_driver.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIA_DRIVER_H -#define _VIA_DRIVER_H - -#if 0 /* DEBUG is use in VIA DRI code as a flag */ -/* #define DEBUG_PRINT */ -#ifdef DEBUG_PRINT -#define DEBUG(x) x -#else -#define DEBUG(x) -#endif -#endif - -#if 0 -#include "vgaHW.h" -#include "xf86.h" -#include "xf86Resources.h" -#include "xf86_ansic.h" -#include "xf86Pci.h" -#include "xf86PciInfo.h" -#include "xf86_OSproc.h" -#include "compiler.h" -#include "xf86Cursor.h" -#include "mipointer.h" -#include "micmap.h" - -#define USE_FB -#ifdef USE_FB -#include "fb.h" -#else -#include "cfb.h" -#include "cfb16.h" -#include "cfb32.h" -#endif - -#include "xf86cmap.h" -#include "vbe.h" -#include "xaa.h" - -#include "via_regs.h" -#include "via_bios.h" -#include "via_gpioi2c.h" -#include "via_priv.h" -#include "ginfo.h" - -#ifdef XF86DRI -#define _XF86DRI_SERVER_ -#include "sarea.h" -#include "dri.h" -#include "GL/glxint.h" -#include "via_dri.h" -#endif -#else -#include "via_regs.h" - -#include "GL/internal/dri_interface.h" -#include "via_dri.h" -#endif - -/* _SOLO : copied from via_bios.h */ -/* System Memory CLK */ -#define VIA_MEM_SDR66 0x00 -#define VIA_MEM_SDR100 0x01 -#define VIA_MEM_SDR133 0x02 -#define VIA_MEM_DDR200 0x03 -#define VIA_MEM_DDR266 0x04 -#define VIA_MEM_DDR333 0x05 -#define VIA_MEM_DDR400 0x06 - -#define DRIVER_NAME "via" -#define DRIVER_VERSION "4.1.0" -#define VERSION_MAJOR 4 -#define VERSION_MINOR 1 -#define PATCHLEVEL 41 -#define VIA_VERSION ((VERSION_MAJOR<<24) | (VERSION_MINOR<<16) | PATCHLEVEL) - -#define VGAIN8(addr) MMIO_IN8(pVia->MapBase+0x8000, addr) -#define VGAIN16(addr) MMIO_IN16(pVia->MapBase+0x8000, addr) -#define VGAIN(addr) MMIO_IN32(pVia->MapBase+0x8000, addr) - -#define VGAOUT8(addr, val) MMIO_OUT8(pVia->MapBase+0x8000, addr, val) -#define VGAOUT16(addr, val) MMIO_OUT16(pVia->MapBase+0x8000, addr, val) -#define VGAOUT(addr, val) MMIO_OUT32(pVia->MapBase+0x8000, addr, val) - -#define INREG(addr) MMIO_IN32(pVia->MapBase, addr) -#define OUTREG(addr, val) MMIO_OUT32(pVia->MapBase, addr, val) -#define INREG16(addr) MMIO_IN16(pVia->MapBase, addr) -#define OUTREG16(addr, val) MMIO_OUT16(pVia->MapBase, addr, val) - -#define VIA_PIXMAP_CACHE_SIZE (256 * 1024) -#define VIA_CURSOR_SIZE (4 * 1024) -#define VIA_VQ_SIZE (256 * 1024) - -typedef struct { - unsigned int mode, refresh, resMode; - int countWidthByQWord; - int offsetWidthByQWord; - unsigned char SR08, SR0A, SR0F; - - /* extended Sequencer registers */ - unsigned char SR10, SR11, SR12, SR13,SR14,SR15,SR16; - unsigned char SR17, SR18, SR19, SR1A,SR1B,SR1C,SR1D,SR1E; - unsigned char SR1F, SR20, SR21, SR22,SR23,SR24,SR25,SR26; - unsigned char SR27, SR28, SR29, SR2A,SR2B,SR2C,SR2D,SR2E; - unsigned char SR2F, SR30, SR31, SR32,SR33,SR34,SR40,SR41; - unsigned char SR42, SR43, SR44, SR45,SR46,SR47; - - unsigned char Clock; - - /* extended CRTC registers */ - unsigned char CR13, CR30, CR31, CR32, CR33, CR34, CR35, CR36; - unsigned char CR37, CR38, CR39, CR3A, CR40, CR41, CR42, CR43; - unsigned char CR44, CR45, CR46, CR47, CR48, CR49, CR4A; - unsigned char CRTCRegs[83]; - unsigned char TVRegs[0xCF]; - unsigned char TVRegs2[0xCF]; -/* unsigned char LCDRegs[0x40];*/ - -} VIARegRec, *VIARegPtr; - - -typedef struct _VIA { - VIARegRec SavedReg; - VIARegRec ModeReg; -#if 0 - xf86CursorInfoPtr CursorInfoRec; - int stateMode; - VIAModeInfoPtr VIAModeList; -#endif - int ModeStructInit; - int Bpp, Bpl, ScissB; - unsigned PlaneMask; - - unsigned long videoRambytes; - int videoRamKbytes; - int FBFreeStart; - int FBFreeEnd; - int CursorStart; - int VQStart; - int VQEnd; - - /* These are physical addresses. */ - unsigned long FrameBufferBase; - unsigned long MmioBase; - - /* These are linear addresses. */ - unsigned char* MapBase; - unsigned char* VidMapBase; - unsigned char* BltBase; - unsigned char* MapBaseDense; - unsigned char* FBBase; - unsigned char* FBStart; - - int PrimaryVidMapped; - int dacSpeedBpp; - int minClock, maxClock; - int MCLK, REFCLK, LCDclk; - double refclk_fact; - - /* Here are all the Options */ - int VQEnable; - int pci_burst; - int NoPCIRetry; - int hwcursor; - int NoAccel; - int shadowFB; - int NoDDCValue; - int rotate; - -#if 0 - CloseScreenProcPtr CloseScreen; - pciVideoPtr PciInfo; - PCITAG PciTag; -#endif - int Chipset; - int ChipId; - int ChipRev; - /*vbeInfoPtr pVbe;*/ - int EntityIndex; - - /* Support for shadowFB and rotation */ - unsigned char* ShadowPtr; - int ShadowPitch; - void (*PointerMoved)(int index, int x, int y); - - /* Support for XAA acceleration */ -#if 0 - XAAInfoRecPtr AccelInfoRec; - xRectangle Rect; -#endif - uint32_t SavedCmd; - uint32_t SavedFgColor; - uint32_t SavedBgColor; - uint32_t SavedPattern0; - uint32_t SavedPattern1; - uint32_t SavedPatternAddr; - -#if 0 - /* Support for Int10 processing */ - xf86Int10InfoPtr pInt10; - - /* BIOS Info Ptr */ - VIABIOSInfoPtr pBIOSInfo; - VGABIOSVERPtr pBIOSVer; -#endif - - /* Support for DGA */ - int numDGAModes; - /*DGAModePtr DGAModes;*/ - int DGAactive; - int DGAViewportStatus; - - /* The various wait handlers. */ - int (*myWaitIdle)(struct _VIA*); - -#if 0 - /* I2C & DDC */ - I2CBusPtr I2C_Port1; - I2CBusPtr I2C_Port2; - xf86MonPtr DDC1; - xf86MonPtr DDC2; -#endif - - /* MHS */ - int IsSecondary; - int HasSecondary; - -#if 0 - /* Capture information */ - VIACAPINFO CapInfo[2]; /* 2 capture information */ -#endif - -/* - uint32_t Cap0_Deinterlace; - uint32_t Cap1_Deinterlace; - - int Cap0_FieldSwap; - int NoCap0_HFilter; - int Capture_OverScanOff; - int NoMPEGHQV_VFilter; -*/ -#ifdef XF86DRI - int directRenderingEnabled; - DRIInfoPtr pDRIInfo; - int drmFD; - int numVisualConfigs; - __GLXvisualConfig* pVisualConfigs; - VIAConfigPrivPtr pVisualConfigsPriv; - unsigned long agpHandle; - unsigned long registerHandle; - uint32_t agpAddr; - unsigned char *agpBase; - unsigned int agpSize; - int IsPCI; - int drixinerama; -#else - int drmFD; - unsigned long agpHandle; - unsigned long registerHandle; - unsigned long agpAddr; - unsigned char *agpBase; - unsigned int agpSize; - int IsPCI; -#endif - - int V4LEnabled; - uint16_t ActiveDevice; /* if SAMM, non-equal pBIOSInfo->ActiveDevice */ - unsigned char *CursorImage; - uint32_t CursorFG; - uint32_t CursorBG; - uint32_t CursorMC; - - unsigned char MemClk; - int EnableExtendedFIFO; - VIADRIPtr devPrivate; -} VIARec, *VIAPtr; - - -/* Shortcuts. These depend on a local symbol "pVia". */ - -#define WaitIdle() pVia->myWaitIdle(pVia) -#define VIAPTR(p) ((VIAPtr)((p)->driverPrivate)) - -#endif /* _VIA_DRIVER_H */ - diff --git a/src/mesa/drivers/dri/unichrome/server/via_priv.h b/src/mesa/drivers/dri/unichrome/server/via_priv.h deleted file mode 100644 index 352eac0597d..00000000000 --- a/src/mesa/drivers/dri/unichrome/server/via_priv.h +++ /dev/null @@ -1,69 +0,0 @@ - -#ifndef _VIA_PRIV_H_ -#define _VIA_PRIV_H_ 1 - -//#include "ddmpeg.h" -#include "via_common.h" - -#define MEM_BLOCKS 4 - -typedef struct { - unsigned long base; /* Offset into fb */ - int pool; /* Pool we drew from */ - int drm_fd; /* Fd in DRM mode */ - drm_via_mem_t drm; /* DRM management object */ - int slot; /* Pool 3 slot */ - void *pVia; /* VIA driver pointer */ - //FBLinearPtr linear; /* X linear pool info ptr */ -} VIAMem; - -typedef VIAMem *VIAMemPtr; - - - -#if 0 -typedef struct { - unsigned long gdwVideoFlagTV1; - unsigned long gdwVideoFlagSW; - unsigned long gdwVideoFlagMPEG; - unsigned long gdwAlphaEnabled; /* For Alpha blending use*/ - - VIAMem SWOVMem; - VIAMem HQVMem; - VIAMem SWfbMem; - - DDPIXELFORMAT DPFsrc; - DDUPDATEOVERLAY UpdateOverlayBackup; /* For HQVcontrol func use - // To save MPEG updateoverlay info.*/ - -/* device struct */ - SWDEVICE SWDevice; - SUBDEVICE SUBDevice; - MPGDEVICE MPGDevice; - OVERLAYRECORD overlayRecordV1; - OVERLAYRECORD overlayRecordV3; - - BoxRec AvailFBArea; - FBLinearPtr SWOVlinear; - - int MPEG_ON; - int SWVideo_ON; - -/*To solve the bandwidth issue */ - unsigned long gdwUseExtendedFIFO; - -/* For panning mode use */ - int panning_old_x; - int panning_old_y; - int panning_x; - int panning_y; - -/*To solve the bandwidth issue */ - unsigned char Save_3C4_16; - unsigned char Save_3C4_17; - unsigned char Save_3C4_18; - -} swovRec, *swovPtr; -#endif - -#endif /* _VIA_PRIV_H_ */ diff --git a/src/mesa/drivers/dri/unichrome/server/via_regs.h b/src/mesa/drivers/dri/unichrome/server/via_regs.h deleted file mode 100644 index 87e1e9daa92..00000000000 --- a/src/mesa/drivers/dri/unichrome/server/via_regs.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/************************************************************************* - * - * File: via_regs.c - * Content: The defines of Via registers - * - ************************************************************************/ - -#ifndef _VIA_REGS_H -#define _VIA_REGS_H - -#include "via_driver.h" - -/*#define VIA_SERIES(chip) (chip == VIA_CLE266)*/ - -#define PCI_VIA_VENDOR_ID 0x1106 - -#define PCI_CHIP_CLE3122 0x3122 -#define PCI_CHIP_CLE3022 0x3022 -#define PCI_CHIP_VT3205 0x3205 -#define PCI_CHIP_VT7205 0x7205 -#define PCI_CHIP_VT3204 0x3108 -#define PCI_CHIP_VT3259 0x3118 -#define PCI_CHIP_VT3344 0x3344 - - -#define BIOS_BSIZE 1024 -#define BIOS_BASE 0xc0000 - - -#define VIA_MMIO_REGSIZE 0x9000 -#define VIA_MMIO_REGBASE 0x0 -#define VIA_MMIO_VGABASE 0x8000 -#define VIA_MMIO_BLTBASE 0x200000 -#define VIA_MMIO_BLTSIZE 0x10000 - - -/* defines for VIA 2D registers */ -#define VIA_REG_GECMD 0x000 -#define VIA_REG_GEMODE 0x004 -#define VIA_REG_GESTATUS 0x004 /* as same as VIA_REG_GEMODE */ -#define VIA_REG_SRCPOS 0x008 -#define VIA_REG_DSTPOS 0x00C -#define VIA_REG_LINE_K1K2 0x008 -#define VIA_REG_LINE_XY 0x00C -#define VIA_REG_DIMENSION 0x010 /* width and height */ -#define VIA_REG_PATADDR 0x014 -#define VIA_REG_FGCOLOR 0x018 -#define VIA_REG_DSTCOLORKEY 0x018 /* as same as VIA_REG_FG */ -#define VIA_REG_BGCOLOR 0x01C -#define VIA_REG_SRCCOLORKEY 0x01C /* as same as VIA_REG_BG */ -#define VIA_REG_CLIPTL 0x020 /* top and left of clipping */ -#define VIA_REG_CLIPBR 0x024 /* bottom and right of clipping */ -#define VIA_REG_OFFSET 0x028 -#define VIA_REG_LINE_ERROR 0x028 -#define VIA_REG_KEYCONTROL 0x02C /* color key control */ -#define VIA_REG_SRCBASE 0x030 -#define VIA_REG_DSTBASE 0x034 -#define VIA_REG_PITCH 0x038 /* pitch of src and dst */ -#define VIA_REG_MONOPAT0 0x03C -#define VIA_REG_MONOPAT1 0x040 -#define VIA_REG_COLORPAT 0x100 /* from 0x100 to 0x1ff */ - - - -/* defines for VIA video registers */ -#define VIA_REG_INTERRUPT 0x200 -#define VIA_REG_CRTCSTART 0x214 - - -/* defines for VIA HW cursor registers */ -#define VIA_REG_CURSOR_MODE 0x2D0 -#define VIA_REG_CURSOR_POS 0x2D4 -#define VIA_REG_CURSOR_ORG 0x2D8 -#define VIA_REG_CURSOR_BG 0x2DC -#define VIA_REG_CURSOR_FG 0x2E0 - - -/* defines for VIA 3D registers */ -#define VIA_REG_STATUS 0x400 -#define VIA_REG_TRANSET 0x43C -#define VIA_REG_TRANSPACE 0x440 - -/* VIA_REG_STATUS(0x400): Engine Status */ -#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */ -#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */ -#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */ -#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */ - - -/* VIA_REG_GECMD(0x00): 2D Engine Command */ -#define VIA_GEC_NOOP 0x00000000 -#define VIA_GEC_BLT 0x00000001 -#define VIA_GEC_LINE 0x00000005 - -#define VIA_GEC_SRC_XY 0x00000000 -#define VIA_GEC_SRC_LINEAR 0x00000010 -#define VIA_GEC_DST_XY 0x00000000 -#define VIA_GEC_DST_LINRAT 0x00000020 - -#define VIA_GEC_SRC_FB 0x00000000 -#define VIA_GEC_SRC_SYS 0x00000040 -#define VIA_GEC_DST_FB 0x00000000 -#define VIA_GEC_DST_SYS 0x00000080 - -#define VIA_GEC_SRC_MONO 0x00000100 /* source is mono */ -#define VIA_GEC_PAT_MONO 0x00000200 /* pattern is mono */ - -#define VIA_GEC_MSRC_OPAQUE 0x00000000 /* mono src is opaque */ -#define VIA_GEC_MSRC_TRANS 0x00000400 /* mono src is transparent */ - -#define VIA_GEC_PAT_FB 0x00000000 /* pattern is in frame buffer */ -#define VIA_GEC_PAT_REG 0x00000800 /* pattern is from reg setting */ - -#define VIA_GEC_CLIP_DISABLE 0x00000000 -#define VIA_GEC_CLIP_ENABLE 0x00001000 - -#define VIA_GEC_FIXCOLOR_PAT 0x00002000 - -#define VIA_GEC_INCX 0x00000000 -#define VIA_GEC_DECY 0x00004000 -#define VIA_GEC_INCY 0x00000000 -#define VIA_GEC_DECX 0x00008000 - -#define VIA_GEC_MPAT_OPAQUE 0x00000000 /* mono pattern is opaque */ -#define VIA_GEC_MPAT_TRANS 0x00010000 /* mono pattern is transparent */ - -#define VIA_GEC_MONO_UNPACK 0x00000000 -#define VIA_GEC_MONO_PACK 0x00020000 -#define VIA_GEC_MONO_DWORD 0x00000000 -#define VIA_GEC_MONO_WORD 0x00040000 -#define VIA_GEC_MONO_BYTE 0x00080000 - -#define VIA_GEC_LASTPIXEL_ON 0x00000000 -#define VIA_GEC_LASTPIXEL_OFF 0x00100000 -#define VIA_GEC_X_MAJOR 0x00000000 -#define VIA_GEC_Y_MAJOR 0x00200000 -#define VIA_GEC_QUICK_START 0x00800000 - - -/* VIA_REG_GEMODE(0x04): GE mode */ -#define VIA_GEM_8bpp 0x00000000 -#define VIA_GEM_16bpp 0x00000100 -#define VIA_GEM_32bpp 0x00000300 - -#define VIA_GEM_640 0x00000000 /* 640*480 */ -#define VIA_GEM_800 0x00000400 /* 800*600 */ -#define VIA_GEM_1024 0x00000800 /* 1024*768 */ -#define VIA_GEM_1280 0x00000C00 /* 1280*1024 */ -#define VIA_GEM_1600 0x00001000 /* 1600*1200 */ -#define VIA_GEM_2048 0x00001400 /* 2048*1536 */ - -/* VIA_REG_PITCH(0x38): Pitch Setting */ -#define VIA_PITCH_ENABLE 0x80000000 - - -#define MAXLOOP 0xffffff - - -#define VerticalRetraceWait() \ -{ \ - VGAOUT8(vgaCRIndex, 0x17); \ - if (VGAIN8(vgaCRReg) & 0x80) { \ - while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x00) ; \ - while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x08) ; \ - while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x00) ; \ - } \ -} - - -#define VIASETREG(addr, data) *(volatile unsigned int *)(pVia->MapBase + (addr)) = (data) -#define VIAGETREG(addr) *(volatile unsigned int *)(pVia->MapBase + (addr)) - - -#endif /* _VIA_REGS_H */ diff --git a/src/mesa/drivers/dri/unichrome/via_3d_reg.h b/src/mesa/drivers/dri/unichrome/via_3d_reg.h deleted file mode 100644 index 77b24dc6156..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_3d_reg.h +++ /dev/null @@ -1,1652 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef VIA_3D_REG_H -#define VIA_3D_REG_H -#define HC_REG_BASE 0x0400 - -#define HC_ParaN_MASK 0xffffffff -#define HC_Para_MASK 0x00ffffff -#define HC_SubA_MASK 0xff000000 -#define HC_SubA_SHIFT 24 -/* Transmission Setting - */ -#define HC_REG_TRANS_SET 0x003c -#define HC_ParaSubType_MASK 0xff000000 -#define HC_ParaType_MASK 0x00ff0000 -#define HC_ParaOS_MASK 0x0000ff00 -#define HC_ParaAdr_MASK 0x000000ff -#define HC_ParaSubType_SHIFT 24 -#define HC_ParaType_SHIFT 16 -#define HC_ParaOS_SHIFT 8 -#define HC_ParaAdr_SHIFT 0 - -#define HC_ParaType_CmdVdata 0x0000 -#define HC_ParaType_NotTex 0x0001 -#define HC_ParaType_Tex 0x0002 -#define HC_ParaType_Palette 0x0003 -#define HC_ParaType_PreCR 0x0010 -#define HC_ParaType_Auto 0x00fe - -/* Transmission Space - */ -#define HC_REG_Hpara0 0x0040 -#define HC_REG_HpataAF 0x02fc - -/* Read - */ -#define HC_REG_HREngSt 0x0000 -#define HC_REG_HRFIFOempty 0x0004 -#define HC_REG_HRFIFOfull 0x0008 -#define HC_REG_HRErr 0x000c -#define HC_REG_FIFOstatus 0x0010 -/* HC_REG_HREngSt 0x0000 - */ -#define HC_HDASZC_MASK 0x00010000 -#define HC_HSGEMI_MASK 0x0000f000 -#define HC_HLGEMISt_MASK 0x00000f00 -#define HC_HCRSt_MASK 0x00000080 -#define HC_HSE0St_MASK 0x00000040 -#define HC_HSE1St_MASK 0x00000020 -#define HC_HPESt_MASK 0x00000010 -#define HC_HXESt_MASK 0x00000008 -#define HC_HBESt_MASK 0x00000004 -#define HC_HE2St_MASK 0x00000002 -#define HC_HE3St_MASK 0x00000001 -/* HC_REG_HRFIFOempty 0x0004 - */ -#define HC_HRZDempty_MASK 0x00000010 -#define HC_HRTXAempty_MASK 0x00000008 -#define HC_HRTXDempty_MASK 0x00000004 -#define HC_HWZDempty_MASK 0x00000002 -#define HC_HWCDempty_MASK 0x00000001 -/* HC_REG_HRFIFOfull 0x0008 - */ -#define HC_HRZDfull_MASK 0x00000010 -#define HC_HRTXAfull_MASK 0x00000008 -#define HC_HRTXDfull_MASK 0x00000004 -#define HC_HWZDfull_MASK 0x00000002 -#define HC_HWCDfull_MASK 0x00000001 -/* HC_REG_HRErr 0x000c - */ -#define HC_HAGPCMErr_MASK 0x80000000 -#define HC_HAGPCMErrC_MASK 0x70000000 -/* HC_REG_FIFOstatus 0x0010 - */ -#define HC_HRFIFOATall_MASK 0x80000000 -#define HC_HRFIFOATbusy_MASK 0x40000000 -#define HC_HRATFGMDo_MASK 0x00000100 -#define HC_HRATFGMDi_MASK 0x00000080 -#define HC_HRATFRZD_MASK 0x00000040 -#define HC_HRATFRTXA_MASK 0x00000020 -#define HC_HRATFRTXD_MASK 0x00000010 -#define HC_HRATFWZD_MASK 0x00000008 -#define HC_HRATFWCD_MASK 0x00000004 -#define HC_HRATTXTAG_MASK 0x00000002 -#define HC_HRATTXCH_MASK 0x00000001 - -/* AGP Command Setting - */ -#define HC_SubA_HAGPBstL 0x0060 -#define HC_SubA_HAGPBendL 0x0061 -#define HC_SubA_HAGPCMNT 0x0062 -#define HC_SubA_HAGPBpL 0x0063 -#define HC_SubA_HAGPBpH 0x0064 -/* HC_SubA_HAGPCMNT 0x0062 - */ -#define HC_HAGPCMNT_MASK 0x00800000 -#define HC_HCmdErrClr_MASK 0x00400000 -#define HC_HAGPBendH_MASK 0x0000ff00 -#define HC_HAGPBstH_MASK 0x000000ff -#define HC_HAGPBendH_SHIFT 8 -#define HC_HAGPBstH_SHIFT 0 -/* HC_SubA_HAGPBpL 0x0063 - */ -#define HC_HAGPBpL_MASK 0x00fffffc -#define HC_HAGPBpID_MASK 0x00000003 -#define HC_HAGPBpID_PAUSE 0x00000000 -#define HC_HAGPBpID_JUMP 0x00000001 -#define HC_HAGPBpID_STOP 0x00000002 -/* HC_SubA_HAGPBpH 0x0064 - */ -#define HC_HAGPBpH_MASK 0x00ffffff - -/* Miscellaneous Settings - */ -#define HC_SubA_HClipTB 0x0070 -#define HC_SubA_HClipLR 0x0071 -#define HC_SubA_HFPClipTL 0x0072 -#define HC_SubA_HFPClipBL 0x0073 -#define HC_SubA_HFPClipLL 0x0074 -#define HC_SubA_HFPClipRL 0x0075 -#define HC_SubA_HFPClipTBH 0x0076 -#define HC_SubA_HFPClipLRH 0x0077 -#define HC_SubA_HLP 0x0078 -#define HC_SubA_HLPRF 0x0079 -#define HC_SubA_HSolidCL 0x007a -#define HC_SubA_HPixGC 0x007b -#define HC_SubA_HSPXYOS 0x007c -#define HC_SubA_HVertexCNT 0x007d - -#define HC_HClipT_MASK 0x00fff000 -#define HC_HClipT_SHIFT 12 -#define HC_HClipB_MASK 0x00000fff -#define HC_HClipB_SHIFT 0 -#define HC_HClipL_MASK 0x00fff000 -#define HC_HClipL_SHIFT 12 -#define HC_HClipR_MASK 0x00000fff -#define HC_HClipR_SHIFT 0 -#define HC_HFPClipBH_MASK 0x0000ff00 -#define HC_HFPClipBH_SHIFT 8 -#define HC_HFPClipTH_MASK 0x000000ff -#define HC_HFPClipTH_SHIFT 0 -#define HC_HFPClipRH_MASK 0x0000ff00 -#define HC_HFPClipRH_SHIFT 8 -#define HC_HFPClipLH_MASK 0x000000ff -#define HC_HFPClipLH_SHIFT 0 -#define HC_HSolidCH_MASK 0x000000ff -#define HC_HPixGC_MASK 0x00800000 -#define HC_HSPXOS_MASK 0x00fff000 -#define HC_HSPXOS_SHIFT 12 -#define HC_HSPYOS_MASK 0x00000fff - -/* Command - * Command A - */ -#define HC_HCmdHeader_MASK 0xfe000000 /*0xffe00000*/ -#define HC_HE3Fire_MASK 0x00100000 -#define HC_HPMType_MASK 0x000f0000 -#define HC_HEFlag_MASK 0x0000e000 -#define HC_HShading_MASK 0x00001c00 -#define HC_HPMValidN_MASK 0x00000200 -#define HC_HPLEND_MASK 0x00000100 -#define HC_HVCycle_MASK 0x000000ff -#define HC_HVCycle_Style_MASK 0x000000c0 -#define HC_HVCycle_ChgA_MASK 0x00000030 -#define HC_HVCycle_ChgB_MASK 0x0000000c -#define HC_HVCycle_ChgC_MASK 0x00000003 -#define HC_HPMType_Point 0x00000000 -#define HC_HPMType_Line 0x00010000 -#define HC_HPMType_Tri 0x00020000 -#define HC_HPMType_TriWF 0x00040000 -#define HC_HEFlag_NoAA 0x00000000 -#define HC_HEFlag_ab 0x00008000 -#define HC_HEFlag_bc 0x00004000 -#define HC_HEFlag_ca 0x00002000 -#define HC_HShading_Solid 0x00000000 -#define HC_HShading_FlatA 0x00000400 -#define HC_HShading_FlatB 0x00000800 -#define HC_HShading_FlatC 0x00000c00 -#define HC_HShading_Gouraud 0x00001000 -#define HC_HVCycle_Full 0x00000000 -#define HC_HVCycle_AFP 0x00000040 -#define HC_HVCycle_One 0x000000c0 -#define HC_HVCycle_NewA 0x00000000 -#define HC_HVCycle_AA 0x00000010 -#define HC_HVCycle_AB 0x00000020 -#define HC_HVCycle_AC 0x00000030 -#define HC_HVCycle_NewB 0x00000000 -#define HC_HVCycle_BA 0x00000004 -#define HC_HVCycle_BB 0x00000008 -#define HC_HVCycle_BC 0x0000000c -#define HC_HVCycle_NewC 0x00000000 -#define HC_HVCycle_CA 0x00000001 -#define HC_HVCycle_CB 0x00000002 -#define HC_HVCycle_CC 0x00000003 - -/* Command B - */ -#define HC_HLPrst_MASK 0x00010000 -#define HC_HLLastP_MASK 0x00008000 -#define HC_HVPMSK_MASK 0x00007f80 -#define HC_HBFace_MASK 0x00000040 -#define HC_H2nd1VT_MASK 0x0000003f -#define HC_HVPMSK_X 0x00004000 -#define HC_HVPMSK_Y 0x00002000 -#define HC_HVPMSK_Z 0x00001000 -#define HC_HVPMSK_W 0x00000800 -#define HC_HVPMSK_Cd 0x00000400 -#define HC_HVPMSK_Cs 0x00000200 -#define HC_HVPMSK_S 0x00000100 -#define HC_HVPMSK_T 0x00000080 - -/* Enable Setting - */ -#define HC_SubA_HEnable 0x0000 -#define HC_HenTXEnvMap_MASK 0x00200000 -#define HC_HenVertexCNT_MASK 0x00100000 -#define HC_HenCPUDAZ_MASK 0x00080000 -#define HC_HenDASZWC_MASK 0x00040000 -#define HC_HenFBCull_MASK 0x00020000 -#define HC_HenCW_MASK 0x00010000 -#define HC_HenAA_MASK 0x00008000 -#define HC_HenST_MASK 0x00004000 -#define HC_HenZT_MASK 0x00002000 -#define HC_HenZW_MASK 0x00001000 -#define HC_HenAT_MASK 0x00000800 -#define HC_HenAW_MASK 0x00000400 -#define HC_HenSP_MASK 0x00000200 -#define HC_HenLP_MASK 0x00000100 -#define HC_HenTXCH_MASK 0x00000080 -#define HC_HenTXMP_MASK 0x00000040 -#define HC_HenTXPP_MASK 0x00000020 -#define HC_HenTXTR_MASK 0x00000010 -#define HC_HenCS_MASK 0x00000008 -#define HC_HenFOG_MASK 0x00000004 -#define HC_HenABL_MASK 0x00000002 -#define HC_HenDT_MASK 0x00000001 - -/* Z Setting - */ -#define HC_SubA_HZWBBasL 0x0010 -#define HC_SubA_HZWBBasH 0x0011 -#define HC_SubA_HZWBType 0x0012 -#define HC_SubA_HZBiasL 0x0013 -#define HC_SubA_HZWBend 0x0014 -#define HC_SubA_HZWTMD 0x0015 -#define HC_SubA_HZWCDL 0x0016 -#define HC_SubA_HZWCTAGnum 0x0017 -#define HC_SubA_HZCYNum 0x0018 -#define HC_SubA_HZWCFire 0x0019 -/* HC_SubA_HZWBType - */ -#define HC_HZWBType_MASK 0x00800000 -#define HC_HZBiasedWB_MASK 0x00400000 -#define HC_HZONEasFF_MASK 0x00200000 -#define HC_HZOONEasFF_MASK 0x00100000 -#define HC_HZWBFM_MASK 0x00030000 -#define HC_HZWBLoc_MASK 0x0000c000 -#define HC_HZWBPit_MASK 0x00003fff -#define HC_HZWBFM_16 0x00000000 -#define HC_HZWBFM_32 0x00020000 -#define HC_HZWBFM_24 0x00030000 -#define HC_HZWBLoc_Local 0x00000000 -#define HC_HZWBLoc_SyS 0x00004000 -/* HC_SubA_HZWBend - */ -#define HC_HZWBend_MASK 0x00ffe000 -#define HC_HZBiasH_MASK 0x000000ff -#define HC_HZWBend_SHIFT 10 -/* HC_SubA_HZWTMD - */ -#define HC_HZWTMD_MASK 0x00070000 -#define HC_HEBEBias_MASK 0x00007f00 -#define HC_HZNF_MASK 0x000000ff -#define HC_HZWTMD_NeverPass 0x00000000 -#define HC_HZWTMD_LT 0x00010000 -#define HC_HZWTMD_EQ 0x00020000 -#define HC_HZWTMD_LE 0x00030000 -#define HC_HZWTMD_GT 0x00040000 -#define HC_HZWTMD_NE 0x00050000 -#define HC_HZWTMD_GE 0x00060000 -#define HC_HZWTMD_AllPass 0x00070000 -#define HC_HEBEBias_SHIFT 8 -/* HC_SubA_HZWCDL 0x0016 - */ -#define HC_HZWCDL_MASK 0x00ffffff -/* HC_SubA_HZWCTAGnum 0x0017 - */ -#define HC_HZWCTAGnum_MASK 0x00ff0000 -#define HC_HZWCTAGnum_SHIFT 16 -#define HC_HZWCDH_MASK 0x000000ff -#define HC_HZWCDH_SHIFT 0 -/* HC_SubA_HZCYNum 0x0018 - */ -#define HC_HZCYNum_MASK 0x00030000 -#define HC_HZCYNum_SHIFT 16 -#define HC_HZWCQWnum_MASK 0x00003fff -#define HC_HZWCQWnum_SHIFT 0 -/* HC_SubA_HZWCFire 0x0019 - */ -#define HC_ZWCFire_MASK 0x00010000 -#define HC_HZWCQWnumLast_MASK 0x00003fff -#define HC_HZWCQWnumLast_SHIFT 0 - -/* Stencil Setting - */ -#define HC_SubA_HSTREF 0x0023 -#define HC_SubA_HSTMD 0x0024 -/* HC_SubA_HSBFM - */ -#define HC_HSBFM_MASK 0x00030000 -#define HC_HSBLoc_MASK 0x0000c000 -#define HC_HSBPit_MASK 0x00003fff -/* HC_SubA_HSTREF - */ -#define HC_HSTREF_MASK 0x00ff0000 -#define HC_HSTOPMSK_MASK 0x0000ff00 -#define HC_HSTBMSK_MASK 0x000000ff -#define HC_HSTREF_SHIFT 16 -#define HC_HSTOPMSK_SHIFT 8 -/* HC_SubA_HSTMD - */ -#define HC_HSTMD_MASK 0x00070000 -#define HC_HSTOPSF_MASK 0x000001c0 -#define HC_HSTOPSPZF_MASK 0x00000038 -#define HC_HSTOPSPZP_MASK 0x00000007 -#define HC_HSTMD_NeverPass 0x00000000 -#define HC_HSTMD_LT 0x00010000 -#define HC_HSTMD_EQ 0x00020000 -#define HC_HSTMD_LE 0x00030000 -#define HC_HSTMD_GT 0x00040000 -#define HC_HSTMD_NE 0x00050000 -#define HC_HSTMD_GE 0x00060000 -#define HC_HSTMD_AllPass 0x00070000 -#define HC_HSTOPSF_KEEP 0x00000000 -#define HC_HSTOPSF_ZERO 0x00000040 -#define HC_HSTOPSF_REPLACE 0x00000080 -#define HC_HSTOPSF_INCRSAT 0x000000c0 -#define HC_HSTOPSF_DECRSAT 0x00000100 -#define HC_HSTOPSF_INVERT 0x00000140 -#define HC_HSTOPSF_INCR 0x00000180 -#define HC_HSTOPSF_DECR 0x000001c0 -#define HC_HSTOPSPZF_KEEP 0x00000000 -#define HC_HSTOPSPZF_ZERO 0x00000008 -#define HC_HSTOPSPZF_REPLACE 0x00000010 -#define HC_HSTOPSPZF_INCRSAT 0x00000018 -#define HC_HSTOPSPZF_DECRSAT 0x00000020 -#define HC_HSTOPSPZF_INVERT 0x00000028 -#define HC_HSTOPSPZF_INCR 0x00000030 -#define HC_HSTOPSPZF_DECR 0x00000038 -#define HC_HSTOPSPZP_KEEP 0x00000000 -#define HC_HSTOPSPZP_ZERO 0x00000001 -#define HC_HSTOPSPZP_REPLACE 0x00000002 -#define HC_HSTOPSPZP_INCRSAT 0x00000003 -#define HC_HSTOPSPZP_DECRSAT 0x00000004 -#define HC_HSTOPSPZP_INVERT 0x00000005 -#define HC_HSTOPSPZP_INCR 0x00000006 -#define HC_HSTOPSPZP_DECR 0x00000007 - -/* Alpha Setting - */ -#define HC_SubA_HABBasL 0x0030 -#define HC_SubA_HABBasH 0x0031 -#define HC_SubA_HABFM 0x0032 -#define HC_SubA_HATMD 0x0033 -#define HC_SubA_HABLCsat 0x0034 -#define HC_SubA_HABLCop 0x0035 -#define HC_SubA_HABLAsat 0x0036 -#define HC_SubA_HABLAop 0x0037 -#define HC_SubA_HABLRCa 0x0038 -#define HC_SubA_HABLRFCa 0x0039 -#define HC_SubA_HABLRCbias 0x003a -#define HC_SubA_HABLRCb 0x003b -#define HC_SubA_HABLRFCb 0x003c -#define HC_SubA_HABLRAa 0x003d -#define HC_SubA_HABLRAb 0x003e -/* HC_SubA_HABFM - */ -#define HC_HABFM_MASK 0x00030000 -#define HC_HABLoc_MASK 0x0000c000 -#define HC_HABPit_MASK 0x000007ff -/* HC_SubA_HATMD - */ -#define HC_HATMD_MASK 0x00000700 -#define HC_HATREF_MASK 0x000000ff -#define HC_HATMD_NeverPass 0x00000000 -#define HC_HATMD_LT 0x00000100 -#define HC_HATMD_EQ 0x00000200 -#define HC_HATMD_LE 0x00000300 -#define HC_HATMD_GT 0x00000400 -#define HC_HATMD_NE 0x00000500 -#define HC_HATMD_GE 0x00000600 -#define HC_HATMD_AllPass 0x00000700 -/* HC_SubA_HABLCsat - */ -#define HC_HABLCsat_MASK 0x00010000 -#define HC_HABLCa_MASK 0x0000fc00 -#define HC_HABLCa_C_MASK 0x0000c000 -#define HC_HABLCa_OPC_MASK 0x00003c00 -#define HC_HABLFCa_MASK 0x000003f0 -#define HC_HABLFCa_C_MASK 0x00000300 -#define HC_HABLFCa_OPC_MASK 0x000000f0 -#define HC_HABLCbias_MASK 0x0000000f -#define HC_HABLCbias_C_MASK 0x00000008 -#define HC_HABLCbias_OPC_MASK 0x00000007 -/*-- Define the input color. - */ -#define HC_XC_Csrc 0x00000000 -#define HC_XC_Cdst 0x00000001 -#define HC_XC_Asrc 0x00000002 -#define HC_XC_Adst 0x00000003 -#define HC_XC_Fog 0x00000004 -#define HC_XC_HABLRC 0x00000005 -#define HC_XC_minSrcDst 0x00000006 -#define HC_XC_maxSrcDst 0x00000007 -#define HC_XC_mimAsrcInvAdst 0x00000008 -#define HC_XC_OPC 0x00000000 -#define HC_XC_InvOPC 0x00000010 -#define HC_XC_OPCp5 0x00000020 -/*-- Define the input Alpha - */ -#define HC_XA_OPA 0x00000000 -#define HC_XA_InvOPA 0x00000010 -#define HC_XA_OPAp5 0x00000020 -#define HC_XA_0 0x00000000 -#define HC_XA_Asrc 0x00000001 -#define HC_XA_Adst 0x00000002 -#define HC_XA_Fog 0x00000003 -#define HC_XA_minAsrcFog 0x00000004 -#define HC_XA_minAsrcAdst 0x00000005 -#define HC_XA_maxAsrcFog 0x00000006 -#define HC_XA_maxAsrcAdst 0x00000007 -#define HC_XA_HABLRA 0x00000008 -#define HC_XA_minAsrcInvAdst 0x00000008 -#define HC_XA_HABLFRA 0x00000009 -/*-- - */ -#define HC_HABLCa_OPC (HC_XC_OPC << 10) -#define HC_HABLCa_InvOPC (HC_XC_InvOPC << 10) -#define HC_HABLCa_OPCp5 (HC_XC_OPCp5 << 10) -#define HC_HABLCa_Csrc (HC_XC_Csrc << 10) -#define HC_HABLCa_Cdst (HC_XC_Cdst << 10) -#define HC_HABLCa_Asrc (HC_XC_Asrc << 10) -#define HC_HABLCa_Adst (HC_XC_Adst << 10) -#define HC_HABLCa_Fog (HC_XC_Fog << 10) -#define HC_HABLCa_HABLRCa (HC_XC_HABLRC << 10) -#define HC_HABLCa_minSrcDst (HC_XC_minSrcDst << 10) -#define HC_HABLCa_maxSrcDst (HC_XC_maxSrcDst << 10) -#define HC_HABLFCa_OPC (HC_XC_OPC << 4) -#define HC_HABLFCa_InvOPC (HC_XC_InvOPC << 4) -#define HC_HABLFCa_OPCp5 (HC_XC_OPCp5 << 4) -#define HC_HABLFCa_Csrc (HC_XC_Csrc << 4) -#define HC_HABLFCa_Cdst (HC_XC_Cdst << 4) -#define HC_HABLFCa_Asrc (HC_XC_Asrc << 4) -#define HC_HABLFCa_Adst (HC_XC_Adst << 4) -#define HC_HABLFCa_Fog (HC_XC_Fog << 4) -#define HC_HABLFCa_HABLRCa (HC_XC_HABLRC << 4) -#define HC_HABLFCa_minSrcDst (HC_XC_minSrcDst << 4) -#define HC_HABLFCa_maxSrcDst (HC_XC_maxSrcDst << 4) -#define HC_HABLFCa_mimAsrcInvAdst (HC_XC_mimAsrcInvAdst << 4) -#define HC_HABLCbias_HABLRCbias 0x00000000 -#define HC_HABLCbias_Asrc 0x00000001 -#define HC_HABLCbias_Adst 0x00000002 -#define HC_HABLCbias_Fog 0x00000003 -#define HC_HABLCbias_Cin 0x00000004 -/* HC_SubA_HABLCop 0x0035 - */ -#define HC_HABLdot_MASK 0x00010000 -#define HC_HABLCop_MASK 0x00004000 -#define HC_HABLCb_MASK 0x00003f00 -#define HC_HABLCb_C_MASK 0x00003000 -#define HC_HABLCb_OPC_MASK 0x00000f00 -#define HC_HABLFCb_MASK 0x000000fc -#define HC_HABLFCb_C_MASK 0x000000c0 -#define HC_HABLFCb_OPC_MASK 0x0000003c -#define HC_HABLCshift_MASK 0x00000003 -#define HC_HABLCb_OPC (HC_XC_OPC << 8) -#define HC_HABLCb_InvOPC (HC_XC_InvOPC << 8) -#define HC_HABLCb_OPCp5 (HC_XC_OPCp5 << 8) -#define HC_HABLCb_Csrc (HC_XC_Csrc << 8) -#define HC_HABLCb_Cdst (HC_XC_Cdst << 8) -#define HC_HABLCb_Asrc (HC_XC_Asrc << 8) -#define HC_HABLCb_Adst (HC_XC_Adst << 8) -#define HC_HABLCb_Fog (HC_XC_Fog << 8) -#define HC_HABLCb_HABLRCa (HC_XC_HABLRC << 8) -#define HC_HABLCb_minSrcDst (HC_XC_minSrcDst << 8) -#define HC_HABLCb_maxSrcDst (HC_XC_maxSrcDst << 8) -#define HC_HABLFCb_OPC (HC_XC_OPC << 2) -#define HC_HABLFCb_InvOPC (HC_XC_InvOPC << 2) -#define HC_HABLFCb_OPCp5 (HC_XC_OPCp5 << 2) -#define HC_HABLFCb_Csrc (HC_XC_Csrc << 2) -#define HC_HABLFCb_Cdst (HC_XC_Cdst << 2) -#define HC_HABLFCb_Asrc (HC_XC_Asrc << 2) -#define HC_HABLFCb_Adst (HC_XC_Adst << 2) -#define HC_HABLFCb_Fog (HC_XC_Fog << 2) -#define HC_HABLFCb_HABLRCb (HC_XC_HABLRC << 2) -#define HC_HABLFCb_minSrcDst (HC_XC_minSrcDst << 2) -#define HC_HABLFCb_maxSrcDst (HC_XC_maxSrcDst << 2) -#define HC_HABLFCb_mimAsrcInvAdst (HC_XC_mimAsrcInvAdst << 2) -/* HC_SubA_HABLAsat 0x0036 - */ -#define HC_HABLAsat_MASK 0x00010000 -#define HC_HABLAa_MASK 0x0000fc00 -#define HC_HABLAa_A_MASK 0x0000c000 -#define HC_HABLAa_OPA_MASK 0x00003c00 -#define HC_HABLFAa_MASK 0x000003f0 -#define HC_HABLFAa_A_MASK 0x00000300 -#define HC_HABLFAa_OPA_MASK 0x000000f0 -#define HC_HABLAbias_MASK 0x0000000f -#define HC_HABLAbias_A_MASK 0x00000008 -#define HC_HABLAbias_OPA_MASK 0x00000007 -#define HC_HABLAa_OPA (HC_XA_OPA << 10) -#define HC_HABLAa_InvOPA (HC_XA_InvOPA << 10) -#define HC_HABLAa_OPAp5 (HC_XA_OPAp5 << 10) -#define HC_HABLAa_0 (HC_XA_0 << 10) -#define HC_HABLAa_Asrc (HC_XA_Asrc << 10) -#define HC_HABLAa_Adst (HC_XA_Adst << 10) -#define HC_HABLAa_Fog (HC_XA_Fog << 10) -#define HC_HABLAa_minAsrcFog (HC_XA_minAsrcFog << 10) -#define HC_HABLAa_minAsrcAdst (HC_XA_minAsrcAdst << 10) -#define HC_HABLAa_maxAsrcFog (HC_XA_maxAsrcFog << 10) -#define HC_HABLAa_maxAsrcAdst (HC_XA_maxAsrcAdst << 10) -#define HC_HABLAa_HABLRA (HC_XA_HABLRA << 10) -#define HC_HABLFAa_OPA (HC_XA_OPA << 4) -#define HC_HABLFAa_InvOPA (HC_XA_InvOPA << 4) -#define HC_HABLFAa_OPAp5 (HC_XA_OPAp5 << 4) -#define HC_HABLFAa_0 (HC_XA_0 << 4) -#define HC_HABLFAa_Asrc (HC_XA_Asrc << 4) -#define HC_HABLFAa_Adst (HC_XA_Adst << 4) -#define HC_HABLFAa_Fog (HC_XA_Fog << 4) -#define HC_HABLFAa_minAsrcFog (HC_XA_minAsrcFog << 4) -#define HC_HABLFAa_minAsrcAdst (HC_XA_minAsrcAdst << 4) -#define HC_HABLFAa_maxAsrcFog (HC_XA_maxAsrcFog << 4) -#define HC_HABLFAa_maxAsrcAdst (HC_XA_maxAsrcAdst << 4) -#define HC_HABLFAa_minAsrcInvAdst (HC_XA_minAsrcInvAdst << 4) -#define HC_HABLFAa_HABLFRA (HC_XA_HABLFRA << 4) -#define HC_HABLAbias_HABLRAbias 0x00000000 -#define HC_HABLAbias_Asrc 0x00000001 -#define HC_HABLAbias_Adst 0x00000002 -#define HC_HABLAbias_Fog 0x00000003 -#define HC_HABLAbias_Aaa 0x00000004 -/* HC_SubA_HABLAop 0x0037 - */ -#define HC_HABLAop_MASK 0x00004000 -#define HC_HABLAb_MASK 0x00003f00 -#define HC_HABLAb_OPA_MASK 0x00000f00 -#define HC_HABLFAb_MASK 0x000000fc -#define HC_HABLFAb_OPA_MASK 0x0000003c -#define HC_HABLAshift_MASK 0x00000003 -#define HC_HABLAb_OPA (HC_XA_OPA << 8) -#define HC_HABLAb_InvOPA (HC_XA_InvOPA << 8) -#define HC_HABLAb_OPAp5 (HC_XA_OPAp5 << 8) -#define HC_HABLAb_0 (HC_XA_0 << 8) -#define HC_HABLAb_Asrc (HC_XA_Asrc << 8) -#define HC_HABLAb_Adst (HC_XA_Adst << 8) -#define HC_HABLAb_Fog (HC_XA_Fog << 8) -#define HC_HABLAb_minAsrcFog (HC_XA_minAsrcFog << 8) -#define HC_HABLAb_minAsrcAdst (HC_XA_minAsrcAdst << 8) -#define HC_HABLAb_maxAsrcFog (HC_XA_maxAsrcFog << 8) -#define HC_HABLAb_maxAsrcAdst (HC_XA_maxAsrcAdst << 8) -#define HC_HABLAb_HABLRA (HC_XA_HABLRA << 8) -#define HC_HABLFAb_OPA (HC_XA_OPA << 2) -#define HC_HABLFAb_InvOPA (HC_XA_InvOPA << 2) -#define HC_HABLFAb_OPAp5 (HC_XA_OPAp5 << 2) -#define HC_HABLFAb_0 (HC_XA_0 << 2) -#define HC_HABLFAb_Asrc (HC_XA_Asrc << 2) -#define HC_HABLFAb_Adst (HC_XA_Adst << 2) -#define HC_HABLFAb_Fog (HC_XA_Fog << 2) -#define HC_HABLFAb_minAsrcFog (HC_XA_minAsrcFog << 2) -#define HC_HABLFAb_minAsrcAdst (HC_XA_minAsrcAdst << 2) -#define HC_HABLFAb_maxAsrcFog (HC_XA_maxAsrcFog << 2) -#define HC_HABLFAb_maxAsrcAdst (HC_XA_maxAsrcAdst << 2) -#define HC_HABLFAb_minAsrcInvAdst (HC_XA_minAsrcInvAdst << 2) -#define HC_HABLFAb_HABLFRA (HC_XA_HABLFRA << 2) -/* HC_SubA_HABLRAa 0x003d - */ -#define HC_HABLRAa_MASK 0x00ff0000 -#define HC_HABLRFAa_MASK 0x0000ff00 -#define HC_HABLRAbias_MASK 0x000000ff -#define HC_HABLRAa_SHIFT 16 -#define HC_HABLRFAa_SHIFT 8 -/* HC_SubA_HABLRAb 0x003e - */ -#define HC_HABLRAb_MASK 0x0000ff00 -#define HC_HABLRFAb_MASK 0x000000ff -#define HC_HABLRAb_SHIFT 8 - -/* Destination Setting - */ -#define HC_SubA_HDBBasL 0x0040 -#define HC_SubA_HDBBasH 0x0041 -#define HC_SubA_HDBFM 0x0042 -#define HC_SubA_HFBBMSKL 0x0043 -#define HC_SubA_HROP 0x0044 -/* HC_SubA_HDBFM 0x0042 - */ -#define HC_HDBFM_MASK 0x001f0000 -#define HC_HDBLoc_MASK 0x0000c000 -#define HC_HDBPit_MASK 0x00003fff -#define HC_HDBFM_RGB555 0x00000000 -#define HC_HDBFM_RGB565 0x00010000 -#define HC_HDBFM_ARGB4444 0x00020000 -#define HC_HDBFM_ARGB1555 0x00030000 -#define HC_HDBFM_BGR555 0x00040000 -#define HC_HDBFM_BGR565 0x00050000 -#define HC_HDBFM_ABGR4444 0x00060000 -#define HC_HDBFM_ABGR1555 0x00070000 -#define HC_HDBFM_ARGB0888 0x00080000 -#define HC_HDBFM_ARGB8888 0x00090000 -#define HC_HDBFM_ABGR0888 0x000a0000 -#define HC_HDBFM_ABGR8888 0x000b0000 -#define HC_HDBLoc_Local 0x00000000 -#define HC_HDBLoc_Sys 0x00004000 -/* HC_SubA_HROP 0x0044 - */ -#define HC_HROP_MASK 0x00000f00 -#define HC_HFBBMSKH_MASK 0x000000ff -#define HC_HROP_BLACK 0x00000000 -#define HC_HROP_DPon 0x00000100 -#define HC_HROP_DPna 0x00000200 -#define HC_HROP_Pn 0x00000300 -#define HC_HROP_PDna 0x00000400 -#define HC_HROP_Dn 0x00000500 -#define HC_HROP_DPx 0x00000600 -#define HC_HROP_DPan 0x00000700 -#define HC_HROP_DPa 0x00000800 -#define HC_HROP_DPxn 0x00000900 -#define HC_HROP_D 0x00000a00 -#define HC_HROP_DPno 0x00000b00 -#define HC_HROP_P 0x00000c00 -#define HC_HROP_PDno 0x00000d00 -#define HC_HROP_DPo 0x00000e00 -#define HC_HROP_WHITE 0x00000f00 - -/* Fog Setting - */ -#define HC_SubA_HFogLF 0x0050 -#define HC_SubA_HFogCL 0x0051 -#define HC_SubA_HFogCH 0x0052 -#define HC_SubA_HFogStL 0x0053 -#define HC_SubA_HFogStH 0x0054 -#define HC_SubA_HFogOOdMF 0x0055 -#define HC_SubA_HFogOOdEF 0x0056 -#define HC_SubA_HFogEndL 0x0057 -#define HC_SubA_HFogDenst 0x0058 -/* HC_SubA_FogLF 0x0050 - */ -#define HC_FogLF_MASK 0x00000010 -#define HC_FogEq_MASK 0x00000008 -#define HC_FogMD_MASK 0x00000007 -#define HC_FogMD_LocalFog 0x00000000 -#define HC_FogMD_LinearFog 0x00000002 -#define HC_FogMD_ExponentialFog 0x00000004 -#define HC_FogMD_Exponential2Fog 0x00000005 -/* #define HC_FogMD_FogTable 0x00000003 */ - -/* HC_SubA_HFogDenst 0x0058 - */ -#define HC_FogDenst_MASK 0x001fff00 -#define HC_FogEndL_MASK 0x000000ff - -/* Texture subtype definitions - */ -#define HC_SubType_Tex0 0x00000000 -#define HC_SubType_Tex1 0x00000001 -#define HC_SubType_TexGeneral 0x000000fe - -/* Attribute of texture n - */ -#define HC_SubA_HTXnL0BasL 0x0000 -#define HC_SubA_HTXnL1BasL 0x0001 -#define HC_SubA_HTXnL2BasL 0x0002 -#define HC_SubA_HTXnL3BasL 0x0003 -#define HC_SubA_HTXnL4BasL 0x0004 -#define HC_SubA_HTXnL5BasL 0x0005 -#define HC_SubA_HTXnL6BasL 0x0006 -#define HC_SubA_HTXnL7BasL 0x0007 -#define HC_SubA_HTXnL8BasL 0x0008 -#define HC_SubA_HTXnL9BasL 0x0009 -#define HC_SubA_HTXnLaBasL 0x000a -#define HC_SubA_HTXnLbBasL 0x000b -#define HC_SubA_HTXnLcBasL 0x000c -#define HC_SubA_HTXnLdBasL 0x000d -#define HC_SubA_HTXnLeBasL 0x000e -#define HC_SubA_HTXnLfBasL 0x000f -#define HC_SubA_HTXnL10BasL 0x0010 -#define HC_SubA_HTXnL11BasL 0x0011 -#define HC_SubA_HTXnL012BasH 0x0020 -#define HC_SubA_HTXnL345BasH 0x0021 -#define HC_SubA_HTXnL678BasH 0x0022 -#define HC_SubA_HTXnL9abBasH 0x0023 -#define HC_SubA_HTXnLcdeBasH 0x0024 -#define HC_SubA_HTXnLf1011BasH 0x0025 -#define HC_SubA_HTXnL0Pit 0x002b -#define HC_SubA_HTXnL1Pit 0x002c -#define HC_SubA_HTXnL2Pit 0x002d -#define HC_SubA_HTXnL3Pit 0x002e -#define HC_SubA_HTXnL4Pit 0x002f -#define HC_SubA_HTXnL5Pit 0x0030 -#define HC_SubA_HTXnL6Pit 0x0031 -#define HC_SubA_HTXnL7Pit 0x0032 -#define HC_SubA_HTXnL8Pit 0x0033 -#define HC_SubA_HTXnL9Pit 0x0034 -#define HC_SubA_HTXnLaPit 0x0035 -#define HC_SubA_HTXnLbPit 0x0036 -#define HC_SubA_HTXnLcPit 0x0037 -#define HC_SubA_HTXnLdPit 0x0038 -#define HC_SubA_HTXnLePit 0x0039 -#define HC_SubA_HTXnLfPit 0x003a -#define HC_SubA_HTXnL10Pit 0x003b -#define HC_SubA_HTXnL11Pit 0x003c -#define HC_SubA_HTXnL0_5WE 0x004b -#define HC_SubA_HTXnL6_bWE 0x004c -#define HC_SubA_HTXnLc_11WE 0x004d -#define HC_SubA_HTXnL0_5HE 0x0051 -#define HC_SubA_HTXnL6_bHE 0x0052 -#define HC_SubA_HTXnLc_11HE 0x0053 -#define HC_SubA_HTXnL0OS 0x0077 -#define HC_SubA_HTXnTB 0x0078 -#define HC_SubA_HTXnMPMD 0x0079 -#define HC_SubA_HTXnCLODu 0x007a -#define HC_SubA_HTXnFM 0x007b -#define HC_SubA_HTXnTRCH 0x007c -#define HC_SubA_HTXnTRCL 0x007d -#define HC_SubA_HTXnTBC 0x007e -#define HC_SubA_HTXnTRAH 0x007f -#define HC_SubA_HTXnTBLCsat 0x0080 -#define HC_SubA_HTXnTBLCop 0x0081 -#define HC_SubA_HTXnTBLMPfog 0x0082 -#define HC_SubA_HTXnTBLAsat 0x0083 -#define HC_SubA_HTXnTBLRCa 0x0085 -#define HC_SubA_HTXnTBLRCb 0x0086 -#define HC_SubA_HTXnTBLRCc 0x0087 -#define HC_SubA_HTXnTBLRCbias 0x0088 -#define HC_SubA_HTXnTBLRAa 0x0089 -#define HC_SubA_HTXnTBLRFog 0x008a -#define HC_SubA_HTXnBumpM00 0x0090 -#define HC_SubA_HTXnBumpM01 0x0091 -#define HC_SubA_HTXnBumpM10 0x0092 -#define HC_SubA_HTXnBumpM11 0x0093 -#define HC_SubA_HTXnLScale 0x0094 -#define HC_SubA_HTXSMD 0x0000 -/* HC_SubA_HTXnL012BasH 0x0020 - */ -#define HC_HTXnL0BasH_MASK 0x000000ff -#define HC_HTXnL1BasH_MASK 0x0000ff00 -#define HC_HTXnL2BasH_MASK 0x00ff0000 -#define HC_HTXnL1BasH_SHIFT 8 -#define HC_HTXnL2BasH_SHIFT 16 -/* HC_SubA_HTXnL345BasH 0x0021 - */ -#define HC_HTXnL3BasH_MASK 0x000000ff -#define HC_HTXnL4BasH_MASK 0x0000ff00 -#define HC_HTXnL5BasH_MASK 0x00ff0000 -#define HC_HTXnL4BasH_SHIFT 8 -#define HC_HTXnL5BasH_SHIFT 16 -/* HC_SubA_HTXnL678BasH 0x0022 - */ -#define HC_HTXnL6BasH_MASK 0x000000ff -#define HC_HTXnL7BasH_MASK 0x0000ff00 -#define HC_HTXnL8BasH_MASK 0x00ff0000 -#define HC_HTXnL7BasH_SHIFT 8 -#define HC_HTXnL8BasH_SHIFT 16 -/* HC_SubA_HTXnL9abBasH 0x0023 - */ -#define HC_HTXnL9BasH_MASK 0x000000ff -#define HC_HTXnLaBasH_MASK 0x0000ff00 -#define HC_HTXnLbBasH_MASK 0x00ff0000 -#define HC_HTXnLaBasH_SHIFT 8 -#define HC_HTXnLbBasH_SHIFT 16 -/* HC_SubA_HTXnLcdeBasH 0x0024 - */ -#define HC_HTXnLcBasH_MASK 0x000000ff -#define HC_HTXnLdBasH_MASK 0x0000ff00 -#define HC_HTXnLeBasH_MASK 0x00ff0000 -#define HC_HTXnLdBasH_SHIFT 8 -#define HC_HTXnLeBasH_SHIFT 16 -/* HC_SubA_HTXnLcdeBasH 0x0025 - */ -#define HC_HTXnLfBasH_MASK 0x000000ff -#define HC_HTXnL10BasH_MASK 0x0000ff00 -#define HC_HTXnL11BasH_MASK 0x00ff0000 -#define HC_HTXnL10BasH_SHIFT 8 -#define HC_HTXnL11BasH_SHIFT 16 -/* HC_SubA_HTXnL0Pit 0x002b - */ -#define HC_HTXnLnPit_MASK 0x00003fff -#define HC_HTXnEnPit_MASK 0x00080000 -#define HC_HTXnLnPitE_MASK 0x00f00000 -#define HC_HTXnLnPitE_SHIFT 20 -/* HC_SubA_HTXnL0_5WE 0x004b - */ -#define HC_HTXnL0WE_MASK 0x0000000f -#define HC_HTXnL1WE_MASK 0x000000f0 -#define HC_HTXnL2WE_MASK 0x00000f00 -#define HC_HTXnL3WE_MASK 0x0000f000 -#define HC_HTXnL4WE_MASK 0x000f0000 -#define HC_HTXnL5WE_MASK 0x00f00000 -#define HC_HTXnL1WE_SHIFT 4 -#define HC_HTXnL2WE_SHIFT 8 -#define HC_HTXnL3WE_SHIFT 12 -#define HC_HTXnL4WE_SHIFT 16 -#define HC_HTXnL5WE_SHIFT 20 -/* HC_SubA_HTXnL6_bWE 0x004c - */ -#define HC_HTXnL6WE_MASK 0x0000000f -#define HC_HTXnL7WE_MASK 0x000000f0 -#define HC_HTXnL8WE_MASK 0x00000f00 -#define HC_HTXnL9WE_MASK 0x0000f000 -#define HC_HTXnLaWE_MASK 0x000f0000 -#define HC_HTXnLbWE_MASK 0x00f00000 -#define HC_HTXnL7WE_SHIFT 4 -#define HC_HTXnL8WE_SHIFT 8 -#define HC_HTXnL9WE_SHIFT 12 -#define HC_HTXnLaWE_SHIFT 16 -#define HC_HTXnLbWE_SHIFT 20 -/* HC_SubA_HTXnLc_11WE 0x004d - */ -#define HC_HTXnLcWE_MASK 0x0000000f -#define HC_HTXnLdWE_MASK 0x000000f0 -#define HC_HTXnLeWE_MASK 0x00000f00 -#define HC_HTXnLfWE_MASK 0x0000f000 -#define HC_HTXnL10WE_MASK 0x000f0000 -#define HC_HTXnL11WE_MASK 0x00f00000 -#define HC_HTXnLdWE_SHIFT 4 -#define HC_HTXnLeWE_SHIFT 8 -#define HC_HTXnLfWE_SHIFT 12 -#define HC_HTXnL10WE_SHIFT 16 -#define HC_HTXnL11WE_SHIFT 20 -/* HC_SubA_HTXnL0_5HE 0x0051 - */ -#define HC_HTXnL0HE_MASK 0x0000000f -#define HC_HTXnL1HE_MASK 0x000000f0 -#define HC_HTXnL2HE_MASK 0x00000f00 -#define HC_HTXnL3HE_MASK 0x0000f000 -#define HC_HTXnL4HE_MASK 0x000f0000 -#define HC_HTXnL5HE_MASK 0x00f00000 -#define HC_HTXnL1HE_SHIFT 4 -#define HC_HTXnL2HE_SHIFT 8 -#define HC_HTXnL3HE_SHIFT 12 -#define HC_HTXnL4HE_SHIFT 16 -#define HC_HTXnL5HE_SHIFT 20 -/* HC_SubA_HTXnL6_bHE 0x0052 - */ -#define HC_HTXnL6HE_MASK 0x0000000f -#define HC_HTXnL7HE_MASK 0x000000f0 -#define HC_HTXnL8HE_MASK 0x00000f00 -#define HC_HTXnL9HE_MASK 0x0000f000 -#define HC_HTXnLaHE_MASK 0x000f0000 -#define HC_HTXnLbHE_MASK 0x00f00000 -#define HC_HTXnL7HE_SHIFT 4 -#define HC_HTXnL8HE_SHIFT 8 -#define HC_HTXnL9HE_SHIFT 12 -#define HC_HTXnLaHE_SHIFT 16 -#define HC_HTXnLbHE_SHIFT 20 -/* HC_SubA_HTXnLc_11HE 0x0053 - */ -#define HC_HTXnLcHE_MASK 0x0000000f -#define HC_HTXnLdHE_MASK 0x000000f0 -#define HC_HTXnLeHE_MASK 0x00000f00 -#define HC_HTXnLfHE_MASK 0x0000f000 -#define HC_HTXnL10HE_MASK 0x000f0000 -#define HC_HTXnL11HE_MASK 0x00f00000 -#define HC_HTXnLdHE_SHIFT 4 -#define HC_HTXnLeHE_SHIFT 8 -#define HC_HTXnLfHE_SHIFT 12 -#define HC_HTXnL10HE_SHIFT 16 -#define HC_HTXnL11HE_SHIFT 20 -/* HC_SubA_HTXnL0OS 0x0077 - */ -#define HC_HTXnL0OS_MASK 0x003ff000 -#define HC_HTXnLVmax_MASK 0x00000fc0 -#define HC_HTXnLVmin_MASK 0x0000003f -#define HC_HTXnL0OS_SHIFT 12 -#define HC_HTXnLVmax_SHIFT 6 -/* HC_SubA_HTXnTB 0x0078 - */ -#define HC_HTXnTB_MASK 0x00f00000 -#define HC_HTXnFLSe_MASK 0x0000e000 -#define HC_HTXnFLSs_MASK 0x00001c00 -#define HC_HTXnFLTe_MASK 0x00000380 -#define HC_HTXnFLTs_MASK 0x00000070 -#define HC_HTXnFLDs_MASK 0x0000000f -#define HC_HTXnTB_NoTB 0x00000000 -#define HC_HTXnTB_TBC_S 0x00100000 -#define HC_HTXnTB_TBC_T 0x00200000 -#define HC_HTXnTB_TB_S 0x00400000 -#define HC_HTXnTB_TB_T 0x00800000 - -/* The "S" in FLS? means the S texture coordinate, and a "T" means the T - * texture coordinage. The "e" in FL?e means the magnification ("enlarge") - * mode, and the "s" in FL?s means the minification ("shrink") mode. - * - * The "D" in FLD? means the intermipmap level mode. That means that the - * GL_*_MIPMAP_LINEAR modes get FLDs_Linear, and the GL_*_MIPMAP_NEAREST modes - * get FLDs_Nearest. - */ -#define HC_HTXnFLSe_Nearest 0x00000000 -#define HC_HTXnFLSe_Linear 0x00002000 -#define HC_HTXnFLSe_NonLinear 0x00004000 -#define HC_HTXnFLSe_Sharp 0x00008000 -#define HC_HTXnFLSe_Flat_Gaussian_Cubic 0x0000c000 -#define HC_HTXnFLSs_Nearest 0x00000000 -#define HC_HTXnFLSs_Linear 0x00000400 -#define HC_HTXnFLSs_NonLinear 0x00000800 -#define HC_HTXnFLSs_Flat_Gaussian_Cubic 0x00001800 -#define HC_HTXnFLTe_Nearest 0x00000000 -#define HC_HTXnFLTe_Linear 0x00000080 -#define HC_HTXnFLTe_NonLinear 0x00000100 -#define HC_HTXnFLTe_Sharp 0x00000180 -#define HC_HTXnFLTe_Flat_Gaussian_Cubic 0x00000300 -#define HC_HTXnFLTs_Nearest 0x00000000 -#define HC_HTXnFLTs_Linear 0x00000010 -#define HC_HTXnFLTs_NonLinear 0x00000020 -#define HC_HTXnFLTs_Flat_Gaussian_Cubic 0x00000060 -#define HC_HTXnFLDs_Tex0 0x00000000 -#define HC_HTXnFLDs_Nearest 0x00000001 -#define HC_HTXnFLDs_Linear 0x00000002 -#define HC_HTXnFLDs_NonLinear 0x00000003 -#define HC_HTXnFLDs_Dither 0x00000004 -#define HC_HTXnFLDs_ConstLOD 0x00000005 -#define HC_HTXnFLDs_Ani 0x00000006 -#define HC_HTXnFLDs_AniDither 0x00000007 - -/* HC_SubA_HTXnMPMD 0x0079 - */ -#define HC_HTXnMPMD_SMASK 0x00070000 -#define HC_HTXnMPMD_TMASK 0x00380000 -#define HC_HTXnLODDTf_MASK 0x00000007 -#define HC_HTXnXY2ST_MASK 0x00000008 -#define HC_HTXnMPMD_Tsingle 0x00000000 -#define HC_HTXnMPMD_Tclamp 0x00080000 -#define HC_HTXnMPMD_Trepeat 0x00100000 -#define HC_HTXnMPMD_Tmirror 0x00180000 -#define HC_HTXnMPMD_Twrap 0x00200000 -#define HC_HTXnMPMD_Ssingle 0x00000000 -#define HC_HTXnMPMD_Sclamp 0x00010000 -#define HC_HTXnMPMD_Srepeat 0x00020000 -#define HC_HTXnMPMD_Smirror 0x00030000 -#define HC_HTXnMPMD_Swrap 0x00040000 -/* HC_SubA_HTXnCLODu 0x007a - */ -#define HC_HTXnCLODu_MASK 0x000ffc00 -#define HC_HTXnCLODd_MASK 0x000003ff -#define HC_HTXnCLODu_SHIFT 10 -/* HC_SubA_HTXnFM 0x007b - */ -#define HC_HTXnFM_MASK 0x00ff0000 -#define HC_HTXnLoc_MASK 0x00000003 -#define HC_HTXnFM_INDEX 0x00000000 /* 0 << 19 */ -#define HC_HTXnFM_Intensity 0x00080000 /* 1 << 19 */ -#define HC_HTXnFM_Lum 0x00100000 /* 2 << 19 */ -#define HC_HTXnFM_Alpha 0x00180000 /* 3 << 19 */ -#define HC_HTXnFM_DX 0x00280000 /* 5 << 19 */ -#define HC_HTXnFM_BUMPMAP 0x00380000 /* 7 << 19 */ -#define HC_HTXnFM_ARGB16 0x00880000 /* 17 << 19 */ -#define HC_HTXnFM_ARGB32 0x00980000 /* 19 << 19 */ -#define HC_HTXnFM_ABGR16 0x00a80000 /* 21 << 19 */ -#define HC_HTXnFM_ABGR32 0x00b80000 /* 23 << 19 */ -#define HC_HTXnFM_RGBA16 0x00c80000 /* 25 << 19 */ -#define HC_HTXnFM_RGBA32 0x00d80000 /* 27 << 19 */ -#define HC_HTXnFM_BGRA16 0x00e80000 /* 29 << 19 */ -#define HC_HTXnFM_BGRA32 0x00f80000 /* 31 << 19 */ -#define HC_HTXnFM_Index1 (HC_HTXnFM_INDEX | 0x00000000) -#define HC_HTXnFM_Index2 (HC_HTXnFM_INDEX | 0x00010000) -#define HC_HTXnFM_Index4 (HC_HTXnFM_INDEX | 0x00020000) -#define HC_HTXnFM_Index8 (HC_HTXnFM_INDEX | 0x00030000) -#define HC_HTXnFM_T1 (HC_HTXnFM_Intensity | 0x00000000) -#define HC_HTXnFM_T2 (HC_HTXnFM_Intensity | 0x00010000) -#define HC_HTXnFM_T4 (HC_HTXnFM_Intensity | 0x00020000) -#define HC_HTXnFM_T8 (HC_HTXnFM_Intensity | 0x00030000) -#define HC_HTXnFM_L1 (HC_HTXnFM_Lum | 0x00000000) -#define HC_HTXnFM_L2 (HC_HTXnFM_Lum | 0x00010000) -#define HC_HTXnFM_L4 (HC_HTXnFM_Lum | 0x00020000) -#define HC_HTXnFM_L8 (HC_HTXnFM_Lum | 0x00030000) -#define HC_HTXnFM_AL44 (HC_HTXnFM_Lum | 0x00040000) -#define HC_HTXnFM_AL88 (HC_HTXnFM_Lum | 0x00050000) -#define HC_HTXnFM_A1 (HC_HTXnFM_Alpha | 0x00000000) -#define HC_HTXnFM_A2 (HC_HTXnFM_Alpha | 0x00010000) -#define HC_HTXnFM_A4 (HC_HTXnFM_Alpha | 0x00020000) -#define HC_HTXnFM_A8 (HC_HTXnFM_Alpha | 0x00030000) -#define HC_HTXnFM_DX1 (HC_HTXnFM_DX | 0x00010000) -#define HC_HTXnFM_DX23 (HC_HTXnFM_DX | 0x00020000) -#define HC_HTXnFM_DX45 (HC_HTXnFM_DX | 0x00030000) -#define HC_HTXnFM_RGB555 (HC_HTXnFM_ARGB16 | 0x00000000) -#define HC_HTXnFM_RGB565 (HC_HTXnFM_ARGB16 | 0x00010000) -#define HC_HTXnFM_ARGB1555 (HC_HTXnFM_ARGB16 | 0x00020000) -#define HC_HTXnFM_ARGB4444 (HC_HTXnFM_ARGB16 | 0x00030000) -#define HC_HTXnFM_ARGB0888 (HC_HTXnFM_ARGB32 | 0x00000000) -#define HC_HTXnFM_ARGB8888 (HC_HTXnFM_ARGB32 | 0x00010000) -#define HC_HTXnFM_BGR555 (HC_HTXnFM_ABGR16 | 0x00000000) -#define HC_HTXnFM_BGR565 (HC_HTXnFM_ABGR16 | 0x00010000) -#define HC_HTXnFM_ABGR1555 (HC_HTXnFM_ABGR16 | 0x00020000) -#define HC_HTXnFM_ABGR4444 (HC_HTXnFM_ABGR16 | 0x00030000) -#define HC_HTXnFM_ABGR0888 (HC_HTXnFM_ABGR32 | 0x00000000) -#define HC_HTXnFM_ABGR8888 (HC_HTXnFM_ABGR32 | 0x00010000) -#define HC_HTXnFM_RGBA5550 (HC_HTXnFM_RGBA16 | 0x00000000) -#define HC_HTXnFM_RGBA5551 (HC_HTXnFM_RGBA16 | 0x00020000) -#define HC_HTXnFM_RGBA4444 (HC_HTXnFM_RGBA16 | 0x00030000) -#define HC_HTXnFM_RGBA8880 (HC_HTXnFM_RGBA32 | 0x00000000) -#define HC_HTXnFM_RGBA8888 (HC_HTXnFM_RGBA32 | 0x00010000) -#define HC_HTXnFM_BGRA5550 (HC_HTXnFM_BGRA16 | 0x00000000) -#define HC_HTXnFM_BGRA5551 (HC_HTXnFM_BGRA16 | 0x00020000) -#define HC_HTXnFM_BGRA4444 (HC_HTXnFM_BGRA16 | 0x00030000) -#define HC_HTXnFM_BGRA8880 (HC_HTXnFM_BGRA32 | 0x00000000) -#define HC_HTXnFM_BGRA8888 (HC_HTXnFM_BGRA32 | 0x00010000) -#define HC_HTXnFM_VU88 (HC_HTXnFM_BUMPMAP | 0x00000000) -#define HC_HTXnFM_LVU655 (HC_HTXnFM_BUMPMAP | 0x00010000) -#define HC_HTXnFM_LVU888 (HC_HTXnFM_BUMPMAP | 0x00020000) -#define HC_HTXnLoc_Local 0x00000000 -#define HC_HTXnLoc_Sys 0x00000002 -#define HC_HTXnLoc_AGP 0x00000003 -/* HC_SubA_HTXnTRAH 0x007f - */ -#define HC_HTXnTRAH_MASK 0x00ff0000 -#define HC_HTXnTRAL_MASK 0x0000ff00 -#define HC_HTXnTBA_MASK 0x000000ff -#define HC_HTXnTRAH_SHIFT 16 -#define HC_HTXnTRAL_SHIFT 8 - -/*-- Define the input texture, for below - */ -#define HC_XTC_TOPC 0x00000000 -#define HC_XTC_InvTOPC 0x00000010 -#define HC_XTC_TOPCp5 0x00000020 -#define HC_XTC_Cbias 0x00000000 -#define HC_XTC_InvCbias 0x00000010 -#define HC_XTC_0 0x00000000 -#define HC_XTC_Dif 0x00000001 -#define HC_XTC_Spec 0x00000002 -#define HC_XTC_Tex 0x00000003 -#define HC_XTC_Cur 0x00000004 -#define HC_XTC_Adif 0x00000005 -#define HC_XTC_Fog 0x00000006 -#define HC_XTC_Atex 0x00000007 -#define HC_XTC_Acur 0x00000008 -#define HC_XTC_HTXnTBLRC 0x00000009 -#define HC_XTC_Ctexnext 0x0000000a -/** HC_SubA_HTXnTBLCsat 0x0080 - */ -#define HC_HTXnTBLCsat_MASK 0x00800000 -#define HC_HTXnTBLCa_MASK 0x000fc000 -#define HC_HTXnTBLCb_MASK 0x00001f80 -#define HC_HTXnTBLCc_MASK 0x0000003f -#define HC_HTXnTBLCa_TOPC (HC_XTC_TOPC << 14) -#define HC_HTXnTBLCa_InvTOPC (HC_XTC_InvTOPC << 14) -#define HC_HTXnTBLCa_TOPCp5 (HC_XTC_TOPCp5 << 14) -#define HC_HTXnTBLCa_0 (HC_XTC_0 << 14) -#define HC_HTXnTBLCa_Dif (HC_XTC_Dif << 14) -#define HC_HTXnTBLCa_Spec (HC_XTC_Spec << 14) -#define HC_HTXnTBLCa_Tex (HC_XTC_Tex << 14) -#define HC_HTXnTBLCa_Cur (HC_XTC_Cur << 14) -#define HC_HTXnTBLCa_Adif (HC_XTC_Adif << 14) -#define HC_HTXnTBLCa_Fog (HC_XTC_Fog << 14) -#define HC_HTXnTBLCa_Atex (HC_XTC_Atex << 14) -#define HC_HTXnTBLCa_Acur (HC_XTC_Acur << 14) -#define HC_HTXnTBLCa_HTXnTBLRC (HC_XTC_HTXnTBLRC << 14) -#define HC_HTXnTBLCa_Ctexnext (HC_XTC_Ctexnext << 14) -#define HC_HTXnTBLCb_TOPC (HC_XTC_TOPC << 7) -#define HC_HTXnTBLCb_InvTOPC (HC_XTC_InvTOPC << 7) -#define HC_HTXnTBLCb_TOPCp5 (HC_XTC_TOPCp5 << 7) -#define HC_HTXnTBLCb_0 (HC_XTC_0 << 7) -#define HC_HTXnTBLCb_Dif (HC_XTC_Dif << 7) -#define HC_HTXnTBLCb_Spec (HC_XTC_Spec << 7) -#define HC_HTXnTBLCb_Tex (HC_XTC_Tex << 7) -#define HC_HTXnTBLCb_Cur (HC_XTC_Cur << 7) -#define HC_HTXnTBLCb_Adif (HC_XTC_Adif << 7) -#define HC_HTXnTBLCb_Fog (HC_XTC_Fog << 7) -#define HC_HTXnTBLCb_Atex (HC_XTC_Atex << 7) -#define HC_HTXnTBLCb_Acur (HC_XTC_Acur << 7) -#define HC_HTXnTBLCb_HTXnTBLRC (HC_XTC_HTXnTBLRC << 7) -#define HC_HTXnTBLCb_Ctexnext (HC_XTC_Ctexnext << 7) -#define HC_HTXnTBLCc_TOPC (HC_XTC_TOPC << 0) -#define HC_HTXnTBLCc_InvTOPC (HC_XTC_InvTOPC << 0) -#define HC_HTXnTBLCc_TOPCp5 (HC_XTC_TOPCp5 << 0) -#define HC_HTXnTBLCc_0 (HC_XTC_0 << 0) -#define HC_HTXnTBLCc_Dif (HC_XTC_Dif << 0) -#define HC_HTXnTBLCc_Spec (HC_XTC_Spec << 0) -#define HC_HTXnTBLCc_Tex (HC_XTC_Tex << 0) -#define HC_HTXnTBLCc_Cur (HC_XTC_Cur << 0) -#define HC_HTXnTBLCc_Adif (HC_XTC_Adif << 0) -#define HC_HTXnTBLCc_Fog (HC_XTC_Fog << 0) -#define HC_HTXnTBLCc_Atex (HC_XTC_Atex << 0) -#define HC_HTXnTBLCc_Acur (HC_XTC_Acur << 0) -#define HC_HTXnTBLCc_HTXnTBLRC (HC_XTC_HTXnTBLRC << 0) -#define HC_HTXnTBLCc_Ctexnext (HC_XTC_Ctexnext << 0) -/* HC_SubA_HTXnTBLCop 0x0081 - */ -#define HC_HTXnTBLdot_MASK 0x00c00000 -#define HC_HTXnTBLCop_MASK 0x00380000 -#define HC_HTXnTBLCbias_MASK 0x0007c000 -#define HC_HTXnTBLCshift_MASK 0x00001800 -#define HC_HTXnTBLAop_MASK 0x00000380 -#define HC_HTXnTBLAbias_MASK 0x00000078 -#define HC_HTXnTBLAshift_MASK 0x00000003 -#define HC_HTXnTBLDOT3 0x00800000 -#define HC_HTXnTBLDOT4 0x00c00000 -#define HC_HTXnTBLCop_Add 0x00000000 -#define HC_HTXnTBLCop_Sub 0x00080000 -#define HC_HTXnTBLCop_Min 0x00100000 -#define HC_HTXnTBLCop_Max 0x00180000 -#define HC_HTXnTBLCop_Mask 0x00200000 -#define HC_HTXnTBLCbias_Cbias (HC_XTC_Cbias << 14) -#define HC_HTXnTBLCbias_InvCbias (HC_XTC_InvCbias << 14) -#define HC_HTXnTBLCbias_0 (HC_XTC_0 << 14) -#define HC_HTXnTBLCbias_Dif (HC_XTC_Dif << 14) -#define HC_HTXnTBLCbias_Spec (HC_XTC_Spec << 14) -#define HC_HTXnTBLCbias_Tex (HC_XTC_Tex << 14) -#define HC_HTXnTBLCbias_Cur (HC_XTC_Cur << 14) -#define HC_HTXnTBLCbias_Adif (HC_XTC_Adif << 14) -#define HC_HTXnTBLCbias_Fog (HC_XTC_Fog << 14) -#define HC_HTXnTBLCbias_Atex (HC_XTC_Atex << 14) -#define HC_HTXnTBLCbias_Acur (HC_XTC_Acur << 14) -#define HC_HTXnTBLCbias_HTXnTBLRC (HC_XTC_HTXnTBLRC << 14) -#define HC_HTXnTBLCshift_1 0x00000000 -#define HC_HTXnTBLCshift_2 0x00000800 -#define HC_HTXnTBLCshift_No 0x00001000 -#define HC_HTXnTBLCshift_DotP 0x00001800 -#define HC_HTXnTBLAop_Add 0x00000000 -#define HC_HTXnTBLAop_Sub 0x00000080 -#define HC_HTXnTBLAop_Min 0x00000100 -#define HC_HTXnTBLAop_Max 0x00000180 -#define HC_HTXnTBLAop_Mask 0x00000200 -#define HC_HTXnTBLAbias_Inv 0x00000040 -#define HC_HTXnTBLAbias_Adif 0x00000000 -#define HC_HTXnTBLAbias_Fog 0x00000008 -#define HC_HTXnTBLAbias_Acur 0x00000010 -#define HC_HTXnTBLAbias_HTXnTBLRAbias 0x00000018 -#define HC_HTXnTBLAbias_Atex 0x00000020 -#define HC_HTXnTBLAshift_1 0x00000000 -#define HC_HTXnTBLAshift_2 0x00000001 -#define HC_HTXnTBLAshift_No 0x00000002 -#define HC_HTXnTBLAshift_DotP 0x00000003 -/* HC_SubA_HTXnTBLMPFog 0x0082 - */ -#define HC_HTXnTBLMPfog_MASK 0x00e00000 -#define HC_HTXnTBLMPfog_0 0x00000000 -#define HC_HTXnTBLMPfog_Adif 0x00200000 -#define HC_HTXnTBLMPfog_Fog 0x00400000 -#define HC_HTXnTBLMPfog_Atex 0x00600000 -#define HC_HTXnTBLMPfog_Acur 0x00800000 -#define HC_HTXnTBLMPfog_GHTXnTBLRFog 0x00a00000 -/* HC_SubA_HTXnTBLAsat 0x0083 - *-- Define the texture alpha input. - */ -#define HC_XTA_TOPA 0x00000000 -#define HC_XTA_InvTOPA 0x00000008 -#define HC_XTA_TOPAp5 0x00000010 -#define HC_XTA_Adif 0x00000000 -#define HC_XTA_Fog 0x00000001 -#define HC_XTA_Acur 0x00000002 -#define HC_XTA_HTXnTBLRA 0x00000003 -#define HC_XTA_Atex 0x00000004 -#define HC_XTA_Atexnext 0x00000005 -/*-- - */ -#define HC_HTXnTBLAsat_MASK 0x00800000 -#define HC_HTXnTBLAMB_MASK 0x00700000 -#define HC_HTXnTBLAa_MASK 0x0007c000 -#define HC_HTXnTBLAb_MASK 0x00000f80 -#define HC_HTXnTBLAc_MASK 0x0000001f -#define HC_HTXnTBLAMB_SHIFT 20 -#define HC_HTXnTBLAa_TOPA (HC_XTA_TOPA << 14) -#define HC_HTXnTBLAa_InvTOPA (HC_XTA_InvTOPA << 14) -#define HC_HTXnTBLAa_TOPAp5 (HC_XTA_TOPAp5 << 14) -#define HC_HTXnTBLAa_Adif (HC_XTA_Adif << 14) -#define HC_HTXnTBLAa_Fog (HC_XTA_Fog << 14) -#define HC_HTXnTBLAa_Acur (HC_XTA_Acur << 14) -#define HC_HTXnTBLAa_HTXnTBLRA (HC_XTA_HTXnTBLRA << 14) -#define HC_HTXnTBLAa_Atex (HC_XTA_Atex << 14) -#define HC_HTXnTBLAa_Atexnext (HC_XTA_Atexnext << 14) -#define HC_HTXnTBLAb_TOPA (HC_XTA_TOPA << 7) -#define HC_HTXnTBLAb_InvTOPA (HC_XTA_InvTOPA << 7) -#define HC_HTXnTBLAb_TOPAp5 (HC_XTA_TOPAp5 << 7) -#define HC_HTXnTBLAb_Adif (HC_XTA_Adif << 7) -#define HC_HTXnTBLAb_Fog (HC_XTA_Fog << 7) -#define HC_HTXnTBLAb_Acur (HC_XTA_Acur << 7) -#define HC_HTXnTBLAb_HTXnTBLRA (HC_XTA_HTXnTBLRA << 7) -#define HC_HTXnTBLAb_Atex (HC_XTA_Atex << 7) -#define HC_HTXnTBLAb_Atexnext (HC_XTA_Atexnext << 7) -#define HC_HTXnTBLAc_TOPA (HC_XTA_TOPA << 0) -#define HC_HTXnTBLAc_InvTOPA (HC_XTA_InvTOPA << 0) -#define HC_HTXnTBLAc_TOPAp5 (HC_XTA_TOPAp5 << 0) -#define HC_HTXnTBLAc_Adif (HC_XTA_Adif << 0) -#define HC_HTXnTBLAc_Fog (HC_XTA_Fog << 0) -#define HC_HTXnTBLAc_Acur (HC_XTA_Acur << 0) -#define HC_HTXnTBLAc_HTXnTBLRA (HC_XTA_HTXnTBLRA << 0) -#define HC_HTXnTBLAc_Atex (HC_XTA_Atex << 0) -#define HC_HTXnTBLAc_Atexnext (HC_XTA_Atexnext << 0) -/* HC_SubA_HTXnTBLRAa 0x0089 - */ -#define HC_HTXnTBLRAa_MASK 0x00ff0000 -#define HC_HTXnTBLRAb_MASK 0x0000ff00 -#define HC_HTXnTBLRAc_MASK 0x000000ff -#define HC_HTXnTBLRAa_SHIFT 16 -#define HC_HTXnTBLRAb_SHIFT 8 -#define HC_HTXnTBLRAc_SHIFT 0 -/* HC_SubA_HTXnTBLRFog 0x008a - */ -#define HC_HTXnTBLRFog_MASK 0x0000ff00 -#define HC_HTXnTBLRAbias_MASK 0x000000ff -#define HC_HTXnTBLRFog_SHIFT 8 -#define HC_HTXnTBLRAbias_SHIFT 0 -/* HC_SubA_HTXnLScale 0x0094 - */ -#define HC_HTXnLScale_MASK 0x0007fc00 -#define HC_HTXnLOff_MASK 0x000001ff -#define HC_HTXnLScale_SHIFT 10 -/* HC_SubA_HTXSMD 0x0000 - */ -#define HC_HTXSMD_MASK 0x00000080 -#define HC_HTXTMD_MASK 0x00000040 -#define HC_HTXNum_MASK 0x00000038 -#define HC_HTXTRMD_MASK 0x00000006 -#define HC_HTXCHCLR_MASK 0x00000001 -#define HC_HTXNum_SHIFT 3 - -/* Texture Palette n - */ -#define HC_SubType_TexPalette0 0x00000000 -#define HC_SubType_TexPalette1 0x00000001 -#define HC_SubType_FogTable 0x00000010 -#define HC_SubType_Stipple 0x00000014 -/* HC_SubA_TexPalette0 0x0000 - */ -#define HC_HTPnA_MASK 0xff000000 -#define HC_HTPnR_MASK 0x00ff0000 -#define HC_HTPnG_MASK 0x0000ff00 -#define HC_HTPnB_MASK 0x000000ff -/* HC_SubA_FogTable 0x0010 - */ -#define HC_HFPn3_MASK 0xff000000 -#define HC_HFPn2_MASK 0x00ff0000 -#define HC_HFPn1_MASK 0x0000ff00 -#define HC_HFPn_MASK 0x000000ff -#define HC_HFPn3_SHIFT 24 -#define HC_HFPn2_SHIFT 16 -#define HC_HFPn1_SHIFT 8 - -/* Auto Testing & Security - */ -#define HC_SubA_HenFIFOAT 0x0000 -#define HC_SubA_HFBDrawFirst 0x0004 -#define HC_SubA_HFBBasL 0x0005 -#define HC_SubA_HFBDst 0x0006 -/* HC_SubA_HenFIFOAT 0x0000 - */ -#define HC_HenFIFOAT_MASK 0x00000020 -#define HC_HenGEMILock_MASK 0x00000010 -#define HC_HenFBASwap_MASK 0x00000008 -#define HC_HenOT_MASK 0x00000004 -#define HC_HenCMDQ_MASK 0x00000002 -#define HC_HenTXCTSU_MASK 0x00000001 -/* HC_SubA_HFBDrawFirst 0x0004 - */ -#define HC_HFBDrawFirst_MASK 0x00000800 -#define HC_HFBQueue_MASK 0x00000400 -#define HC_HFBLock_MASK 0x00000200 -#define HC_HEOF_MASK 0x00000100 -#define HC_HFBBasH_MASK 0x000000ff - -/* GEMI Setting - */ -#define HC_SubA_HTArbRCM 0x0008 -#define HC_SubA_HTArbRZ 0x000a -#define HC_SubA_HTArbWZ 0x000b -#define HC_SubA_HTArbRTX 0x000c -#define HC_SubA_HTArbRCW 0x000d -#define HC_SubA_HTArbE2 0x000e -#define HC_SubA_HArbRQCM 0x0010 -#define HC_SubA_HArbWQCM 0x0011 -#define HC_SubA_HGEMITout 0x0020 -#define HC_SubA_HFthRTXD 0x0040 -#define HC_SubA_HFthRTXA 0x0044 -#define HC_SubA_HCMDQstL 0x0050 -#define HC_SubA_HCMDQendL 0x0051 -#define HC_SubA_HCMDQLen 0x0052 -/* HC_SubA_HTArbRCM 0x0008 - */ -#define HC_HTArbRCM_MASK 0x0000ffff -/* HC_SubA_HTArbRZ 0x000a - */ -#define HC_HTArbRZ_MASK 0x0000ffff -/* HC_SubA_HTArbWZ 0x000b - */ -#define HC_HTArbWZ_MASK 0x0000ffff -/* HC_SubA_HTArbRTX 0x000c - */ -#define HC_HTArbRTX_MASK 0x0000ffff -/* HC_SubA_HTArbRCW 0x000d - */ -#define HC_HTArbRCW_MASK 0x0000ffff -/* HC_SubA_HTArbE2 0x000e - */ -#define HC_HTArbE2_MASK 0x0000ffff -/* HC_SubA_HArbRQCM 0x0010 - */ -#define HC_HTArbRQCM_MASK 0x0000ffff -/* HC_SubA_HArbWQCM 0x0011 - */ -#define HC_HArbWQCM_MASK 0x0000ffff -/* HC_SubA_HGEMITout 0x0020 - */ -#define HC_HGEMITout_MASK 0x000f0000 -#define HC_HNPArbZC_MASK 0x0000ffff -#define HC_HGEMITout_SHIFT 16 -/* HC_SubA_HFthRTXD 0x0040 - */ -#define HC_HFthRTXD_MASK 0x00ff0000 -#define HC_HFthRZD_MASK 0x0000ff00 -#define HC_HFthWZD_MASK 0x000000ff -#define HC_HFthRTXD_SHIFT 16 -#define HC_HFthRZD_SHIFT 8 -/* HC_SubA_HFthRTXA 0x0044 - */ -#define HC_HFthRTXA_MASK 0x000000ff - -/****************************************************************************** -** Define the Halcyon Internal register access constants. For simulator only. -******************************************************************************/ -#define HC_SIMA_HAGPBstL 0x0000 -#define HC_SIMA_HAGPBendL 0x0001 -#define HC_SIMA_HAGPCMNT 0x0002 -#define HC_SIMA_HAGPBpL 0x0003 -#define HC_SIMA_HAGPBpH 0x0004 -#define HC_SIMA_HClipTB 0x0005 -#define HC_SIMA_HClipLR 0x0006 -#define HC_SIMA_HFPClipTL 0x0007 -#define HC_SIMA_HFPClipBL 0x0008 -#define HC_SIMA_HFPClipLL 0x0009 -#define HC_SIMA_HFPClipRL 0x000a -#define HC_SIMA_HFPClipTBH 0x000b -#define HC_SIMA_HFPClipLRH 0x000c -#define HC_SIMA_HLP 0x000d -#define HC_SIMA_HLPRF 0x000e -#define HC_SIMA_HSolidCL 0x000f -#define HC_SIMA_HPixGC 0x0010 -#define HC_SIMA_HSPXYOS 0x0011 -#define HC_SIMA_HCmdA 0x0012 -#define HC_SIMA_HCmdB 0x0013 -#define HC_SIMA_HEnable 0x0014 -#define HC_SIMA_HZWBBasL 0x0015 -#define HC_SIMA_HZWBBasH 0x0016 -#define HC_SIMA_HZWBType 0x0017 -#define HC_SIMA_HZBiasL 0x0018 -#define HC_SIMA_HZWBend 0x0019 -#define HC_SIMA_HZWTMD 0x001a -#define HC_SIMA_HZWCDL 0x001b -#define HC_SIMA_HZWCTAGnum 0x001c -#define HC_SIMA_HZCYNum 0x001d -#define HC_SIMA_HZWCFire 0x001e -/* #define HC_SIMA_HSBBasL 0x001d */ -/* #define HC_SIMA_HSBBasH 0x001e */ -/* #define HC_SIMA_HSBFM 0x001f */ -#define HC_SIMA_HSTREF 0x0020 -#define HC_SIMA_HSTMD 0x0021 -#define HC_SIMA_HABBasL 0x0022 -#define HC_SIMA_HABBasH 0x0023 -#define HC_SIMA_HABFM 0x0024 -#define HC_SIMA_HATMD 0x0025 -#define HC_SIMA_HABLCsat 0x0026 -#define HC_SIMA_HABLCop 0x0027 -#define HC_SIMA_HABLAsat 0x0028 -#define HC_SIMA_HABLAop 0x0029 -#define HC_SIMA_HABLRCa 0x002a -#define HC_SIMA_HABLRFCa 0x002b -#define HC_SIMA_HABLRCbias 0x002c -#define HC_SIMA_HABLRCb 0x002d -#define HC_SIMA_HABLRFCb 0x002e -#define HC_SIMA_HABLRAa 0x002f -#define HC_SIMA_HABLRAb 0x0030 -#define HC_SIMA_HDBBasL 0x0031 -#define HC_SIMA_HDBBasH 0x0032 -#define HC_SIMA_HDBFM 0x0033 -#define HC_SIMA_HFBBMSKL 0x0034 -#define HC_SIMA_HROP 0x0035 -#define HC_SIMA_HFogLF 0x0036 -#define HC_SIMA_HFogCL 0x0037 -#define HC_SIMA_HFogCH 0x0038 -#define HC_SIMA_HFogStL 0x0039 -#define HC_SIMA_HFogStH 0x003a -#define HC_SIMA_HFogOOdMF 0x003b -#define HC_SIMA_HFogOOdEF 0x003c -#define HC_SIMA_HFogEndL 0x003d -#define HC_SIMA_HFogDenst 0x003e -/*---- start of texture 0 setting ---- - */ -#define HC_SIMA_HTX0L0BasL 0x0040 -#define HC_SIMA_HTX0L1BasL 0x0041 -#define HC_SIMA_HTX0L2BasL 0x0042 -#define HC_SIMA_HTX0L3BasL 0x0043 -#define HC_SIMA_HTX0L4BasL 0x0044 -#define HC_SIMA_HTX0L5BasL 0x0045 -#define HC_SIMA_HTX0L6BasL 0x0046 -#define HC_SIMA_HTX0L7BasL 0x0047 -#define HC_SIMA_HTX0L8BasL 0x0048 -#define HC_SIMA_HTX0L9BasL 0x0049 -#define HC_SIMA_HTX0LaBasL 0x004a -#define HC_SIMA_HTX0LbBasL 0x004b -#define HC_SIMA_HTX0LcBasL 0x004c -#define HC_SIMA_HTX0LdBasL 0x004d -#define HC_SIMA_HTX0LeBasL 0x004e -#define HC_SIMA_HTX0LfBasL 0x004f -#define HC_SIMA_HTX0L10BasL 0x0050 -#define HC_SIMA_HTX0L11BasL 0x0051 -#define HC_SIMA_HTX0L012BasH 0x0052 -#define HC_SIMA_HTX0L345BasH 0x0053 -#define HC_SIMA_HTX0L678BasH 0x0054 -#define HC_SIMA_HTX0L9abBasH 0x0055 -#define HC_SIMA_HTX0LcdeBasH 0x0056 -#define HC_SIMA_HTX0Lf1011BasH 0x0057 -#define HC_SIMA_HTX0L0Pit 0x0058 -#define HC_SIMA_HTX0L1Pit 0x0059 -#define HC_SIMA_HTX0L2Pit 0x005a -#define HC_SIMA_HTX0L3Pit 0x005b -#define HC_SIMA_HTX0L4Pit 0x005c -#define HC_SIMA_HTX0L5Pit 0x005d -#define HC_SIMA_HTX0L6Pit 0x005e -#define HC_SIMA_HTX0L7Pit 0x005f -#define HC_SIMA_HTX0L8Pit 0x0060 -#define HC_SIMA_HTX0L9Pit 0x0061 -#define HC_SIMA_HTX0LaPit 0x0062 -#define HC_SIMA_HTX0LbPit 0x0063 -#define HC_SIMA_HTX0LcPit 0x0064 -#define HC_SIMA_HTX0LdPit 0x0065 -#define HC_SIMA_HTX0LePit 0x0066 -#define HC_SIMA_HTX0LfPit 0x0067 -#define HC_SIMA_HTX0L10Pit 0x0068 -#define HC_SIMA_HTX0L11Pit 0x0069 -#define HC_SIMA_HTX0L0_5WE 0x006a -#define HC_SIMA_HTX0L6_bWE 0x006b -#define HC_SIMA_HTX0Lc_11WE 0x006c -#define HC_SIMA_HTX0L0_5HE 0x006d -#define HC_SIMA_HTX0L6_bHE 0x006e -#define HC_SIMA_HTX0Lc_11HE 0x006f -#define HC_SIMA_HTX0L0OS 0x0070 -#define HC_SIMA_HTX0TB 0x0071 -#define HC_SIMA_HTX0MPMD 0x0072 -#define HC_SIMA_HTX0CLODu 0x0073 -#define HC_SIMA_HTX0FM 0x0074 -#define HC_SIMA_HTX0TRCH 0x0075 -#define HC_SIMA_HTX0TRCL 0x0076 -#define HC_SIMA_HTX0TBC 0x0077 -#define HC_SIMA_HTX0TRAH 0x0078 -#define HC_SIMA_HTX0TBLCsat 0x0079 -#define HC_SIMA_HTX0TBLCop 0x007a -#define HC_SIMA_HTX0TBLMPfog 0x007b -#define HC_SIMA_HTX0TBLAsat 0x007c -#define HC_SIMA_HTX0TBLRCa 0x007d -#define HC_SIMA_HTX0TBLRCb 0x007e -#define HC_SIMA_HTX0TBLRCc 0x007f -#define HC_SIMA_HTX0TBLRCbias 0x0080 -#define HC_SIMA_HTX0TBLRAa 0x0081 -#define HC_SIMA_HTX0TBLRFog 0x0082 -#define HC_SIMA_HTX0BumpM00 0x0083 -#define HC_SIMA_HTX0BumpM01 0x0084 -#define HC_SIMA_HTX0BumpM10 0x0085 -#define HC_SIMA_HTX0BumpM11 0x0086 -#define HC_SIMA_HTX0LScale 0x0087 -/*---- end of texture 0 setting ---- 0x008f - */ -#define HC_SIMA_TX0TX1_OFF 0x0050 -/*---- start of texture 1 setting ---- - */ -#define HC_SIMA_HTX1L0BasL (HC_SIMA_HTX0L0BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L1BasL (HC_SIMA_HTX0L1BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L2BasL (HC_SIMA_HTX0L2BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L3BasL (HC_SIMA_HTX0L3BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L4BasL (HC_SIMA_HTX0L4BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L5BasL (HC_SIMA_HTX0L5BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L6BasL (HC_SIMA_HTX0L6BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L7BasL (HC_SIMA_HTX0L7BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L8BasL (HC_SIMA_HTX0L8BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L9BasL (HC_SIMA_HTX0L9BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LaBasL (HC_SIMA_HTX0LaBasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LbBasL (HC_SIMA_HTX0LbBasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LcBasL (HC_SIMA_HTX0LcBasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LdBasL (HC_SIMA_HTX0LdBasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LeBasL (HC_SIMA_HTX0LeBasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LfBasL (HC_SIMA_HTX0LfBasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L10BasL (HC_SIMA_HTX0L10BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L11BasL (HC_SIMA_HTX0L11BasL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L012BasH (HC_SIMA_HTX0L012BasH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L345BasH (HC_SIMA_HTX0L345BasH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L678BasH (HC_SIMA_HTX0L678BasH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L9abBasH (HC_SIMA_HTX0L9abBasH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LcdeBasH (HC_SIMA_HTX0LcdeBasH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1Lf1011BasH (HC_SIMA_HTX0Lf1011BasH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L0Pit (HC_SIMA_HTX0L0Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L1Pit (HC_SIMA_HTX0L1Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L2Pit (HC_SIMA_HTX0L2Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L3Pit (HC_SIMA_HTX0L3Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L4Pit (HC_SIMA_HTX0L4Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L5Pit (HC_SIMA_HTX0L5Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L6Pit (HC_SIMA_HTX0L6Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L7Pit (HC_SIMA_HTX0L7Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L8Pit (HC_SIMA_HTX0L8Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L9Pit (HC_SIMA_HTX0L9Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LaPit (HC_SIMA_HTX0LaPit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LbPit (HC_SIMA_HTX0LbPit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LcPit (HC_SIMA_HTX0LcPit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LdPit (HC_SIMA_HTX0LdPit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LePit (HC_SIMA_HTX0LePit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LfPit (HC_SIMA_HTX0LfPit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L10Pit (HC_SIMA_HTX0L10Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L11Pit (HC_SIMA_HTX0L11Pit + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L0_5WE (HC_SIMA_HTX0L0_5WE + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L6_bWE (HC_SIMA_HTX0L6_bWE + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1Lc_11WE (HC_SIMA_HTX0Lc_11WE + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L0_5HE (HC_SIMA_HTX0L0_5HE + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L6_bHE (HC_SIMA_HTX0L6_bHE + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1Lc_11HE (HC_SIMA_HTX0Lc_11HE + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1L0OS (HC_SIMA_HTX0L0OS + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TB (HC_SIMA_HTX0TB + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1MPMD (HC_SIMA_HTX0MPMD + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1CLODu (HC_SIMA_HTX0CLODu + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1FM (HC_SIMA_HTX0FM + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TRCH (HC_SIMA_HTX0TRCH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TRCL (HC_SIMA_HTX0TRCL + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBC (HC_SIMA_HTX0TBC + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TRAH (HC_SIMA_HTX0TRAH + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LTC (HC_SIMA_HTX0LTC + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LTA (HC_SIMA_HTX0LTA + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLCsat (HC_SIMA_HTX0TBLCsat + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLCop (HC_SIMA_HTX0TBLCop + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLMPfog (HC_SIMA_HTX0TBLMPfog + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLAsat (HC_SIMA_HTX0TBLAsat + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLRCa (HC_SIMA_HTX0TBLRCa + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLRCb (HC_SIMA_HTX0TBLRCb + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLRCc (HC_SIMA_HTX0TBLRCc + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLRCbias (HC_SIMA_HTX0TBLRCbias + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLRAa (HC_SIMA_HTX0TBLRAa + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1TBLRFog (HC_SIMA_HTX0TBLRFog + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1BumpM00 (HC_SIMA_HTX0BumpM00 + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1BumpM01 (HC_SIMA_HTX0BumpM01 + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1BumpM10 (HC_SIMA_HTX0BumpM10 + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1BumpM11 (HC_SIMA_HTX0BumpM11 + HC_SIMA_TX0TX1_OFF) -#define HC_SIMA_HTX1LScale (HC_SIMA_HTX0LScale + HC_SIMA_TX0TX1_OFF) -/*---- end of texture 1 setting ---- 0xaf - */ -#define HC_SIMA_HTXSMD 0x00b0 -#define HC_SIMA_HenFIFOAT 0x00b1 -#define HC_SIMA_HFBDrawFirst 0x00b2 -#define HC_SIMA_HFBBasL 0x00b3 -#define HC_SIMA_HTArbRCM 0x00b4 -#define HC_SIMA_HTArbRZ 0x00b5 -#define HC_SIMA_HTArbWZ 0x00b6 -#define HC_SIMA_HTArbRTX 0x00b7 -#define HC_SIMA_HTArbRCW 0x00b8 -#define HC_SIMA_HTArbE2 0x00b9 -#define HC_SIMA_HGEMITout 0x00ba -#define HC_SIMA_HFthRTXD 0x00bb -#define HC_SIMA_HFthRTXA 0x00bc -/* Define the texture palette 0 - */ -#define HC_SIMA_HTP0 0x0100 -#define HC_SIMA_HTP1 0x0200 -#define HC_SIMA_FOGTABLE 0x0300 -#define HC_SIMA_STIPPLE 0x0400 -#define HC_SIMA_HE3Fire 0x0440 -#define HC_SIMA_TRANS_SET 0x0441 -#define HC_SIMA_HREngSt 0x0442 -#define HC_SIMA_HRFIFOempty 0x0443 -#define HC_SIMA_HRFIFOfull 0x0444 -#define HC_SIMA_HRErr 0x0445 -#define HC_SIMA_FIFOstatus 0x0446 - -/****************************************************************************** -** Define the AGP command header. -******************************************************************************/ -#define HC_ACMD_MASK 0xfe000000 -#define HC_ACMD_SUB_MASK 0x0c000000 -#define HC_ACMD_HCmdA 0xee000000 -#define HC_ACMD_HCmdB 0xec000000 -#define HC_ACMD_HCmdC 0xea000000 -#define HC_ACMD_H1 0xf0000000 -#define HC_ACMD_H2 0xf2000000 -#define HC_ACMD_H3 0xf4000000 -#define HC_ACMD_H4 0xf6000000 - -#define HC_ACMD_H1IO_MASK 0x000001ff -#define HC_ACMD_H2IO1_MASK 0x001ff000 -#define HC_ACMD_H2IO2_MASK 0x000001ff -#define HC_ACMD_H2IO1_SHIFT 12 -#define HC_ACMD_H2IO2_SHIFT 0 -#define HC_ACMD_H3IO_MASK 0x000001ff -#define HC_ACMD_H3COUNT_MASK 0x01fff000 -#define HC_ACMD_H3COUNT_SHIFT 12 -#define HC_ACMD_H4ID_MASK 0x000001ff -#define HC_ACMD_H4COUNT_MASK 0x01fffe00 -#define HC_ACMD_H4COUNT_SHIFT 9 - -/******************************************************************************** -** Define Header -********************************************************************************/ -#define HC_HEADER2 0xF210F110 - -/******************************************************************************** -** Define Dummy Value -********************************************************************************/ -#define HC_DUMMY 0xCCCCCCCC -/******************************************************************************** -** Define for DMA use -********************************************************************************/ -#define HALCYON_HEADER2 0XF210F110 -#define HALCYON_FIRECMD 0XEE100000 -#define HALCYON_FIREMASK 0XFFF00000 -#define HALCYON_CMDB 0XEC000000 -#define HALCYON_CMDBMASK 0XFFFE0000 -#define HALCYON_SUB_ADDR0 0X00000000 -#define HALCYON_HEADER1MASK 0XFFFFFF00 -#define HALCYON_HEADER1 0XF0000000 -#define HC_SubA_HAGPBstL 0x0060 -#define HC_SubA_HAGPBendL 0x0061 -#define HC_SubA_HAGPCMNT 0x0062 -#define HC_SubA_HAGPBpL 0x0063 -#define HC_SubA_HAGPBpH 0x0064 -#define HC_HAGPCMNT_MASK 0x00800000 -#define HC_HCmdErrClr_MASK 0x00400000 -#define HC_HAGPBendH_MASK 0x0000ff00 -#define HC_HAGPBstH_MASK 0x000000ff -#define HC_HAGPBendH_SHIFT 8 -#define HC_HAGPBstH_SHIFT 0 -#define HC_HAGPBpL_MASK 0x00fffffc -#define HC_HAGPBpID_MASK 0x00000003 -#define HC_HAGPBpID_PAUSE 0x00000000 -#define HC_HAGPBpID_JUMP 0x00000001 -#define HC_HAGPBpID_STOP 0x00000002 -#define HC_HAGPBpH_MASK 0x00ffffff - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c deleted file mode 100644 index 89c2a12a9c2..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file via_context.c - * - * \author John Sheng (presumably of either VIA Technologies or S3 Graphics) - * \author Others at VIA Technologies? - * \author Others at S3 Graphics? - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/formats.h" -#include "main/simple_list.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "vbo/vbo.h" - -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "via_screen.h" -#include "via_dri.h" - -#include "via_state.h" -#include "via_tex.h" -#include "via_span.h" -#include "via_tris.h" -#include "via_ioctl.h" -#include "via_fb.h" - -#include <stdio.h> -#include "main/macros.h" -#include "drirenderbuffer.h" - -#define need_GL_ARB_point_parameters -#define need_GL_EXT_fog_coord -#define need_GL_EXT_secondary_color -#include "main/remap_helper.h" - -#include "vblank.h" -#include "utils.h" - -GLuint VIA_DEBUG = 0; - -/** - * Return various strings for \c glGetString. - * - * \sa glGetString - */ -static const GLubyte *viaGetString(struct gl_context *ctx, GLenum name) -{ - static char buffer[128]; - unsigned offset; - - - switch (name) { - case GL_VENDOR: - return (GLubyte *)"VIA Technology"; - - case GL_RENDERER: { - static const char * const chipset_names[] = { - "UniChrome", - "CastleRock (CLE266)", - "UniChrome (KM400)", - "UniChrome (K8M800)", - "UniChrome (PM8x0/CN400)", - }; - struct via_context *vmesa = VIA_CONTEXT(ctx); - unsigned id = vmesa->viaScreen->deviceID; - - offset = driGetRendererString( buffer, - chipset_names[(id > VIA_PM800) ? 0 : id], - 0 ); - return (GLubyte *)buffer; - } - - default: - return NULL; - } -} - - -/** - * Calculate a width that satisfies the hardware's alignment requirements. - * On the Unichrome hardware, each scanline must be aligned to a multiple of - * 16 pixels. - * - * \param width Minimum buffer width, in pixels. - * - * \returns A pixel width that meets the alignment requirements. - */ -static INLINE unsigned -buffer_align( unsigned width ) -{ - return (width + 0x0f) & ~0x0f; -} - - -static void -viaDeleteRenderbuffer(struct gl_renderbuffer *rb) -{ - /* Don't free() since we're contained in via_context struct. */ -} - -static GLboolean -viaRenderbufferStorage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - rb->Width = width; - rb->Height = height; - rb->InternalFormat = internalFormat; - return GL_TRUE; -} - - -static void -viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format, - __DRIdrawable *dPriv) -{ - const GLuint name = 0; - struct gl_renderbuffer *rb = & vrb->Base; - - vrb->dPriv = dPriv; - _mesa_init_renderbuffer(rb, name); - - /* Make sure we're using a null-valued GetPointer routine */ - assert(rb->GetPointer(NULL, rb, 0, 0) == NULL); - - rb->InternalFormat = format; - - if (format == GL_RGBA) { - /* Color */ - rb->_BaseFormat = GL_RGBA; - rb->Format = MESA_FORMAT_ARGB8888; - rb->DataType = GL_UNSIGNED_BYTE; - } - else if (format == GL_DEPTH_COMPONENT16) { - /* Depth */ - rb->_BaseFormat = GL_DEPTH_COMPONENT; - /* we always Get/Put 32-bit Z values */ - rb->Format = MESA_FORMAT_Z16; - rb->DataType = GL_UNSIGNED_INT; - } - else if (format == GL_DEPTH_COMPONENT24) { - /* Depth */ - rb->_BaseFormat = GL_DEPTH_COMPONENT; - /* we always Get/Put 32-bit Z values */ - rb->Format = MESA_FORMAT_Z32; - rb->DataType = GL_UNSIGNED_INT; - } - else { - /* Stencil */ - ASSERT(format == GL_STENCIL_INDEX8_EXT); - rb->_BaseFormat = GL_STENCIL_INDEX; - rb->Format = MESA_FORMAT_S8; - rb->DataType = GL_UNSIGNED_BYTE; - } - - rb->Delete = viaDeleteRenderbuffer; - rb->AllocStorage = viaRenderbufferStorage; -} - - -/** - * Calculate the framebuffer parameters for all buffers (front, back, depth, - * and stencil) associated with the specified context. - * - * \warning - * This function also calls \c AllocateBuffer to actually allocate the - * buffers. - * - * \sa AllocateBuffer - */ -static GLboolean -calculate_buffer_parameters(struct via_context *vmesa, - struct gl_framebuffer *fb, - __DRIdrawable *dPriv) -{ - const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16; - const unsigned extra = 32; - unsigned w; - unsigned h; - - /* Normally, the renderbuffer would be added to the framebuffer just once - * when the framebuffer was created. The VIA driver is a bit funny - * though in that the front/back/depth renderbuffers are in the per-context - * state! - * That should be fixed someday. - */ - - if (!vmesa->front.Base.InternalFormat) { - /* do one-time init for the renderbuffers */ - viaInitRenderbuffer(&vmesa->front, GL_RGBA, dPriv); - viaSetSpanFunctions(&vmesa->front, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->front.Base); - - if (fb->Visual.doubleBufferMode) { - viaInitRenderbuffer(&vmesa->back, GL_RGBA, dPriv); - viaSetSpanFunctions(&vmesa->back, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->back.Base); - } - - if (vmesa->glCtx->Visual.depthBits > 0) { - viaInitRenderbuffer(&vmesa->depth, - (vmesa->glCtx->Visual.depthBits == 16 - ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24), - dPriv); - viaSetSpanFunctions(&vmesa->depth, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depth.Base); - } - - if (vmesa->glCtx->Visual.stencilBits > 0) { - viaInitRenderbuffer(&vmesa->stencil, GL_STENCIL_INDEX8_EXT, - dPriv); - viaSetSpanFunctions(&vmesa->stencil, &fb->Visual); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencil.Base); - } - } - - assert(vmesa->front.Base.InternalFormat); - assert(vmesa->front.Base.AllocStorage); - if (fb->Visual.doubleBufferMode) { - assert(vmesa->back.Base.AllocStorage); - } - if (fb->Visual.depthBits) { - assert(vmesa->depth.Base.AllocStorage); - } - - - /* Allocate front-buffer */ - if (vmesa->drawType == GLX_PBUFFER_BIT) { - w = vmesa->driDrawable->w; - h = vmesa->driDrawable->h; - - vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel; - vmesa->front.pitch = buffer_align( w ) << shift; /* bytes, not pixels */ - vmesa->front.size = vmesa->front.pitch * h; - - if (vmesa->front.map) - via_free_draw_buffer(vmesa, &vmesa->front); - if (!via_alloc_draw_buffer(vmesa, &vmesa->front)) - return GL_FALSE; - - } else { - w = vmesa->viaScreen->width; - h = vmesa->viaScreen->height; - - vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel; - vmesa->front.pitch = buffer_align( w ) << shift; /* bytes, not pixels */ - vmesa->front.size = vmesa->front.pitch * h; - if (getenv("ALTERNATE_SCREEN")) - vmesa->front.offset = vmesa->front.size; - else - vmesa->front.offset = 0; - vmesa->front.map = (char *) vmesa->driScreen->pFB; - } - - - /* Allocate back-buffer */ - if (vmesa->hasBack) { - vmesa->back.bpp = vmesa->viaScreen->bitsPerPixel; - vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift); - vmesa->back.pitch += extra; - vmesa->back.pitch = MIN2(vmesa->back.pitch, vmesa->front.pitch); - vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h; - if (vmesa->back.map) - via_free_draw_buffer(vmesa, &vmesa->back); - if (!via_alloc_draw_buffer(vmesa, &vmesa->back)) - return GL_FALSE; - } - else { - if (vmesa->back.map) - via_free_draw_buffer(vmesa, &vmesa->back); - (void) memset( &vmesa->back, 0, sizeof( vmesa->back ) ); - } - - - /* Allocate depth-buffer */ - if ( vmesa->hasStencil || vmesa->hasDepth ) { - vmesa->depth.bpp = vmesa->depthBits; - if (vmesa->depth.bpp == 24) - vmesa->depth.bpp = 32; - - vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) * - (vmesa->depth.bpp/8)) + extra; - vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h; - - if (vmesa->depth.map) - via_free_draw_buffer(vmesa, &vmesa->depth); - if (!via_alloc_draw_buffer(vmesa, &vmesa->depth)) { - return GL_FALSE; - } - } - else { - if (vmesa->depth.map) - via_free_draw_buffer(vmesa, &vmesa->depth); - (void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) ); - } - - /* stencil buffer is same as depth buffer */ - vmesa->stencil.handle = vmesa->depth.handle; - vmesa->stencil.size = vmesa->depth.size; - vmesa->stencil.offset = vmesa->depth.offset; - vmesa->stencil.index = vmesa->depth.index; - vmesa->stencil.pitch = vmesa->depth.pitch; - vmesa->stencil.bpp = vmesa->depth.bpp; - vmesa->stencil.map = vmesa->depth.map; - vmesa->stencil.orig = vmesa->depth.orig; - vmesa->stencil.origMap = vmesa->depth.origMap; - - if( vmesa->viaScreen->width == vmesa->driDrawable->w && - vmesa->viaScreen->height == vmesa->driDrawable->h ) { - vmesa->doPageFlip = vmesa->allowPageFlip; - if (vmesa->hasBack) { - assert(vmesa->back.pitch == vmesa->front.pitch); - } - } - else - vmesa->doPageFlip = GL_FALSE; - - return GL_TRUE; -} - - -void viaReAllocateBuffers(struct gl_context *ctx, struct gl_framebuffer *drawbuffer, - GLuint width, GLuint height) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - calculate_buffer_parameters(vmesa, drawbuffer, vmesa->driDrawable); - - _mesa_resize_framebuffer(ctx, drawbuffer, width, height); -} - -/* Extension strings exported by the Unichrome driver. - */ -static const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multitexture", NULL }, - { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, - { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_env_combine", NULL }, -/* { "GL_ARB_texture_env_dot3", NULL }, */ - { "GL_ARB_texture_mirrored_repeat", NULL }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_EXT_texture_env_combine", NULL }, -/* { "GL_EXT_texture_env_dot3", NULL }, */ - { "GL_EXT_texture_lod_bias", NULL }, - { "GL_NV_blend_square", NULL }, - { NULL, NULL } -}; - -extern const struct tnl_pipeline_stage _via_fastrender_stage; -extern const struct tnl_pipeline_stage _via_render_stage; - -static const struct tnl_pipeline_stage *via_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 - &_via_fastrender_stage, /* ADD: unclipped rastersetup-to-dma */ -#endif - &_tnl_render_stage, - 0, -}; - - -static const struct dri_debug_control debug_control[] = -{ - { "fall", DEBUG_FALLBACKS }, - { "tex", DEBUG_TEXTURE }, - { "ioctl", DEBUG_IOCTL }, - { "prim", DEBUG_PRIMS }, - { "vert", DEBUG_VERTS }, - { "state", DEBUG_STATE }, - { "verb", DEBUG_VERBOSE }, - { "dri", DEBUG_DRI }, - { "dma", DEBUG_DMA }, - { "san", DEBUG_SANITY }, - { "sync", DEBUG_SYNC }, - { "sleep", DEBUG_SLEEP }, - { "pix", DEBUG_PIXEL }, - { "2d", DEBUG_2D }, - { NULL, 0 } -}; - - -static GLboolean -AllocateDmaBuffer(struct via_context *vmesa) -{ - if (vmesa->dma) - via_free_dma_buffer(vmesa); - - if (!via_alloc_dma_buffer(vmesa)) - return GL_FALSE; - - vmesa->dmaLow = 0; - vmesa->dmaCliprectAddr = ~0; - return GL_TRUE; -} - -static void -FreeBuffer(struct via_context *vmesa) -{ - if (vmesa->front.map && vmesa->drawType == GLX_PBUFFER_BIT) - via_free_draw_buffer(vmesa, &vmesa->front); - - if (vmesa->back.map) - via_free_draw_buffer(vmesa, &vmesa->back); - - if (vmesa->depth.map) - via_free_draw_buffer(vmesa, &vmesa->depth); - - if (vmesa->breadcrumb.map) - via_free_draw_buffer(vmesa, &vmesa->breadcrumb); - - if (vmesa->dma) - via_free_dma_buffer(vmesa); -} - - -GLboolean -viaCreateContext(gl_api api, - const struct gl_config *visual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate) -{ - struct gl_context *ctx, *shareCtx; - struct via_context *vmesa; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private; - drm_via_sarea_t *saPriv = (drm_via_sarea_t *) - (((GLubyte *)sPriv->pSAREA) + viaScreen->sareaPrivOffset); - struct dd_function_table functions; - - /* Allocate via context */ - vmesa = (struct via_context *) CALLOC_STRUCT(via_context); - if (!vmesa) { - return GL_FALSE; - } - - /* Parse configuration files. - */ - driParseConfigFiles (&vmesa->optionCache, &viaScreen->optionCache, - sPriv->myNum, "unichrome"); - - /* pick back buffer */ - vmesa->hasBack = visual->doubleBufferMode; - - switch(visual->depthBits) { - case 0: - vmesa->hasDepth = GL_FALSE; - vmesa->depthBits = 0; - vmesa->depth_max = 1.0; - break; - case 16: - vmesa->hasDepth = GL_TRUE; - vmesa->depthBits = visual->depthBits; - vmesa->have_hw_stencil = GL_FALSE; - vmesa->depth_max = (GLfloat)0xffff; - vmesa->depth_clear_mask = 0xf << 28; - vmesa->ClearDepth = 0xffff; - vmesa->polygon_offset_scale = 1.0 / vmesa->depth_max; - break; - case 24: - vmesa->hasDepth = GL_TRUE; - vmesa->depthBits = visual->depthBits; - vmesa->depth_max = (GLfloat) 0xffffff; - vmesa->depth_clear_mask = 0xe << 28; - vmesa->ClearDepth = 0xffffff00; - - assert(visual->haveStencilBuffer); - assert(visual->stencilBits == 8); - - vmesa->have_hw_stencil = GL_TRUE; - vmesa->stencilBits = visual->stencilBits; - vmesa->stencil_clear_mask = 0x1 << 28; - vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max; - break; - case 32: - vmesa->hasDepth = GL_TRUE; - vmesa->depthBits = visual->depthBits; - assert(!visual->haveStencilBuffer); - vmesa->have_hw_stencil = GL_FALSE; - vmesa->depth_max = (GLfloat)0xffffffff; - vmesa->depth_clear_mask = 0xf << 28; - vmesa->ClearDepth = 0xffffffff; - vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max; - break; - default: - assert(0); - break; - } - - make_empty_list(&vmesa->freed_tex_buffers); - make_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO]); - make_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP]); - make_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM]); - - _mesa_init_driver_functions(&functions); - viaInitTextureFuncs(&functions); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((struct via_context *) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - vmesa->glCtx = _mesa_create_context(API_OPENGL, visual, shareCtx, &functions, - (void*) vmesa); - - vmesa->shareCtx = shareCtx; - - if (!vmesa->glCtx) { - FREE(vmesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = vmesa; - - ctx = vmesa->glCtx; - - if (driQueryOptionb(&vmesa->optionCache, "excess_mipmap")) - ctx->Const.MaxTextureLevels = 11; - else - ctx->Const.MaxTextureLevels = 10; - - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; - ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; - - 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; - - ctx->Const.MinPointSize = 1.0; - ctx->Const.MinPointSizeAA = 1.0; - ctx->Const.MaxPointSize = 1.0; - ctx->Const.MaxPointSizeAA = 1.0; - ctx->Const.PointSizeGranularity = 1.0; - - ctx->Const.MaxDrawBuffers = 1; - - ctx->Driver.GetString = viaGetString; - - ctx->DriverCtx = (void *)vmesa; - vmesa->glCtx = ctx; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext(ctx); - _vbo_CreateContext(ctx); - _tnl_CreateContext(ctx); - _swsetup_CreateContext(ctx); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline(ctx); - _tnl_install_pipeline(ctx, via_pipeline); - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog(ctx, GL_FALSE); - _swrast_allow_vertex_fog(ctx, GL_TRUE); - _tnl_allow_pixel_fog(ctx, GL_FALSE); - _tnl_allow_vertex_fog(ctx, GL_TRUE); - - vmesa->hHWContext = driContextPriv->hHWContext; - vmesa->driFd = sPriv->fd; - vmesa->driHwLock = &sPriv->pSAREA->lock; - - vmesa->viaScreen = viaScreen; - vmesa->driScreen = sPriv; - vmesa->sarea = saPriv; - - vmesa->renderIndex = ~0; - vmesa->setupIndex = ~0; - vmesa->hwPrimitive = GL_POLYGON+1; - - /* KW: Hardwire this. Was previously set bogusly in - * viaCreateBuffer. Needs work before PBUFFER can be used: - */ - vmesa->drawType = GLX_WINDOW_BIT; - - - _math_matrix_ctr(&vmesa->ViewportMatrix); - - /* Do this early, before VIA_FLUSH_DMA can be called: - */ - if (!AllocateDmaBuffer(vmesa)) { - fprintf(stderr ,"AllocateDmaBuffer fail\n"); - FreeBuffer(vmesa); - FREE(vmesa); - return GL_FALSE; - } - - /* Allocate a small piece of fb memory for synchronization: - */ - vmesa->breadcrumb.bpp = 32; - vmesa->breadcrumb.pitch = buffer_align( 64 ) << 2; - vmesa->breadcrumb.size = vmesa->breadcrumb.pitch; - - if (!via_alloc_draw_buffer(vmesa, &vmesa->breadcrumb)) { - fprintf(stderr ,"AllocateDmaBuffer fail\n"); - FreeBuffer(vmesa); - FREE(vmesa); - return GL_FALSE; - } - - driInitExtensions( ctx, card_extensions, GL_TRUE ); - viaInitStateFuncs(ctx); - viaInitTriFuncs(ctx); - viaInitSpanFuncs(ctx); - viaInitIoctlFuncs(ctx); - viaInitState(ctx); - - if (getenv("VIA_DEBUG")) - VIA_DEBUG = driParseDebugString( getenv( "VIA_DEBUG" ), - debug_control ); - - if (getenv("VIA_NO_RAST") || - driQueryOptionb(&vmesa->optionCache, "no_rast")) - FALLBACK(vmesa, VIA_FALLBACK_USER_DISABLE, 1); - - if (getenv("VIA_PAGEFLIP")) - vmesa->allowPageFlip = 1; - - (*sPriv->systemTime->getUST)( &vmesa->swap_ust ); - - - vmesa->regMMIOBase = (GLuint *)((unsigned long)viaScreen->reg); - vmesa->pnGEMode = (GLuint *)((unsigned long)viaScreen->reg + 0x4); - vmesa->regEngineStatus = (GLuint *)((unsigned long)viaScreen->reg + 0x400); - vmesa->regTranSet = (GLuint *)((unsigned long)viaScreen->reg + 0x43C); - vmesa->regTranSpace = (GLuint *)((unsigned long)viaScreen->reg + 0x440); - vmesa->agpBase = viaScreen->agpBase; - - - return GL_TRUE; -} - -void -viaDestroyContext(__DRIcontext *driContextPriv) -{ - GET_CURRENT_CONTEXT(ctx); - struct via_context *vmesa = - (struct via_context *)driContextPriv->driverPrivate; - struct via_context *current = ctx ? VIA_CONTEXT(ctx) : NULL; - - assert(vmesa); /* should never be null */ - - if (vmesa->driDrawable) { - viaWaitIdle(vmesa, GL_FALSE); - - if (vmesa->doPageFlip) { - LOCK_HARDWARE(vmesa); - if (vmesa->pfCurrentOffset != 0) { - fprintf(stderr, "%s - reset pf\n", __FUNCTION__); - viaResetPageFlippingLocked(vmesa); - } - UNLOCK_HARDWARE(vmesa); - } - } - - /* check if we're deleting the currently bound context */ - if (vmesa == current) { - VIA_FLUSH_DMA(vmesa); - _mesa_make_current(NULL, NULL, NULL); - } - - _swsetup_DestroyContext(vmesa->glCtx); - _tnl_DestroyContext(vmesa->glCtx); - _vbo_DestroyContext(vmesa->glCtx); - _swrast_DestroyContext(vmesa->glCtx); - /* free the Mesa context */ - _mesa_destroy_context(vmesa->glCtx); - /* release our data */ - FreeBuffer(vmesa); - - assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP])); - assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO])); - assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM])); - assert (is_empty_list(&vmesa->freed_tex_buffers)); - - driDestroyOptionCache(&vmesa->optionCache); - - FREE(vmesa); -} - - -void viaXMesaWindowMoved(struct via_context *vmesa) -{ - __DRIdrawable *const drawable = vmesa->driDrawable; - __DRIdrawable *const readable = vmesa->driReadable; - struct via_renderbuffer * draw_buffer; - struct via_renderbuffer * read_buffer; - GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; - - if (!drawable) - return; - - draw_buffer = (struct via_renderbuffer *) drawable->driverPrivate; - read_buffer = (struct via_renderbuffer *) readable->driverPrivate; - - switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0]) { - case BUFFER_BACK_LEFT: - if (drawable->numBackClipRects == 0) { - vmesa->numClipRects = drawable->numClipRects; - vmesa->pClipRects = drawable->pClipRects; - } - else { - vmesa->numClipRects = drawable->numBackClipRects; - vmesa->pClipRects = drawable->pBackClipRects; - } - break; - case BUFFER_FRONT_LEFT: - vmesa->numClipRects = drawable->numClipRects; - vmesa->pClipRects = drawable->pClipRects; - break; - default: - vmesa->numClipRects = 0; - break; - } - - if ((draw_buffer->drawW != drawable->w) - || (draw_buffer->drawH != drawable->h)) { - calculate_buffer_parameters(vmesa, vmesa->glCtx->DrawBuffer, - drawable); - } - - draw_buffer->drawX = drawable->x; - draw_buffer->drawY = drawable->y; - draw_buffer->drawW = drawable->w; - draw_buffer->drawH = drawable->h; - - if (drawable != readable) { - if ((read_buffer->drawW != readable->w) - || (read_buffer->drawH != readable->h)) { - calculate_buffer_parameters(vmesa, vmesa->glCtx->ReadBuffer, - readable); - } - - read_buffer->drawX = readable->x; - read_buffer->drawY = readable->y; - read_buffer->drawW = readable->w; - read_buffer->drawH = readable->h; - } - - vmesa->front.orig = (vmesa->front.offset + - draw_buffer->drawY * vmesa->front.pitch + - draw_buffer->drawX * bytePerPixel); - - vmesa->front.origMap = (vmesa->front.map + - draw_buffer->drawY * vmesa->front.pitch + - draw_buffer->drawX * bytePerPixel); - - vmesa->back.orig = (vmesa->back.offset + - draw_buffer->drawY * vmesa->back.pitch + - draw_buffer->drawX * bytePerPixel); - - vmesa->back.origMap = (vmesa->back.map + - draw_buffer->drawY * vmesa->back.pitch + - draw_buffer->drawX * bytePerPixel); - - vmesa->depth.orig = (vmesa->depth.offset + - draw_buffer->drawY * vmesa->depth.pitch + - draw_buffer->drawX * bytePerPixel); - - vmesa->depth.origMap = (vmesa->depth.map + - draw_buffer->drawY * vmesa->depth.pitch + - draw_buffer->drawX * bytePerPixel); - - viaCalcViewport(vmesa->glCtx); -} - -GLboolean -viaUnbindContext(__DRIcontext *driContextPriv) -{ - return GL_TRUE; -} - -GLboolean -viaMakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv) -{ - if (VIA_DEBUG & DEBUG_DRI) { - fprintf(stderr, "driContextPriv = %016lx\n", (unsigned long)driContextPriv); - fprintf(stderr, "driDrawPriv = %016lx\n", (unsigned long)driDrawPriv); - fprintf(stderr, "driReadPriv = %016lx\n", (unsigned long)driReadPriv); - } - - if (driContextPriv) { - struct via_context *vmesa = - (struct via_context *)driContextPriv->driverPrivate; - struct gl_context *ctx = vmesa->glCtx; - struct gl_framebuffer *drawBuffer, *readBuffer; - - drawBuffer = (struct gl_framebuffer *)driDrawPriv->driverPrivate; - readBuffer = (struct gl_framebuffer *)driReadPriv->driverPrivate; - - if ((vmesa->driDrawable != driDrawPriv) - || (vmesa->driReadable != driReadPriv)) { - if (driDrawPriv->swap_interval == (unsigned)-1) { - driDrawPriv->vblFlags = - vmesa->viaScreen->irqEnabled ? - driGetDefaultVBlankFlags(&vmesa->optionCache) : - VBLANK_FLAG_NO_IRQ; - - driDrawableInitVBlank(driDrawPriv); - } - - vmesa->driDrawable = driDrawPriv; - vmesa->driReadable = driReadPriv; - - if ((drawBuffer->Width != driDrawPriv->w) - || (drawBuffer->Height != driDrawPriv->h)) { - _mesa_resize_framebuffer(ctx, drawBuffer, - driDrawPriv->w, driDrawPriv->h); - drawBuffer->Initialized = GL_TRUE; - } - - if (!calculate_buffer_parameters(vmesa, drawBuffer, driDrawPriv)) { - return GL_FALSE; - } - - if (driDrawPriv != driReadPriv) { - if ((readBuffer->Width != driReadPriv->w) - || (readBuffer->Height != driReadPriv->h)) { - _mesa_resize_framebuffer(ctx, readBuffer, - driReadPriv->w, driReadPriv->h); - readBuffer->Initialized = GL_TRUE; - } - - if (!calculate_buffer_parameters(vmesa, readBuffer, driReadPriv)) { - return GL_FALSE; - } - } - } - - _mesa_make_current(vmesa->glCtx, drawBuffer, readBuffer); - - ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] ); - - viaXMesaWindowMoved(vmesa); - ctx->Driver.Scissor(vmesa->glCtx, - vmesa->glCtx->Scissor.X, - vmesa->glCtx->Scissor.Y, - vmesa->glCtx->Scissor.Width, - vmesa->glCtx->Scissor.Height); - } - else { - _mesa_make_current(NULL, NULL, NULL); - } - - return GL_TRUE; -} - -void viaGetLock(struct via_context *vmesa, GLuint flags) -{ - __DRIdrawable *dPriv = vmesa->driDrawable; - __DRIscreen *sPriv = vmesa->driScreen; - - drmGetLock(vmesa->driFd, vmesa->hHWContext, flags); - - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); - if (dPriv != vmesa->driReadable) { - DRI_VALIDATE_DRAWABLE_INFO(sPriv, vmesa->driReadable); - } - - if (vmesa->sarea->ctxOwner != vmesa->hHWContext) { - vmesa->sarea->ctxOwner = vmesa->hHWContext; - vmesa->newEmitState = ~0; - } - - if (vmesa->lastStamp != dPriv->lastStamp) { - viaXMesaWindowMoved(vmesa); - driUpdateFramebufferSize(vmesa->glCtx, dPriv); - vmesa->newEmitState = ~0; - vmesa->lastStamp = dPriv->lastStamp; - } - - if (vmesa->doPageFlip && - vmesa->pfCurrentOffset != vmesa->sarea->pfCurrentOffset) { - fprintf(stderr, "%s - reset pf\n", __FUNCTION__); - viaResetPageFlippingLocked(vmesa); - } -} - - -void -viaSwapBuffers(__DRIdrawable *drawablePrivate) -{ - __DRIdrawable *dPriv = (__DRIdrawable *)drawablePrivate; - - if (dPriv && - dPriv->driContextPriv && - dPriv->driContextPriv->driverPrivate) { - struct via_context *vmesa = - (struct via_context *)dPriv->driContextPriv->driverPrivate; - struct gl_context *ctx = vmesa->glCtx; - - _mesa_notifySwapBuffers(ctx); - - if (ctx->Visual.doubleBufferMode) { - if (vmesa->doPageFlip) { - viaPageFlip(dPriv); - } - else { - viaCopyBuffer(dPriv); - } - } - else - VIA_FLUSH_DMA(vmesa); - } - else { - _mesa_problem(NULL, "viaSwapBuffers: drawable has no context!\n"); - } -} diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h deleted file mode 100644 index 660e7714072..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_context.h +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _VIACONTEXT_H -#define _VIACONTEXT_H - -#include "dri_util.h" - -#include "drm.h" - -#include "main/mtypes.h" -#include "main/mm.h" -#include "tnl/t_vertex.h" - -#include "via_screen.h" -#include "via_tex.h" -#include "via_drm.h" - -struct via_context; - -/* Chip tags. These are used to group the adapters into - * related families. - */ -enum VIACHIPTAGS { - VIA_UNKNOWN = 0, - VIA_CLE266, - VIA_KM400, - VIA_K8M800, - VIA_PM800, - VIA_LAST -}; - -#define VIA_FALLBACK_TEXTURE 0x1 -#define VIA_FALLBACK_DRAW_BUFFER 0x2 -#define VIA_FALLBACK_READ_BUFFER 0x4 -#define VIA_FALLBACK_COLORMASK 0x8 -#define VIA_FALLBACK_SPECULAR 0x20 -#define VIA_FALLBACK_LOGICOP 0x40 -#define VIA_FALLBACK_RENDERMODE 0x80 -#define VIA_FALLBACK_STENCIL 0x100 -#define VIA_FALLBACK_BLEND_EQ 0x200 -#define VIA_FALLBACK_BLEND_FUNC 0x400 -#define VIA_FALLBACK_USER_DISABLE 0x800 -#define VIA_FALLBACK_PROJ_TEXTURE 0x1000 -#define VIA_FALLBACK_POLY_STIPPLE 0x2000 - -#define VIA_DMA_BUFSIZ 4096 -#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 128) - -#define VIA_NO_CLIPRECTS 0x1 - - -/* Use the templated vertex formats: - */ -#define TAG(x) via##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -typedef void (*via_tri_func)(struct via_context *, viaVertex *, viaVertex *, - viaVertex *); -typedef void (*via_line_func)(struct via_context *, viaVertex *, viaVertex *); -typedef void (*via_point_func)(struct via_context *, viaVertex *); - -/** - * Derived from gl_renderbuffer. - */ -struct via_renderbuffer { - struct gl_renderbuffer Base; /* must be first! */ - drm_handle_t handle; - drmSize size; - unsigned long offset; - unsigned long index; - GLuint pitch; - GLuint bpp; - char *map; - GLuint orig; /* The drawing origin, - * at (drawX,drawY) in screen space. - */ - char *origMap; - - int drawX; /* origin of drawable in draw buffer */ - int drawY; - int drawW; - int drawH; - - __DRIdrawable *dPriv; -}; - - -#define VIA_MAX_TEXLEVELS 10 - -struct via_tex_buffer { - struct via_tex_buffer *next, *prev; - struct via_texture_image *image; - unsigned long index; - unsigned long offset; - GLuint size; - GLuint memType; - unsigned char *bufAddr; - GLuint texBase; - GLuint lastUsed; -}; - - - -struct via_texture_image { - struct gl_texture_image image; - struct via_tex_buffer *texMem; - GLint pitchLog2; -}; - -struct via_texture_object { - struct gl_texture_object obj; /* The "parent" object */ - - GLuint texelBytes; - GLuint memType; - - GLuint regTexFM; - GLuint regTexWidthLog2[2]; - GLuint regTexHeightLog2[2]; - GLuint regTexBaseH[4]; - struct { - GLuint baseL; - GLuint pitchLog2; - } regTexBaseAndPitch[12]; - - GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */ -}; - - - -struct via_context { - GLint refcount; - struct gl_context *glCtx; - struct gl_context *shareCtx; - - /* XXX These don't belong here. They should be per-drawable state. */ - struct via_renderbuffer front; - struct via_renderbuffer back; - struct via_renderbuffer depth; - struct via_renderbuffer stencil; /* mirrors depth */ - struct via_renderbuffer breadcrumb; - - GLboolean hasBack; - GLboolean hasDepth; - GLboolean hasStencil; - GLboolean hasAccum; - GLuint depthBits; - GLuint stencilBits; - - GLboolean have_hw_stencil; - GLuint ClearDepth; - GLuint depth_clear_mask; - GLuint stencil_clear_mask; - GLfloat depth_max; - GLfloat polygon_offset_scale; - - GLubyte *dma; - viaRegion tex; - - /* Bit flag to keep 0track of fallbacks. - */ - GLuint Fallback; - - /* State for via_tris.c. - */ - GLuint newState; /* _NEW_* flags */ - GLuint newEmitState; /* _NEW_* flags */ - GLuint newRenderState; /* _NEW_* flags */ - - struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; - GLuint vertex_attr_count; - - GLuint setupIndex; - GLuint renderIndex; - GLmatrix ViewportMatrix; - GLenum renderPrimitive; - GLenum hwPrimitive; - GLenum hwShadeModel; - unsigned char *verts; - - /* drmBufPtr dma_buffer; - */ - GLuint dmaLow; - GLuint dmaCliprectAddr; - GLuint dmaLastPrim; - GLboolean useAgp; - - - /* Fallback rasterization functions - */ - via_point_func drawPoint; - via_line_func drawLine; - via_tri_func drawTri; - - /* Hardware register - */ - GLuint regCmdA_End; - GLuint regCmdB; - - GLuint regEnable; - GLuint regHFBBMSKL; - GLuint regHROP; - - GLuint regHZWTMD; - GLuint regHSTREF; - GLuint regHSTMD; - - GLuint regHATMD; - GLuint regHABLCsat; - GLuint regHABLCop; - GLuint regHABLAsat; - GLuint regHABLAop; - GLuint regHABLRCa; - GLuint regHABLRFCa; - GLuint regHABLRCbias; - GLuint regHABLRCb; - GLuint regHABLRFCb; - GLuint regHABLRAa; - GLuint regHABLRAb; - GLuint regHFogLF; - GLuint regHFogCL; - GLuint regHFogCH; - - GLuint regHLP; - GLuint regHLPRF; - - GLuint regHTXnCLOD[2]; - GLuint regHTXnTB[2]; - GLuint regHTXnMPMD[2]; - GLuint regHTXnTBLCsat[2]; - GLuint regHTXnTBLCop[2]; - GLuint regHTXnTBLMPfog[2]; - GLuint regHTXnTBLAsat[2]; - GLuint regHTXnTBLRCb[2]; - GLuint regHTXnTBLRAa[2]; - GLuint regHTXnTBLRFog[2]; - GLuint regHTXnTBLRCa[2]; - GLuint regHTXnTBLRCc[2]; - GLuint regHTXnTBLRCbias[2]; - GLuint regHTXnTBC[2]; - GLuint regHTXnTRAH[2]; - - int vertexSize; - int hwVertexSize; - GLboolean ptexHack; - int coloroffset; - int specoffset; - - GLint lastStamp; - - GLuint ClearColor; - GLuint ClearMask; - - /* DRI stuff - */ - GLboolean doPageFlip; - - struct via_renderbuffer *drawBuffer; - - GLuint numClipRects; /* cliprects for that buffer */ - drm_clip_rect_t *pClipRects; - - GLboolean scissor; - drm_clip_rect_t drawRect; - drm_clip_rect_t scissorRect; - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - - /** - * DRI drawable bound to this context for drawing. - */ - __DRIdrawable *driDrawable; - - /** - * DRI drawable bound to this context for reading. - */ - __DRIdrawable *driReadable; - - __DRIscreen *driScreen; - viaScreenPrivate *viaScreen; - drm_via_sarea_t *sarea; - volatile GLuint* regMMIOBase; - volatile GLuint* pnGEMode; - volatile GLuint* regEngineStatus; - volatile GLuint* regTranSet; - volatile GLuint* regTranSpace; - GLuint agpBase; - GLuint drawType; - - GLuint nDoneFirstFlip; - GLuint agpFullCount; - - GLboolean clearTexCache; - GLboolean thrashing; - - /* Configuration cache - */ - driOptionCache optionCache; - - int64_t swap_ust; - int64_t swap_missed_ust; - - GLuint swap_count; - GLuint swap_missed_count; - - - GLuint pfCurrentOffset; - GLboolean allowPageFlip; - - GLuint lastBreadcrumbRead; - GLuint lastBreadcrumbWrite; - GLuint lastSwap[2]; - GLuint lastDma; - - GLuint total_alloc[VIA_MEM_SYSTEM+1]; - - struct via_tex_buffer tex_image_list[VIA_MEM_SYSTEM+1]; - struct via_tex_buffer freed_tex_buffers; - -}; - - - -#define VIA_CONTEXT(ctx) ((struct via_context *)(ctx->DriverCtx)) - - - -/* Lock the hardware and validate our state. - */ -#define LOCK_HARDWARE(vmesa) \ - do { \ - char __ret = 0; \ - DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \ - (DRM_LOCK_HELD|vmesa->hHWContext), __ret); \ - if (__ret) \ - viaGetLock(vmesa, 0); \ - } while (0) - - -/* Release the kernel lock. - */ -#define UNLOCK_HARDWARE(vmesa) \ - DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); - - - -extern GLuint VIA_DEBUG; - -#define DEBUG_TEXTURE 0x1 -#define DEBUG_STATE 0x2 -#define DEBUG_IOCTL 0x4 -#define DEBUG_PRIMS 0x8 -#define DEBUG_VERTS 0x10 -#define DEBUG_FALLBACKS 0x20 -#define DEBUG_VERBOSE 0x40 -#define DEBUG_DRI 0x80 -#define DEBUG_DMA 0x100 -#define DEBUG_SANITY 0x200 -#define DEBUG_SYNC 0x400 -#define DEBUG_SLEEP 0x800 -#define DEBUG_PIXEL 0x1000 -#define DEBUG_2D 0x2000 - - -extern void viaGetLock(struct via_context *vmesa, GLuint flags); -extern void viaLock(struct via_context *vmesa, GLuint flags); -extern void viaUnLock(struct via_context *vmesa, GLuint flags); -extern void viaEmitHwStateLocked(struct via_context *vmesa); -extern void viaEmitScissorValues(struct via_context *vmesa, int box_nr, int emit); -extern void viaXMesaSetBackClipRects(struct via_context *vmesa); -extern void viaXMesaSetFrontClipRects(struct via_context *vmesa); -extern void viaReAllocateBuffers(struct gl_context *ctx, struct gl_framebuffer *drawbuffer, GLuint width, GLuint height); -extern void viaXMesaWindowMoved(struct via_context *vmesa); - -extern GLboolean viaTexCombineState(struct via_context *vmesa, - const struct gl_tex_env_combine_state * combine, - unsigned unit ); - -/* Via hw already adjusted for GL pixel centers: - */ -#define SUBPIXEL_X 0 -#define SUBPIXEL_Y 0 - -/* TODO XXX _SOLO temp defines to make code compilable */ -#ifndef GLX_PBUFFER_BIT -#define GLX_PBUFFER_BIT 0x00000004 -#endif -#ifndef GLX_WINDOW_BIT -#define GLX_WINDOW_BIT 0x00000001 -#endif -#ifndef VERT_BIT_CLIP -#define VERT_BIT_CLIP 0x1000000 -#endif - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_drmclient.h b/src/mesa/drivers/dri/unichrome/via_drmclient.h deleted file mode 100644 index 7beff9a9d93..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_drmclient.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#ifndef _VIA_DRMCLIENT_H_ -#define _VIA_DRMCLIENT_H_ - -#define VIA_DMA_BUF_ORDER 12 -#define VIA_DMA_BUF_SZ (1 << VIA_DMA_BUF_ORDER) -#define VIA_DMA_BUF_NR 256 - -#endif /* _VIA_DRMCLIENT_H_ */ diff --git a/src/mesa/drivers/dri/unichrome/via_fb.c b/src/mesa/drivers/dri/unichrome/via_fb.c deleted file mode 100644 index bebf0619d0b..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_fb.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <assert.h> - -#include "via_context.h" -#include "via_ioctl.h" -#include "via_fb.h" -#include "xf86drm.h" -#include "main/imports.h" -#include "main/simple_list.h" -#include <sys/ioctl.h> - -GLboolean -via_alloc_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf) -{ - drm_via_mem_t mem; - mem.context = vmesa->hHWContext; - mem.size = buf->size; - mem.type = VIA_MEM_VIDEO; - mem.offset = 0; - mem.index = 0; - - if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &mem)) - return GL_FALSE; - - - buf->offset = mem.offset; - buf->map = (char *)vmesa->driScreen->pFB + mem.offset; - buf->index = mem.index; - return GL_TRUE; -} - -void -via_free_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf) -{ - drm_via_mem_t mem; - - if (!vmesa) return; - - mem.context = vmesa->hHWContext; - mem.index = buf->index; - mem.type = VIA_MEM_VIDEO; - mem.offset = buf->offset; - mem.size = buf->size; - - ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &mem); - buf->map = NULL; -} - - -GLboolean -via_alloc_dma_buffer(struct via_context *vmesa) -{ - drm_via_dma_init_t init; - - vmesa->dma = (GLubyte *) malloc(VIA_DMA_BUFSIZ); - - /* - * Check whether AGP DMA has been initialized. - */ - memset(&init, 0, sizeof(init)); - init.func = VIA_DMA_INITIALIZED; - - vmesa->useAgp = - ( 0 == drmCommandWrite(vmesa->driFd, DRM_VIA_DMA_INIT, - &init, sizeof(init))); - if (VIA_DEBUG & DEBUG_DMA) { - if (vmesa->useAgp) - fprintf(stderr, "unichrome_dri.so: Using AGP.\n"); - else - fprintf(stderr, "unichrome_dri.so: Using PCI.\n"); - } - - return ((vmesa->dma) ? GL_TRUE : GL_FALSE); -} - -void -via_free_dma_buffer(struct via_context *vmesa) -{ - if (!vmesa) return; - free(vmesa->dma); - vmesa->dma = 0; -} - - -/* These functions now allocate and free the via_tex_buffer struct as well: - */ -struct via_tex_buffer * -via_alloc_texture(struct via_context *vmesa, - GLuint size, - GLuint memType) -{ - struct via_tex_buffer *t = CALLOC_STRUCT(via_tex_buffer); - - if (!t) - goto cleanup; - - t->size = size; - t->memType = memType; - insert_at_tail(&vmesa->tex_image_list[memType], t); - - if (t->memType == VIA_MEM_AGP || - t->memType == VIA_MEM_VIDEO) { - drm_via_mem_t fb; - - fb.context = vmesa->hHWContext; - fb.size = t->size; - fb.type = t->memType; - fb.offset = 0; - fb.index = 0; - - if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb) != 0 || - fb.index == 0) - goto cleanup; - - if (0) - fprintf(stderr, "offset %lx index %lx\n", fb.offset, fb.index); - - t->offset = fb.offset; - t->index = fb.index; - - if (t->memType == VIA_MEM_AGP) { - t->bufAddr = (GLubyte *)((unsigned long)vmesa->viaScreen->agpLinearStart + - fb.offset); - t->texBase = vmesa->agpBase + fb.offset; - } - else { - t->bufAddr = (GLubyte *)((unsigned long)vmesa->driScreen->pFB + fb.offset); - t->texBase = fb.offset; - } - - vmesa->total_alloc[t->memType] += t->size; - return t; - } - else if (t->memType == VIA_MEM_SYSTEM) { - - t->bufAddr = malloc(t->size); - if (!t->bufAddr) - goto cleanup; - - vmesa->total_alloc[t->memType] += t->size; - return t; - } - - cleanup: - if (t) { - remove_from_list(t); - FREE(t); - } - - return NULL; -} - - -static void -via_do_free_texture(struct via_context *vmesa, struct via_tex_buffer *t) -{ - drm_via_mem_t fb; - - remove_from_list( t ); - - vmesa->total_alloc[t->memType] -= t->size; - - fb.context = vmesa->hHWContext; - fb.index = t->index; - fb.offset = t->offset; - fb.type = t->memType; - fb.size = t->size; - - if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb)) { - fprintf(stderr, "via_free_texture fail\n"); - } - - FREE(t); -} - - -/* Release textures which were potentially still being referenced by - * hardware at the time when they were originally freed. - */ -void -via_release_pending_textures( struct via_context *vmesa ) -{ - struct via_tex_buffer *s, *tmp; - - foreach_s( s, tmp, &vmesa->freed_tex_buffers ) { - if (!VIA_GEQ_WRAP(s->lastUsed, vmesa->lastBreadcrumbRead)) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s: release tex sz %d lastUsed %x\n", - __FUNCTION__, s->size, s->lastUsed); - via_do_free_texture(vmesa, s); - } - } -} - - - -void -via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t) -{ - if (!t) { - return; - } - else if (t->memType == VIA_MEM_SYSTEM) { - remove_from_list(t); - vmesa->total_alloc[t->memType] -= t->size; - free(t->bufAddr); - free(t); - } - else if (t->index && viaCheckBreadcrumb(vmesa, t->lastUsed)) { - via_do_free_texture( vmesa, t ); - } - else { - /* Close current breadcrumb so that we can free this eventually: - */ - if (t->lastUsed == vmesa->lastBreadcrumbWrite) - viaEmitBreadcrumb(vmesa); - - move_to_tail( &vmesa->freed_tex_buffers, t ); - } -} diff --git a/src/mesa/drivers/dri/unichrome/via_fb.h b/src/mesa/drivers/dri/unichrome/via_fb.h deleted file mode 100644 index 2d329ac2a7d..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_fb.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIAFB_INC -#define _VIAFB_INC - -#include "via_context.h" - -extern GLboolean via_alloc_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf); -extern GLboolean via_alloc_dma_buffer(struct via_context *vmesa); - -struct via_tex_buffer * -via_alloc_texture(struct via_context *vmesa, - GLuint size, - GLuint memType); - -extern void via_free_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf); -extern void via_free_dma_buffer(struct via_context *vmesa); -extern void via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t); -void via_release_pending_textures( struct via_context *vmesa ); -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c deleted file mode 100644 index 116adda18ea..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ /dev/null @@ -1,981 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include <stdio.h> -#include <unistd.h> - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/dd.h" -#include "swrast/swrast.h" - -#include "main/mm.h" -#include "via_context.h" -#include "via_tris.h" -#include "via_ioctl.h" -#include "via_fb.h" -#include "via_3d_reg.h" - -#include "vblank.h" -#include "drm.h" -#include "xf86drm.h" -#include <sys/ioctl.h> -#include <errno.h> - - -#define VIA_REG_STATUS 0x400 -#define VIA_REG_GEMODE 0x004 -#define VIA_REG_SRCBASE 0x030 -#define VIA_REG_DSTBASE 0x034 -#define VIA_REG_PITCH 0x038 -#define VIA_REG_SRCCOLORKEY 0x01C -#define VIA_REG_KEYCONTROL 0x02C -#define VIA_REG_SRCPOS 0x008 -#define VIA_REG_DSTPOS 0x00C -#define VIA_REG_GECMD 0x000 -#define VIA_REG_DIMENSION 0x010 /* width and height */ -#define VIA_REG_FGCOLOR 0x018 - -#define VIA_GEM_8bpp 0x00000000 -#define VIA_GEM_16bpp 0x00000100 -#define VIA_GEM_32bpp 0x00000300 -#define VIA_GEC_BLT 0x00000001 -#define VIA_PITCH_ENABLE 0x80000000 -#define VIA_GEC_INCX 0x00000000 -#define VIA_GEC_DECY 0x00004000 -#define VIA_GEC_INCY 0x00000000 -#define VIA_GEC_DECX 0x00008000 -#define VIA_GEC_FIXCOLOR_PAT 0x00002000 - - -#define VIA_BLIT_CLEAR 0x00 -#define VIA_BLIT_COPY 0xCC -#define VIA_BLIT_FILL 0xF0 -#define VIA_BLIT_SET 0xFF - -static void dump_dma( struct via_context *vmesa ) -{ - GLuint i; - GLuint *data = (GLuint *)vmesa->dma; - for (i = 0; i < vmesa->dmaLow; i += 16) { - fprintf(stderr, "%04x: ", i); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x\n", *data++); - } - fprintf(stderr, "******************************************\n"); -} - - - -void viaCheckDma(struct via_context *vmesa, GLuint bytes) -{ - VIA_FINISH_PRIM( vmesa ); - if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) { - viaFlushDma(vmesa); - } -} - - - -#define SetReg2DAGP(nReg, nData) do { \ - OUT_RING( ((nReg) >> 2) | 0xF0000000 ); \ - OUT_RING( nData ); \ -} while (0) - - -static void viaBlit(struct via_context *vmesa, GLuint bpp, - GLuint srcBase, GLuint srcPitch, - GLuint dstBase, GLuint dstPitch, - GLuint w, GLuint h, - GLuint blitMode, - GLuint color, GLuint nMask ) -{ - - GLuint dwGEMode, srcX, dstX, cmd; - RING_VARS; - - if (VIA_DEBUG & DEBUG_2D) - fprintf(stderr, - "%s bpp %d src %x/%x dst %x/%x w %d h %d " - " mode: %x color: 0x%08x mask 0x%08x\n", - __FUNCTION__, bpp, srcBase, srcPitch, dstBase, - dstPitch, w,h, blitMode, color, nMask); - - - if (!w || !h) - return; - - switch (bpp) { - case 16: - dwGEMode = VIA_GEM_16bpp; - srcX = (srcBase & 0x1f) >> 1; - dstX = (dstBase & 0x1f) >> 1; - break; - case 32: - dwGEMode = VIA_GEM_32bpp; - srcX = (srcBase & 0x1f) >> 2; - dstX = (dstBase & 0x1f) >> 2; - break; - default: - return; - } - - switch(blitMode) { - case VIA_BLIT_FILL: - cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24); - break; - case VIA_BLIT_COPY: - cmd = VIA_GEC_BLT | (VIA_BLIT_COPY << 24); - break; - default: - return; - } - - BEGIN_RING(22); - SetReg2DAGP( VIA_REG_GEMODE, dwGEMode); - SetReg2DAGP( VIA_REG_FGCOLOR, color); - SetReg2DAGP( 0x2C, nMask); - SetReg2DAGP( VIA_REG_SRCBASE, (srcBase & ~0x1f) >> 3); - SetReg2DAGP( VIA_REG_DSTBASE, (dstBase & ~0x1f) >> 3); - SetReg2DAGP( VIA_REG_PITCH, VIA_PITCH_ENABLE | - (srcPitch >> 3) | ((dstPitch >> 3) << 16)); - SetReg2DAGP( VIA_REG_SRCPOS, srcX); - SetReg2DAGP( VIA_REG_DSTPOS, dstX); - SetReg2DAGP( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1))); - SetReg2DAGP( VIA_REG_GECMD, cmd); - SetReg2DAGP( 0x2C, 0x00000000); - ADVANCE_RING(); -} - -static void viaFillBuffer(struct via_context *vmesa, - struct via_renderbuffer *buffer, - drm_clip_rect_t *pbox, - int nboxes, - GLuint pixel, - GLuint mask) -{ - GLuint bytePerPixel = buffer->bpp >> 3; - GLuint i; - - for (i = 0; i < nboxes ; i++) { - int x = pbox[i].x1 - buffer->drawX; - int y = pbox[i].y1 - buffer->drawY; - int w = pbox[i].x2 - pbox[i].x1; - int h = pbox[i].y2 - pbox[i].y1; - - int offset = (buffer->offset + - y * buffer->pitch + - x * bytePerPixel); - - viaBlit(vmesa, - buffer->bpp, - offset, buffer->pitch, - offset, buffer->pitch, - w, h, - VIA_BLIT_FILL, pixel, mask); - } -} - - - -static void viaClear(struct gl_context *ctx, GLbitfield mask) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - __DRIdrawable *dPriv = vmesa->driDrawable; - struct via_renderbuffer *const vrb = - (struct via_renderbuffer *) dPriv->driverPrivate; - int flag = 0; - GLuint i = 0; - GLuint clear_depth_mask = 0xf << 28; - GLuint clear_depth = 0; - - VIA_FLUSH_DMA(vmesa); - - if (mask & BUFFER_BIT_FRONT_LEFT) { - flag |= VIA_FRONT; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if (mask & BUFFER_BIT_BACK_LEFT) { - flag |= VIA_BACK; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if (mask & BUFFER_BIT_DEPTH) { - flag |= VIA_DEPTH; - clear_depth = (GLuint)(ctx->Depth.Clear * vmesa->ClearDepth); - clear_depth_mask &= ~vmesa->depth_clear_mask; - mask &= ~BUFFER_BIT_DEPTH; - } - - if (mask & BUFFER_BIT_STENCIL) { - if (vmesa->have_hw_stencil) { - if ((ctx->Stencil.WriteMask[0] & 0xff) == 0xff) { - flag |= VIA_DEPTH; - clear_depth &= ~0xff; - clear_depth |= (ctx->Stencil.Clear & 0xff); - clear_depth_mask &= ~vmesa->stencil_clear_mask; - mask &= ~BUFFER_BIT_STENCIL; - } - else { - if (VIA_DEBUG & DEBUG_2D) - fprintf(stderr, "Clear stencil writemask %x\n", - ctx->Stencil.WriteMask[0]); - } - } - } - - /* 16bpp doesn't support masked clears */ - if (vmesa->viaScreen->bytesPerPixel == 2 && - vmesa->ClearMask & 0xf0000000) { - if (flag & VIA_FRONT) - mask |= BUFFER_BIT_FRONT_LEFT; - if (flag & VIA_BACK) - mask |= BUFFER_BIT_BACK_LEFT; - flag &= ~(VIA_FRONT | VIA_BACK); - } - - if (flag) { - drm_clip_rect_t *boxes, *tmp_boxes = 0; - int nr = 0; - GLint cx, cy, cw, ch; - GLboolean all; - - LOCK_HARDWARE(vmesa); - - /* get region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - all = (cw == ctx->DrawBuffer->Width && ch == ctx->DrawBuffer->Height); - - /* flip top to bottom */ - cy = dPriv->h - cy - ch; - cx += vrb->drawX; - cy += vrb->drawY; - - if (!all) { - drm_clip_rect_t *b = vmesa->pClipRects; - - boxes = tmp_boxes = - (drm_clip_rect_t *)malloc(vmesa->numClipRects * - sizeof(drm_clip_rect_t)); - if (!boxes) { - UNLOCK_HARDWARE(vmesa); - return; - } - - for (; i < vmesa->numClipRects; i++) { - GLint x = b[i].x1; - GLint y = b[i].y1; - GLint w = b[i].x2 - x; - GLint h = b[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; - - boxes[nr].x1 = x; - boxes[nr].y1 = y; - boxes[nr].x2 = x + w; - boxes[nr].y2 = y + h; - nr++; - } - } - else { - boxes = vmesa->pClipRects; - nr = vmesa->numClipRects; - } - - if (flag & VIA_FRONT) { - viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, - vmesa->ClearMask); - } - - if (flag & VIA_BACK) { - viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, - vmesa->ClearMask); - } - - if (flag & VIA_DEPTH) { - viaFillBuffer(vmesa, &vmesa->depth, boxes, nr, clear_depth, - clear_depth_mask); - } - - viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); - UNLOCK_HARDWARE(vmesa); - - if (tmp_boxes) - free(tmp_boxes); - } - - if (mask) - _swrast_Clear(ctx, mask); -} - - - - -static void viaDoSwapBuffers(struct via_context *vmesa, - drm_clip_rect_t *b, - GLuint nbox) -{ - GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; - struct via_renderbuffer *front = &vmesa->front; - struct via_renderbuffer *back = &vmesa->back; - GLuint i; - - for (i = 0; i < nbox; i++, b++) { - GLint x = b->x1 - back->drawX; - GLint y = b->y1 - back->drawY; - GLint w = b->x2 - b->x1; - GLint h = b->y2 - b->y1; - - GLuint src = back->offset + y * back->pitch + x * bytePerPixel; - GLuint dest = front->offset + y * front->pitch + x * bytePerPixel; - - viaBlit(vmesa, - bytePerPixel << 3, - src, back->pitch, - dest, front->pitch, - w, h, - VIA_BLIT_COPY, 0, 0); - } - - viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* redundant */ -} - - -static void viaEmitBreadcrumbLocked( struct via_context *vmesa ) -{ - struct via_renderbuffer *buffer = &vmesa->breadcrumb; - GLuint value = vmesa->lastBreadcrumbWrite + 1; - - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s %d\n", __FUNCTION__, value); - - assert(!vmesa->dmaLow); - - viaBlit(vmesa, - buffer->bpp, - buffer->offset, buffer->pitch, - buffer->offset, buffer->pitch, - 1, 1, - VIA_BLIT_FILL, value, 0); - - viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* often redundant */ - vmesa->lastBreadcrumbWrite = value; -} - -void viaEmitBreadcrumb( struct via_context *vmesa ) -{ - LOCK_HARDWARE(vmesa); - if (vmesa->dmaLow) - viaFlushDmaLocked(vmesa, 0); - - viaEmitBreadcrumbLocked( vmesa ); - UNLOCK_HARDWARE(vmesa); -} - -static GLboolean viaCheckIdle( struct via_context *vmesa ) -{ - if ((vmesa->regEngineStatus[0] & 0xFFFEFFFF) == 0x00020000) { - return GL_TRUE; - } - return GL_FALSE; -} - - -GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value ) -{ - GLuint *buf = (GLuint *)vmesa->breadcrumb.map; - vmesa->lastBreadcrumbRead = *buf; - - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s %d < %d: %d\n", __FUNCTION__, value, - vmesa->lastBreadcrumbRead, - !VIA_GEQ_WRAP(value, vmesa->lastBreadcrumbRead)); - - return !VIA_GEQ_WRAP(value, vmesa->lastBreadcrumbRead); -} - -static void viaWaitBreadcrumb( struct via_context *vmesa, GLuint value ) -{ - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s %d\n", __FUNCTION__, value); - - assert(!VIA_GEQ_WRAP(value, vmesa->lastBreadcrumbWrite)); - - while (!viaCheckBreadcrumb( vmesa, value )) { - viaSwapOutWork( vmesa ); - via_release_pending_textures( vmesa ); - } -} - - -void viaWaitIdle( struct via_context *vmesa, GLboolean light ) -{ - VIA_FLUSH_DMA(vmesa); - - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n", - __FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite); - - /* Need to emit a new breadcrumb? - */ - if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) { - LOCK_HARDWARE(vmesa); - viaEmitBreadcrumbLocked( vmesa ); - UNLOCK_HARDWARE(vmesa); - } - - /* Need to wait? - */ - if (VIA_GEQ_WRAP(vmesa->lastDma, vmesa->lastBreadcrumbRead)) - viaWaitBreadcrumb( vmesa, vmesa->lastDma ); - - if (light) return; - - LOCK_HARDWARE(vmesa); - while(!viaCheckIdle(vmesa)) - ; - UNLOCK_HARDWARE(vmesa); - via_release_pending_textures(vmesa); -} - - -void viaWaitIdleLocked( struct via_context *vmesa, GLboolean light ) -{ - if (vmesa->dmaLow) - viaFlushDmaLocked(vmesa, 0); - - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n", - __FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite); - - /* Need to emit a new breadcrumb? - */ - if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) { - viaEmitBreadcrumbLocked( vmesa ); - } - - /* Need to wait? - */ - if (vmesa->lastDma >= vmesa->lastBreadcrumbRead) - viaWaitBreadcrumb( vmesa, vmesa->lastDma ); - - if (light) return; - - while(!viaCheckIdle(vmesa)) - ; - - via_release_pending_textures(vmesa); -} - - - -/* Wait for command stream to be processed *and* the next vblank to - * occur. Equivalent to calling WAIT_IDLE() and then WaitVBlank, - * except that WAIT_IDLE() will spin the CPU polling, while this is - * IRQ driven. - */ -static void viaWaitIdleVBlank( __DRIdrawable *dPriv, - struct via_context *vmesa, - GLuint value ) -{ - GLboolean missed_target; - __DRIscreen *psp = dPriv->driScreenPriv; - - VIA_FLUSH_DMA(vmesa); - - if (!value) - return; - - do { - if (value < vmesa->lastBreadcrumbRead || - vmesa->thrashing) - viaSwapOutWork(vmesa); - - driWaitForVBlank( dPriv, & missed_target ); - if ( missed_target ) { - vmesa->swap_missed_count++; - (*psp->systemTime->getUST)( &vmesa->swap_missed_ust ); - } - } - while (!viaCheckBreadcrumb(vmesa, value)); - - vmesa->thrashing = 0; /* reset flag on swap */ - vmesa->swap_count++; - via_release_pending_textures( vmesa ); -} - - - -static void viaDoPageFlipLocked(struct via_context *vmesa, GLuint offset) -{ - RING_VARS; - - if (VIA_DEBUG & DEBUG_2D) - fprintf(stderr, "%s %x\n", __FUNCTION__, offset); - - if (!vmesa->nDoneFirstFlip) { - vmesa->nDoneFirstFlip = GL_TRUE; - BEGIN_RING(4); - OUT_RING(HALCYON_HEADER2); - OUT_RING(0x00fe0000); - OUT_RING(0x0000000e); - OUT_RING(0x0000000e); - ADVANCE_RING(); - } - - BEGIN_RING(4); - OUT_RING( HALCYON_HEADER2 ); - OUT_RING( 0x00fe0000 ); - OUT_RING((HC_SubA_HFBBasL << 24) | (offset & 0xFFFFF8) | 0x2); - OUT_RING((HC_SubA_HFBDrawFirst << 24) | - ((offset & 0xFF000000) >> 24) | 0x0100); - ADVANCE_RING(); - - vmesa->pfCurrentOffset = vmesa->sarea->pfCurrentOffset = offset; - - viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* often redundant */ -} - -void viaResetPageFlippingLocked(struct via_context *vmesa) -{ - if (VIA_DEBUG & DEBUG_2D) - fprintf(stderr, "%s\n", __FUNCTION__); - - viaDoPageFlipLocked( vmesa, 0 ); - - if (vmesa->front.offset != 0) { - struct via_renderbuffer buffer_tmp; - memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_renderbuffer)); - } - - assert(vmesa->front.offset == 0); - vmesa->doPageFlip = vmesa->allowPageFlip = 0; -} - - -/* - * Copy the back buffer to the front buffer. - */ -void viaCopyBuffer(__DRIdrawable *dPriv) -{ - struct via_context *vmesa = - (struct via_context *)dPriv->driContextPriv->driverPrivate; - __DRIscreen *psp = dPriv->driScreenPriv; - - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, - "%s: lastSwap[1] %d lastSwap[0] %d lastWrite %d lastRead %d\n", - __FUNCTION__, - vmesa->lastSwap[1], - vmesa->lastSwap[0], - vmesa->lastBreadcrumbWrite, - vmesa->lastBreadcrumbRead); - - VIA_FLUSH_DMA(vmesa); - - if (dPriv->vblFlags == VBLANK_FLAG_SYNC && - vmesa->lastBreadcrumbWrite > 1) - viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite-1); - else - viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[1]); - - LOCK_HARDWARE(vmesa); - - /* Catch and cleanup situation where we were pageflipping but have - * stopped. - */ - if (dPriv->numClipRects && vmesa->sarea->pfCurrentOffset != 0) { - viaResetPageFlippingLocked(vmesa); - UNLOCK_HARDWARE(vmesa); - return; - } - - viaDoSwapBuffers(vmesa, dPriv->pClipRects, dPriv->numClipRects); - vmesa->lastSwap[1] = vmesa->lastSwap[0]; - vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite; - viaEmitBreadcrumbLocked(vmesa); - UNLOCK_HARDWARE(vmesa); - - (*psp->systemTime->getUST)( &vmesa->swap_ust ); -} - - -void viaPageFlip(__DRIdrawable *dPriv) -{ - struct via_context *vmesa = - (struct via_context *)dPriv->driContextPriv->driverPrivate; - struct via_renderbuffer buffer_tmp; - __DRIscreen *psp = dPriv->driScreenPriv; - - VIA_FLUSH_DMA(vmesa); - if (dPriv->vblFlags == VBLANK_FLAG_SYNC && - vmesa->lastBreadcrumbWrite > 1) - viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite - 1); - else - viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[0]); - - LOCK_HARDWARE(vmesa); - viaDoPageFlipLocked(vmesa, vmesa->back.offset); - vmesa->lastSwap[1] = vmesa->lastSwap[0]; - vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite; - viaEmitBreadcrumbLocked(vmesa); - UNLOCK_HARDWARE(vmesa); - - (*psp->systemTime->getUST)( &vmesa->swap_ust ); - - - /* KW: FIXME: When buffers are freed, could free frontbuffer by - * accident: - */ - memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_renderbuffer)); - memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_renderbuffer)); -} - - - - -#define VIA_CMDBUF_MAX_LAG 50000 - -static int fire_buffer(struct via_context *vmesa) -{ - drm_via_cmdbuffer_t bufI; - int ret; - - bufI.buf = (char *)vmesa->dma; - bufI.size = vmesa->dmaLow; - - if (vmesa->useAgp) { - drm_via_cmdbuf_size_t bSiz; - - /* Do the CMDBUF_SIZE ioctl: - */ - bSiz.func = VIA_CMDBUF_LAG; - bSiz.wait = 1; - bSiz.size = VIA_CMDBUF_MAX_LAG; - do { - ret = drmCommandWriteRead(vmesa->driFd, DRM_VIA_CMDBUF_SIZE, - &bSiz, sizeof(bSiz)); - } while (ret == -EAGAIN); - if (ret) { - UNLOCK_HARDWARE(vmesa); - fprintf(stderr, "%s: DRM_VIA_CMDBUF_SIZE returned %d\n", - __FUNCTION__, ret); - abort(); - return ret; - } - - /* Actually fire the buffer: - */ - do { - ret = drmCommandWrite(vmesa->driFd, DRM_VIA_CMDBUFFER, - &bufI, sizeof(bufI)); - } while (ret == -EAGAIN); - if (ret) { - UNLOCK_HARDWARE(vmesa); - fprintf(stderr, "%s: DRM_VIA_CMDBUFFER returned %d\n", - __FUNCTION__, ret); - abort(); - /* If this fails, the original code fell back to the PCI path. - */ - } - else - return 0; - - /* Fall through to PCI handling?!? - */ - viaWaitIdleLocked(vmesa, GL_FALSE); - } - - ret = drmCommandWrite(vmesa->driFd, DRM_VIA_PCICMD, &bufI, sizeof(bufI)); - if (ret) { - UNLOCK_HARDWARE(vmesa); - dump_dma(vmesa); - fprintf(stderr, "%s: DRM_VIA_PCICMD returned %d\n", __FUNCTION__, ret); - abort(); - } - - return ret; -} - - -/* Inserts the surface addresss and active cliprects one at a time - * into the head of the DMA buffer being flushed. Fires the buffer - * for each cliprect. - */ -static void via_emit_cliprect(struct via_context *vmesa, - drm_clip_rect_t *b) -{ - struct via_renderbuffer *buffer = vmesa->drawBuffer; - GLuint *vb = (GLuint *)(vmesa->dma + vmesa->dmaCliprectAddr); - - GLuint format = (vmesa->viaScreen->bitsPerPixel == 0x20 - ? HC_HDBFM_ARGB8888 - : HC_HDBFM_RGB565); - - GLuint pitch = buffer->pitch; - GLuint offset = buffer->offset; - - if (0) - fprintf(stderr, "emit cliprect for box %d,%d %d,%d\n", - b->x1, b->y1, b->x2, b->y2); - - vb[0] = HC_HEADER2; - vb[1] = (HC_ParaType_NotTex << 16); - - assert(vmesa->driDrawable); - - if (vmesa->driDrawable->w == 0 || vmesa->driDrawable->h == 0) { - vb[2] = (HC_SubA_HClipTB << 24) | 0x0; - vb[3] = (HC_SubA_HClipLR << 24) | 0x0; - } - else { - vb[2] = (HC_SubA_HClipTB << 24) | (b->y1 << 12) | b->y2; - vb[3] = (HC_SubA_HClipLR << 24) | (b->x1 << 12) | b->x2; - } - - vb[4] = (HC_SubA_HDBBasL << 24) | (offset & 0xFFFFFF); - vb[5] = (HC_SubA_HDBBasH << 24) | ((offset & 0xFF000000) >> 24); - - vb[6] = (HC_SubA_HSPXYOS << 24); - vb[7] = (HC_SubA_HDBFM << 24) | HC_HDBLoc_Local | format | pitch; -} - - - -static int intersect_rect(drm_clip_rect_t *out, - drm_clip_rect_t *a, - drm_clip_rect_t *b) -{ - *out = *a; - - if (0) - fprintf(stderr, "intersect %d,%d %d,%d and %d,%d %d,%d\n", - a->x1, a->y1, a->x2, a->y2, - b->x1, b->y1, b->x2, b->y2); - - if (b->x1 > out->x1) out->x1 = b->x1; - if (b->x2 < out->x2) out->x2 = b->x2; - 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; -} - -void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags) -{ - int i; - RING_VARS; - - if (VIA_DEBUG & (DEBUG_IOCTL|DEBUG_DMA)) - fprintf(stderr, "%s\n", __FUNCTION__); - - if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) && - *(GLuint *)vmesa->driHwLock != - (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) { - fprintf(stderr, "%s called without lock held\n", __FUNCTION__); - abort(); - } - - if (vmesa->dmaLow == 0) { - return; - } - - assert(vmesa->dmaLastPrim == 0); - - /* viaFinishPrimitive can add up to 8 bytes beyond VIA_DMA_HIGHWATER: - */ - if (vmesa->dmaLow > VIA_DMA_HIGHWATER + 8) { - fprintf(stderr, "buffer overflow in Flush Prims = %d\n",vmesa->dmaLow); - abort(); - } - - switch (vmesa->dmaLow & 0x1F) { - case 8: - BEGIN_RING_NOCHECK( 6 ); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - ADVANCE_RING(); - break; - case 16: - BEGIN_RING_NOCHECK( 4 ); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - ADVANCE_RING(); - break; - case 24: - BEGIN_RING_NOCHECK( 10 ); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - OUT_RING( HC_DUMMY ); - ADVANCE_RING(); - break; - case 0: - break; - default: - if (VIA_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s: unaligned value for vmesa->dmaLow: %x\n", - __FUNCTION__, vmesa->dmaLow); - } - - vmesa->lastDma = vmesa->lastBreadcrumbWrite; - - if (VIA_DEBUG & DEBUG_DMA) - dump_dma( vmesa ); - - if (flags & VIA_NO_CLIPRECTS) { - if (0) fprintf(stderr, "%s VIA_NO_CLIPRECTS\n", __FUNCTION__); - assert(vmesa->dmaCliprectAddr == ~0); - fire_buffer( vmesa ); - } - else if (vmesa->dmaCliprectAddr == ~0) { - /* Contains only state. Could just dump the packet? - */ - if (0) fprintf(stderr, "%s: no dmaCliprectAddr\n", __FUNCTION__); - if (0) fire_buffer( vmesa ); - } - else if (vmesa->numClipRects) { - drm_clip_rect_t *pbox = vmesa->pClipRects; - - for (i = 0; i < vmesa->numClipRects; i++) { - drm_clip_rect_t b; - - b.x1 = pbox[i].x1; - b.x2 = pbox[i].x2; - b.y1 = pbox[i].y1; - b.y2 = pbox[i].y2; - - if (vmesa->scissor && - !intersect_rect(&b, &b, &vmesa->scissorRect)) - continue; - - via_emit_cliprect(vmesa, &b); - - if (fire_buffer(vmesa) != 0) { - dump_dma( vmesa ); - goto done; - } - } - } else { - if (0) fprintf(stderr, "%s: no cliprects\n", __FUNCTION__); - UNLOCK_HARDWARE(vmesa); - sched_yield(); - LOCK_HARDWARE(vmesa); - } - - done: - /* Reset vmesa vars: - */ - vmesa->dmaLow = 0; - vmesa->dmaCliprectAddr = ~0; - vmesa->newEmitState = ~0; -} - -void viaWrapPrimitive( struct via_context *vmesa ) -{ - GLenum renderPrimitive = vmesa->renderPrimitive; - GLenum hwPrimitive = vmesa->hwPrimitive; - - if (VIA_DEBUG & DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__); - - if (vmesa->dmaLastPrim) - viaFinishPrimitive( vmesa ); - - viaFlushDma(vmesa); - - if (renderPrimitive != GL_POLYGON + 1) - viaRasterPrimitive( vmesa->glCtx, - renderPrimitive, - hwPrimitive ); - -} - -void viaFlushDma(struct via_context *vmesa) -{ - if (vmesa->dmaLow) { - assert(!vmesa->dmaLastPrim); - - LOCK_HARDWARE(vmesa); - viaFlushDmaLocked(vmesa, 0); - UNLOCK_HARDWARE(vmesa); - } -} - -static void viaFlush(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - VIA_FLUSH_DMA(vmesa); -} - -static void viaFinish(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - VIA_FLUSH_DMA(vmesa); - viaWaitIdle(vmesa, GL_FALSE); -} - -static void viaClearStencil(struct gl_context *ctx, int s) -{ - return; -} - -void viaInitIoctlFuncs(struct gl_context *ctx) -{ - ctx->Driver.Flush = viaFlush; - ctx->Driver.Clear = viaClear; - ctx->Driver.Finish = viaFinish; - ctx->Driver.ClearStencil = viaClearStencil; -} - - - diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.h b/src/mesa/drivers/dri/unichrome/via_ioctl.h deleted file mode 100644 index 03df789b52c..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIAIOCTL_H -#define _VIAIOCTL_H - -#include "via_context.h" - - -void viaFinishPrimitive(struct via_context *vmesa); -void viaFlushDma(struct via_context *vmesa); -void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags); - -void viaInitIoctlFuncs(struct gl_context *ctx); -void viaCopyBuffer(__DRIdrawable *dpriv); -void viaPageFlip(__DRIdrawable *dpriv); -void viaCheckDma(struct via_context *vmesa, GLuint bytes); -void viaResetPageFlippingLocked(struct via_context *vmesa); -void viaWaitIdle(struct via_context *vmesa, GLboolean light); -void viaWaitIdleLocked(struct via_context *vmesa, GLboolean light); - -GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value ); -void viaEmitBreadcrumb( struct via_context *vmesa ); - - -#define VIA_FINISH_PRIM(vmesa) do { \ - if (vmesa->dmaLastPrim) \ - viaFinishPrimitive( vmesa ); \ -} while (0) - -#define VIA_FLUSH_DMA(vmesa) do { \ - VIA_FINISH_PRIM(vmesa); \ - if (vmesa->dmaLow) \ - viaFlushDma(vmesa); \ -} while (0) - - -void viaWrapPrimitive( struct via_context *vmesa ); - -static INLINE GLuint *viaAllocDma(struct via_context *vmesa, int bytes) -{ - if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) { - viaFlushDma(vmesa); - } - - { - GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow); - vmesa->dmaLow += bytes; - return start; - } -} - - -static GLuint INLINE *viaExtendPrimitive(struct via_context *vmesa, int bytes) -{ - if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) { - viaWrapPrimitive(vmesa); - } - - { - GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow); - vmesa->dmaLow += bytes; - return start; - } -} - - - - -#define RING_VARS GLuint *_vb = 0, _nr, _x; - -#define BEGIN_RING(n) do { \ - if (_vb != 0) abort(); \ - _vb = viaAllocDma(vmesa, (n) * sizeof(GLuint)); \ - _nr = (n); \ - _x = 0; \ -} while (0) - -#define BEGIN_RING_NOCHECK(n) do { \ - if (_vb != 0) abort(); \ - _vb = (GLuint *)(vmesa->dma + vmesa->dmaLow); \ - vmesa->dmaLow += (n) * sizeof(GLuint); \ - _nr = (n); \ - _x = 0; \ -} while (0) - -#define OUT_RING(n) _vb[_x++] = (n) - -#define ADVANCE_RING() do { \ - if (_x != _nr) abort(); \ - _vb = 0; \ -} while (0) - -#define ADVANCE_RING_VARIABLE() do { \ - if (_x > _nr) abort(); \ - vmesa->dmaLow -= (_nr - _x) * sizeof(GLuint); \ - _vb = 0; \ -} while (0) - - -#define QWORD_PAD_RING() do { \ - if (vmesa->dmaLow & 0x4) { \ - BEGIN_RING(1); \ - OUT_RING(HC_DUMMY); \ - ADVANCE_RING(); \ - } \ -} while (0) - -#define VIA_GEQ_WRAP(left, right) \ - (((left) - (right)) < ( 1 << 23)) - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_memcpy.c b/src/mesa/drivers/dri/unichrome/via_memcpy.c deleted file mode 100644 index d7b05bcaaf9..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_memcpy.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2004 Thomas Hellstrom, All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE CODE SUPPLIER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* Thomas' orginal gutted for mesa by Keith Whitwell - */ - -#include "via_tex.h" - -#if defined( USE_SSE_ASM ) - -#define SSE_PREFETCH " prefetchnta " -#define FENCE __asm__ __volatile__ ("sfence":::"memory"); - - -#define PREFETCH1(arch_prefetch,from) \ - __asm__ __volatile__ ( \ - "1: " arch_prefetch "(%0)\n" \ - arch_prefetch "32(%0)\n" \ - arch_prefetch "64(%0)\n" \ - arch_prefetch "96(%0)\n" \ - arch_prefetch "128(%0)\n" \ - arch_prefetch "160(%0)\n" \ - arch_prefetch "192(%0)\n" \ - arch_prefetch "256(%0)\n" \ - arch_prefetch "288(%0)\n" \ - "2:\n" \ - : : "r" (from) ); - - - -#define small_memcpy(to,from,n) \ - { \ - __asm__ __volatile__( \ - "movl %2,%%ecx\n\t" \ - "sarl $2,%%ecx\n\t" \ - "rep ; movsl\n\t" \ - "testb $2,%b2\n\t" \ - "je 1f\n\t" \ - "movsw\n" \ - "1:\ttestb $1,%b2\n\t" \ - "je 2f\n\t" \ - "movsb\n" \ - "2:" \ - :"=&D" (to), "=&S" (from) \ - :"q" (n),"0" ((long) to),"1" ((long) from) \ - : "%ecx","memory"); \ - } - - -#define SSE_CPY(prefetch,from,to,dummy,lcnt) \ - if ((unsigned long) from & 15) { \ - __asm__ __volatile__ ( \ - "1:\n" \ - prefetch "320(%1)\n" \ - " movups (%1), %%xmm0\n" \ - " movups 16(%1), %%xmm1\n" \ - " movntps %%xmm0, (%0)\n" \ - " movntps %%xmm1, 16(%0)\n" \ - prefetch "352(%1)\n" \ - " movups 32(%1), %%xmm2\n" \ - " movups 48(%1), %%xmm3\n" \ - " movntps %%xmm2, 32(%0)\n" \ - " movntps %%xmm3, 48(%0)\n" \ - " addl $64,%0\n" \ - " addl $64,%1\n" \ - " decl %2\n" \ - " jne 1b\n" \ - :"=&D"(to), "=&S"(from), "=&r"(dummy) \ - :"0" (to), "1" (from), "2" (lcnt): "memory"); \ - } else { \ - __asm__ __volatile__ ( \ - "2:\n" \ - prefetch "320(%1)\n" \ - " movaps (%1), %%xmm0\n" \ - " movaps 16(%1), %%xmm1\n" \ - " movntps %%xmm0, (%0)\n" \ - " movntps %%xmm1, 16(%0)\n" \ - prefetch "352(%1)\n" \ - " movaps 32(%1), %%xmm2\n" \ - " movaps 48(%1), %%xmm3\n" \ - " movntps %%xmm2, 32(%0)\n" \ - " movntps %%xmm3, 48(%0)\n" \ - " addl $64,%0\n" \ - " addl $64,%1\n" \ - " decl %2\n" \ - " jne 2b\n" \ - :"=&D"(to), "=&S"(from), "=&r"(dummy) \ - :"0" (to), "1" (from), "2" (lcnt): "memory"); \ - } - - - -/* - */ -void via_sse_memcpy(void *to, - const void *from, - size_t sz) - -{ - int dummy; - int lcnt = sz >> 6; - int rest = sz & 63; - - PREFETCH1(SSE_PREFETCH,from); - - if (lcnt > 5) { - lcnt -= 5; - SSE_CPY(SSE_PREFETCH,from,to,dummy,lcnt); - lcnt = 5; - } - if (lcnt) { - SSE_CPY("#",from,to,dummy,lcnt); - } - if (rest) small_memcpy(to, from, rest); - FENCE; -} - -#endif /* defined( USE_SSE_ASM ) */ diff --git a/src/mesa/drivers/dri/unichrome/via_render.c b/src/mesa/drivers/dri/unichrome/via_render.c deleted file mode 100644 index 10e2b4eaddf..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_render.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/* - * Render unclipped vertex buffers by emitting vertices directly to - * dma buffers. Use strip/fan hardware acceleration where possible. - * - */ -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/mtypes.h" - -#include "math/m_xform.h" - -#include "tnl/t_context.h" - -#include "via_context.h" -#include "via_tris.h" -#include "via_ioctl.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_LINE_LOOP 1 -#define HAVE_TRIANGLES 1 -#define HAVE_TRI_STRIPS 1 -#define HAVE_TRI_STRIP_1 0 -#define HAVE_TRI_FANS 1 -#define HAVE_POLYGONS 1 -#define HAVE_QUADS 0 -#define HAVE_QUAD_STRIPS 0 - -#define HAVE_ELTS 0 - -#define LOCAL_VARS struct via_context *vmesa = VIA_CONTEXT(ctx) -#define INIT(prim) do { \ - viaRasterPrimitive(ctx, prim, prim); \ -} while (0) -#define GET_CURRENT_VB_MAX_VERTS() \ - ((VIA_DMA_BUF_SZ - (512 + (int)vmesa->dmaLow)) / (vmesa->vertexSize * 4)) -#define GET_SUBSEQUENT_VB_MAX_VERTS() \ - (VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4) - -#define ALLOC_VERTS( nr ) \ - viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4) - -#define EMIT_VERTS(ctx, j, nr, buf) \ - _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) - -#define FLUSH() VIA_FINISH_PRIM( vmesa ) - -#define TAG(x) via_fast##x -#include "tnl_dd/t_dd_dmatmp.h" -#undef TAG -#undef LOCAL_VARS -#undef INIT - -/**********************************************************************/ -/* Fast Render pipeline stage */ -/**********************************************************************/ -static GLboolean via_run_fastrender(struct gl_context *ctx, - struct tnl_pipeline_stage *stage) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - - tnl->Driver.Render.Start(ctx); - - if (VB->ClipOrMask || - vmesa->renderIndex != 0 || - !via_fastvalidate_render( ctx, VB )) { - tnl->Driver.Render.Finish(ctx); - return GL_TRUE; - } - - tnl->clipspace.new_inputs |= VERT_BIT_POS; - - for (i = 0; i < VB->PrimitiveCount; ++i) { - GLuint mode = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - if (length) - via_fastrender_tab_verts[mode & PRIM_MODE_MASK](ctx, start, start+length, mode); - } - - tnl->Driver.Render.Finish(ctx); - - return GL_FALSE; /* finished the pipe */ -} - -const struct tnl_pipeline_stage _via_fastrender_stage = -{ - "via fast render", - NULL, - NULL, - NULL, - NULL, - via_run_fastrender /* run */ -}; - - diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c deleted file mode 100644 index 9ea656cf023..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <stdio.h> - -#include "dri_util.h" -#include "utils.h" -#include "main/glheader.h" -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/simple_list.h" -#include "vblank.h" - -#include "via_state.h" -#include "via_tex.h" -#include "via_span.h" -#include "via_screen.h" -#include "via_dri.h" - -#include "GL/internal/dri_interface.h" -#include "drirenderbuffer.h" - -#include "xmlpool.h" - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_QUALITY - DRI_CONF_EXCESS_MIPMAP(false) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) - DRI_CONF_SECTION_END -DRI_CONF_END; -static const GLuint __driNConfigOptions = 3; - -static drmBufMapPtr via_create_empty_buffers(void) -{ - drmBufMapPtr retval; - - retval = (drmBufMapPtr)MALLOC(sizeof(drmBufMap)); - if (retval == NULL) return NULL; - memset(retval, 0, sizeof(drmBufMap)); - - retval->list = (drmBufPtr)MALLOC(sizeof(drmBuf) * VIA_DMA_BUF_NR); - if (retval->list == NULL) { - FREE(retval); - return NULL; - } - memset(retval->list, 0, sizeof(drmBuf) * VIA_DMA_BUF_NR); - return retval; -} - -static void via_free_empty_buffers( drmBufMapPtr bufs ) -{ - if (bufs && bufs->list) - FREE(bufs->list); - - if (bufs) - FREE(bufs); -} - - -static GLboolean -viaInitDriver(__DRIscreen *sPriv) -{ - viaScreenPrivate *viaScreen; - VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv; - int i; - - if (sPriv->devPrivSize != sizeof(VIADRIRec)) { - fprintf(stderr,"\nERROR! sizeof(VIADRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - viaScreen = (viaScreenPrivate *) CALLOC(sizeof(viaScreenPrivate)); - if (!viaScreen) { - __driUtilMessage("viaInitDriver: alloc viaScreenPrivate struct failed"); - return GL_FALSE; - } - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&viaScreen->optionCache, - __driConfigOptions, __driNConfigOptions); - - - viaScreen->driScrnPriv = sPriv; - sPriv->private = (void *)viaScreen; - - viaScreen->deviceID = gDRIPriv->deviceID; - viaScreen->width = gDRIPriv->width; - viaScreen->height = gDRIPriv->height; - viaScreen->mem = gDRIPriv->mem; - viaScreen->bitsPerPixel = gDRIPriv->bytesPerPixel * 8; - viaScreen->bytesPerPixel = gDRIPriv->bytesPerPixel; - viaScreen->fbOffset = 0; - viaScreen->fbSize = gDRIPriv->fbSize; - viaScreen->irqEnabled = gDRIPriv->irqEnabled; - - if (VIA_DEBUG & DEBUG_DRI) { - fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID); - fprintf(stderr, "width = %08x\n", viaScreen->width); - fprintf(stderr, "height = %08x\n", viaScreen->height); - fprintf(stderr, "cpp = %08x\n", viaScreen->cpp); - fprintf(stderr, "fbOffset = %08x\n", viaScreen->fbOffset); - } - - viaScreen->bufs = via_create_empty_buffers(); - if (viaScreen->bufs == NULL) { - __driUtilMessage("viaInitDriver: via_create_empty_buffers() failed"); - FREE(viaScreen); - return GL_FALSE; - } - - if (drmMap(sPriv->fd, - gDRIPriv->regs.handle, - gDRIPriv->regs.size, - &viaScreen->reg) != 0) { - FREE(viaScreen); - sPriv->private = NULL; - __driUtilMessage("viaInitDriver: drmMap regs failed"); - return GL_FALSE; - } - - if (gDRIPriv->agp.size) { - if (drmMap(sPriv->fd, - gDRIPriv->agp.handle, - gDRIPriv->agp.size, - (drmAddress *)&viaScreen->agpLinearStart) != 0) { - drmUnmap(viaScreen->reg, gDRIPriv->regs.size); - FREE(viaScreen); - sPriv->private = NULL; - __driUtilMessage("viaInitDriver: drmMap agp failed"); - return GL_FALSE; - } - - viaScreen->agpBase = drmAgpBase(sPriv->fd); - } else - viaScreen->agpLinearStart = 0; - - viaScreen->sareaPrivOffset = gDRIPriv->sarea_priv_offset; - - i = 0; - viaScreen->extensions[i++] = &driReadDrawableExtension; - if ( viaScreen->irqEnabled ) { - viaScreen->extensions[i++] = &driSwapControlExtension.base; - viaScreen->extensions[i++] = &driMediaStreamCounterExtension.base; - } - - viaScreen->extensions[i++] = NULL; - sPriv->extensions = viaScreen->extensions; - - return GL_TRUE; -} - -static void -viaDestroyScreen(__DRIscreen *sPriv) -{ - viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private; - VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv; - - drmUnmap(viaScreen->reg, gDRIPriv->regs.size); - if (gDRIPriv->agp.size) - drmUnmap(viaScreen->agpLinearStart, gDRIPriv->agp.size); - - via_free_empty_buffers(viaScreen->bufs); - - driDestroyOptionInfo(&viaScreen->optionCache); - - FREE(viaScreen); - sPriv->private = NULL; -} - - -static GLboolean -viaCreateBuffer(__DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const struct gl_config *mesaVis, - GLboolean isPixmap) -{ -#if 0 - viaScreenPrivate *screen = (viaScreenPrivate *) driScrnPriv->private; -#endif - - GLboolean swStencil = (mesaVis->stencilBits > 0 && - mesaVis->depthBits != 24); - GLboolean swAccum = mesaVis->accumRedBits > 0; - - if (isPixmap) { - /* KW: This needs work, disabled for now: - */ -#if 0 - driDrawPriv->driverPrivate = (void *) - _mesa_create_framebuffer(mesaVis, - GL_FALSE, /* software depth buffer? */ - swStencil, - mesaVis->accumRedBits > 0, - GL_FALSE /* s/w alpha planes */); - - return (driDrawPriv->driverPrivate != NULL); -#endif - return GL_FALSE; - } - else { - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - /* The front color, back color and depth renderbuffers are - * set up later in calculate_buffer_parameters(). - * Only create/connect software-based buffers here. - */ - -#if 000 - /* This code _should_ be put to use. We have to move the - * viaRenderbuffer members out of the via_context structure. - * Those members should just be the renderbuffers hanging off the - * gl_framebuffer object. - */ - /* XXX check/fix the offset/pitch parameters! */ - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, - screen->bytesPerPixel, - 0, screen->width, driDrawPriv); - viaSetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, - screen->bytesPerPixel, - 0, screen->width, driDrawPriv); - viaSetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, - screen->bytesPerPixel, - 0, screen->width, driDrawPriv); - viaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, - screen->bytesPerPixel, - 0, screen->width, driDrawPriv); - viaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 32) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z32, NULL, - screen->bytesPerPixel, - 0, screen->width, driDrawPriv); - viaSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0 && !swStencil) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(MESA_FORMAT_S8, NULL, - screen->bytesPerPixel, - 0, screen->width, driDrawPriv); - viaSetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } -#endif - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - swStencil, - swAccum, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -viaDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -static const __DRIconfig ** -viaFillInModes( __DRIscreen *psp, - unsigned pixel_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - const unsigned back_buffer_factor = (have_back_buffer) ? 2 : 1; - GLenum fb_format; - GLenum fb_type; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - /* The 32-bit depth-buffer mode isn't supported yet, so don't actually - * enable it. - */ - static const uint8_t depth_bits_array[4] = { 0, 16, 24, 32 }; - static const uint8_t stencil_bits_array[4] = { 0, 0, 8, 0 }; - uint8_t msaa_samples_array[1] = { 0 }; - const unsigned depth_buffer_factor = 3; - - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, back_buffer_modes, - back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, - __LINE__); - return NULL; - } - - return (const __DRIconfig **) configs; -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -viaInitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { VIA_DRIDDX_VERSION_MAJOR, - VIA_DRIDDX_VERSION_MINOR, - VIA_DRIDDX_VERSION_PATCH }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 2, 3, 0 }; - static const char *driver_name = "Unichrome"; - VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions2( driver_name, - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected) ) - return NULL; - - if (!viaInitDriver(psp)) - return NULL; - - return viaFillInModes( psp, dri_priv->bytesPerPixel * 8, GL_TRUE ); - -} - - -/** - * Get information about previous buffer swaps. - */ -static int -getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo ) -{ - struct via_context *vmesa; - - if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL) - || (dPriv->driContextPriv->driverPrivate == NULL) - || (sInfo == NULL) ) { - return -1; - } - - vmesa = (struct via_context *) dPriv->driContextPriv->driverPrivate; - sInfo->swap_count = vmesa->swap_count; - sInfo->swap_ust = vmesa->swap_ust; - sInfo->swap_missed_count = vmesa->swap_missed_count; - - sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0) - ? driCalculateSwapUsage( dPriv, 0, vmesa->swap_missed_ust ) - : 0.0; - - return 0; -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = viaInitScreen, - .DestroyScreen = viaDestroyScreen, - .CreateContext = viaCreateContext, - .DestroyContext = viaDestroyContext, - .CreateBuffer = viaCreateBuffer, - .DestroyBuffer = viaDestroyBuffer, - .SwapBuffers = viaSwapBuffers, - .MakeCurrent = viaMakeCurrent, - .UnbindContext = viaUnbindContext, - .GetSwapInfo = getSwapInfo, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h deleted file mode 100644 index 292646dabde..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIAINIT_H -#define _VIAINIT_H - -#include <sys/time.h> -#include "dri_util.h" -#include "via_dri.h" -#include "xmlconfig.h" - -typedef struct { - viaRegion regs; - viaRegion agp; - int deviceID; - int width; - int height; - int mem; - - int cpp; - int bitsPerPixel; - int bytesPerPixel; - int fbFormat; - int fbOffset; - int fbSize; - - int fbStride; - - int backOffset; - int depthOffset; - - int backPitch; - int backPitchBits; - - int textureOffset; - int textureSize; - int logTextureGranularity; - - drmAddress reg; - drmAddress agpLinearStart; - GLuint agpBase; - - __DRIscreen *driScrnPriv; - drmBufMapPtr bufs; - unsigned int sareaPrivOffset; - /*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/ - int VQEnable; - int irqEnabled; - - /* Configuration cache with default values for all contexts */ - driOptionCache optionCache; - - const __DRIextension *extensions[5]; -} viaScreenPrivate; - - -extern GLboolean -viaCreateContext(gl_api api, - const struct gl_config *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate); - -extern void -viaDestroyContext(__DRIcontext *driContextPriv); - -extern GLboolean -viaUnbindContext(__DRIcontext *driContextPriv); - -extern GLboolean -viaMakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv); - -extern void -viaSwapBuffers(__DRIdrawable *drawablePrivate); - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_span.c b/src/mesa/drivers/dri/unichrome/via_span.c deleted file mode 100644 index 4ca584261bc..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_span.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/glheader.h" -#include "main/formats.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "via_context.h" -#include "via_span.h" -#include "via_ioctl.h" -#include "swrast/swrast.h" - -#define DBG 0 - -#define Y_FLIP(_y) (height - _y - 1) - -#define HW_LOCK() - -#define HW_UNLOCK() - -#undef LOCAL_VARS -#define LOCAL_VARS \ - struct via_renderbuffer *vrb = (struct via_renderbuffer *) rb; \ - __DRIdrawable *dPriv = vrb->dPriv; \ - GLuint pitch = vrb->pitch; \ - GLuint height = dPriv->h; \ - GLint p = 0; \ - char *buf = (char *)(vrb->origMap); \ - (void) p; - -/* ================================================================ - * Color buffer - */ - -/* 16 bit, RGB565 color spanline and pixel functions - */ -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#define SPANTMP_PIXEL_FMT GL_RGB -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 - -#define TAG(x) via##x##_565 -#define TAG2(x,y) via##x##_565##y -#include "spantmp2.h" - - -/* 32 bit, ARGB8888 color spanline and pixel functions - */ -#define GET_PTR(_x, _y) (buf + (_x) * 4 + (_y) * pitch) -#define SPANTMP_PIXEL_FMT GL_BGRA -#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV - -#define TAG(x) via##x##_8888 -#define TAG2(x,y) via##x##_8888##y -#include "spantmp2.h" - - -/* 16 bit depthbuffer functions. - */ -#define LOCAL_DEPTH_VARS \ - struct via_renderbuffer *vrb = (struct via_renderbuffer *) rb; \ - __DRIdrawable *dPriv = vrb->dPriv; \ - GLuint depth_pitch = vrb->pitch; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(vrb->map) - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH(_x, _y, d) \ - *(GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch) = d; - -#define READ_DEPTH(d, _x, _y) \ - d = *(volatile GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch); - -#define TAG(x) via##x##_z16 -#include "depthtmp.h" - -/* 32 bit depthbuffer functions. - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH(_x, _y, d) \ - *(GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch) = d; - -#define READ_DEPTH(d, _x, _y) \ - d = *(volatile GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch); - -#define TAG(x) via##x##_z32 -#include "depthtmp.h" - - - -/* 24/8 bit interleaved depth/stencil functions - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \ - tmp &= 0x000000ff; \ - tmp |= ((d)<<8); \ - *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) = tmp; \ -} - -#define READ_DEPTH( d, _x, _y ) \ - d = (*(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch)) >> 8; - - -#define TAG(x) via##x##_z24_s8 -#include "depthtmp.h" - -#define WRITE_STENCIL( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \ - tmp &= 0xffffff00; \ - tmp |= (d); \ - *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) = tmp; \ -} - -#define READ_STENCIL( d, _x, _y ) \ - d = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) & 0xff; - -#define TAG(x) via##x##_z24_s8 -#include "stenciltmp.h" - - - - -/* Move locking out to get reasonable span performance. - */ -void viaSpanRenderStart( struct gl_context *ctx ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - viaWaitIdle(vmesa, GL_FALSE); - LOCK_HARDWARE(vmesa); -} - -void viaSpanRenderFinish( struct gl_context *ctx ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - _swrast_flush( ctx ); - UNLOCK_HARDWARE( vmesa ); -} - -void viaInitSpanFuncs(struct gl_context *ctx) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = viaSpanRenderStart; - swdd->SpanRenderFinish = viaSpanRenderFinish; -} - - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -viaSetSpanFunctions(struct via_renderbuffer *vrb, const struct gl_config *vis) -{ - if (vrb->Base.Format == MESA_FORMAT_RGB565) { - viaInitPointers_565(&vrb->Base); - } - else if (vrb->Base.Format == MESA_FORMAT_ARGB8888) { - viaInitPointers_8888(&vrb->Base); - } - else if (vrb->Base.Format == MESA_FORMAT_Z16) { - viaInitDepthPointers_z16(&vrb->Base); - } - else if (vrb->Base.Format == MESA_FORMAT_Z24_S8) { - viaInitDepthPointers_z24_s8(&vrb->Base); - } - else if (vrb->Base.Format == MESA_FORMAT_Z32) { - viaInitDepthPointers_z32(&vrb->Base); - } - else if (vrb->Base.Format == MESA_FORMAT_S8) { - viaInitStencilPointers_z24_s8(&vrb->Base); - } -} diff --git a/src/mesa/drivers/dri/unichrome/via_span.h b/src/mesa/drivers/dri/unichrome/via_span.h deleted file mode 100644 index b7abf685382..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_span.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIA_SPAN_H -#define _VIA_SPAN_H - -extern void viaInitSpanFuncs(struct gl_context *ctx); -extern void viaSpanRenderStart( struct gl_context *ctx ); -extern void viaSpanRenderFinish( struct gl_context *ctx ); - -extern void -viaSetSpanFunctions(struct via_renderbuffer *vrb, const struct gl_config *vis); - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c deleted file mode 100644 index 3b270e02a97..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ /dev/null @@ -1,1529 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <stdio.h> - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/colormac.h" -#include "main/enums.h" -#include "main/dd.h" -#include "main/mm.h" - -#include "via_context.h" -#include "via_state.h" -#include "via_tex.h" -#include "via_ioctl.h" -#include "via_3d_reg.h" - -#include "swrast/swrast.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "swrast_setup/swrast_setup.h" - - -static GLuint ROP[16] = { - HC_HROP_BLACK, /* GL_CLEAR 0 */ - HC_HROP_DPa, /* GL_AND s & d */ - HC_HROP_PDna, /* GL_AND_REVERSE s & ~d */ - HC_HROP_P, /* GL_COPY s */ - HC_HROP_DPna, /* GL_AND_INVERTED ~s & d */ - HC_HROP_D, /* GL_NOOP d */ - HC_HROP_DPx, /* GL_XOR s ^ d */ - HC_HROP_DPo, /* GL_OR s | d */ - HC_HROP_DPon, /* GL_NOR ~(s | d) */ - HC_HROP_DPxn, /* GL_EQUIV ~(s ^ d) */ - HC_HROP_Dn, /* GL_INVERT ~d */ - HC_HROP_PDno, /* GL_OR_REVERSE s | ~d */ - HC_HROP_Pn, /* GL_COPY_INVERTED ~s */ - HC_HROP_DPno, /* GL_OR_INVERTED ~s | d */ - HC_HROP_DPan, /* GL_NAND ~(s & d) */ - HC_HROP_WHITE /* GL_SET 1 */ -}; - -/* - * Compute the 'S5.5' lod bias factor from the floating point OpenGL bias. - */ -static GLuint viaComputeLodBias(GLfloat bias) -{ - int b = (int) (bias * 32.0); - if (b > 511) - b = 511; - else if (b < -512) - b = -512; - return (GLuint) b; -} - -void viaEmitState(struct via_context *vmesa) -{ - struct gl_context *ctx = vmesa->glCtx; - GLuint i = 0; - GLuint j = 0; - RING_VARS; - - viaCheckDma(vmesa, 0x110); - - BEGIN_RING(5); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( ((HC_SubA_HEnable << 24) | vmesa->regEnable) ); - OUT_RING( ((HC_SubA_HFBBMSKL << 24) | vmesa->regHFBBMSKL) ); - OUT_RING( ((HC_SubA_HROP << 24) | vmesa->regHROP) ); - ADVANCE_RING(); - - if (vmesa->have_hw_stencil) { - GLuint pitch, format, offset; - - format = HC_HZWBFM_24; - offset = vmesa->depth.offset; - pitch = vmesa->depth.pitch; - - BEGIN_RING(6); - OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) ); - OUT_RING( (HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24) ); - OUT_RING( (HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | - format | pitch ); - OUT_RING( (HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD ); - OUT_RING( (HC_SubA_HSTREF << 24) | vmesa->regHSTREF ); - OUT_RING( (HC_SubA_HSTMD << 24) | vmesa->regHSTMD ); - ADVANCE_RING(); - } - else if (vmesa->hasDepth) { - GLuint pitch, format, offset; - - if (vmesa->depthBits == 16) { - format = HC_HZWBFM_16; - } - else { - format = HC_HZWBFM_32; - } - - - offset = vmesa->depth.offset; - pitch = vmesa->depth.pitch; - - BEGIN_RING(4); - OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) ); - OUT_RING( (HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24) ); - OUT_RING( (HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | - format | pitch ); - OUT_RING( (HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD ); - ADVANCE_RING(); - } - - if (ctx->Color.AlphaEnabled) { - BEGIN_RING(1); - OUT_RING( (HC_SubA_HATMD << 24) | vmesa->regHATMD ); - ADVANCE_RING(); - i++; - } - - if (ctx->Color.BlendEnabled) { - BEGIN_RING(11); - OUT_RING( (HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat ); - OUT_RING( (HC_SubA_HABLCop << 24) | vmesa->regHABLCop ); - OUT_RING( (HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat ); - OUT_RING( (HC_SubA_HABLAop << 24) | vmesa->regHABLAop ); - OUT_RING( (HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa ); - OUT_RING( (HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa ); - OUT_RING( (HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias ); - OUT_RING( (HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb ); - OUT_RING( (HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb ); - OUT_RING( (HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa ); - OUT_RING( (HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb ); - ADVANCE_RING(); - } - - if (ctx->Fog.Enabled) { - BEGIN_RING(3); - OUT_RING( (HC_SubA_HFogLF << 24) | vmesa->regHFogLF ); - OUT_RING( (HC_SubA_HFogCL << 24) | vmesa->regHFogCL ); - OUT_RING( (HC_SubA_HFogCH << 24) | vmesa->regHFogCH ); - ADVANCE_RING(); - } - - if (ctx->Line.StippleFlag) { - BEGIN_RING(2); - OUT_RING( (HC_SubA_HLP << 24) | ctx->Line.StipplePattern ); - OUT_RING( (HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor ); - ADVANCE_RING(); - } - - BEGIN_RING(1); - OUT_RING( (HC_SubA_HPixGC << 24) | 0x0 ); - ADVANCE_RING(); - - QWORD_PAD_RING(); - - - if (ctx->Texture._EnabledUnits) { - - struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0]; - struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1]; - - { - GLuint nDummyValue = 0; - - BEGIN_RING( 8 ); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (HC_SubType_TexGeneral << 24) ); - - if (texUnit0->Enabled && texUnit1->Enabled) { - nDummyValue = (HC_SubA_HTXSMD << 24) | (1 << 3); - } - else { - nDummyValue = (HC_SubA_HTXSMD << 24) | 0; - } - - if (vmesa->clearTexCache) { - vmesa->clearTexCache = 0; - OUT_RING( nDummyValue | HC_HTXCHCLR_MASK ); - OUT_RING( nDummyValue ); - } - else { - OUT_RING( nDummyValue ); - OUT_RING( nDummyValue ); - } - - OUT_RING( HC_HEADER2 ); - OUT_RING( HC_ParaType_NotTex << 16 ); - OUT_RING( (HC_SubA_HEnable << 24) | vmesa->regEnable ); - OUT_RING( (HC_SubA_HEnable << 24) | vmesa->regEnable ); - ADVANCE_RING(); - } - - if (texUnit0->Enabled) { - struct gl_texture_object *texObj = texUnit0->_Current; - struct via_texture_object *t = (struct via_texture_object *)texObj; - GLuint numLevels = t->lastLevel - t->firstLevel + 1; - if (VIA_DEBUG & DEBUG_STATE) { - fprintf(stderr, "texture0 enabled\n"); - } - if (numLevels == 8) { - BEGIN_RING(27); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) ); - OUT_RING( t->regTexFM ); - OUT_RING( (HC_SubA_HTXnL0OS << 24) | - ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); - OUT_RING( t->regTexWidthLog2[0] ); - OUT_RING( t->regTexWidthLog2[1] ); - OUT_RING( t->regTexHeightLog2[0] ); - OUT_RING( t->regTexHeightLog2[1] ); - OUT_RING( t->regTexBaseH[0] ); - OUT_RING( t->regTexBaseH[1] ); - OUT_RING( t->regTexBaseH[2] ); - OUT_RING( t->regTexBaseAndPitch[0].baseL ); - OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[1].baseL ); - OUT_RING( t->regTexBaseAndPitch[1].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[2].baseL ); - OUT_RING( t->regTexBaseAndPitch[2].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[3].baseL ); - OUT_RING( t->regTexBaseAndPitch[3].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[4].baseL ); - OUT_RING( t->regTexBaseAndPitch[4].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[5].baseL ); - OUT_RING( t->regTexBaseAndPitch[5].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[6].baseL ); - OUT_RING( t->regTexBaseAndPitch[6].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[7].baseL ); - OUT_RING( t->regTexBaseAndPitch[7].pitchLog2 ); - ADVANCE_RING(); - } - else if (numLevels > 1) { - - BEGIN_RING(12 + numLevels * 2); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) ); - OUT_RING( t->regTexFM ); - OUT_RING( (HC_SubA_HTXnL0OS << 24) | - ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); - OUT_RING( t->regTexWidthLog2[0] ); - OUT_RING( t->regTexHeightLog2[0] ); - - if (numLevels > 6) { - OUT_RING( t->regTexWidthLog2[1] ); - OUT_RING( t->regTexHeightLog2[1] ); - } - - OUT_RING( t->regTexBaseH[0] ); - - if (numLevels > 3) { - OUT_RING( t->regTexBaseH[1] ); - } - if (numLevels > 6) { - OUT_RING( t->regTexBaseH[2] ); - } - if (numLevels > 9) { - OUT_RING( t->regTexBaseH[3] ); - } - - for (j = 0; j < numLevels; j++) { - OUT_RING( t->regTexBaseAndPitch[j].baseL ); - OUT_RING( t->regTexBaseAndPitch[j].pitchLog2 ); - } - - ADVANCE_RING_VARIABLE(); - } - else { - - BEGIN_RING(9); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) ); - OUT_RING( t->regTexFM ); - OUT_RING( (HC_SubA_HTXnL0OS << 24) | - ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); - OUT_RING( t->regTexWidthLog2[0] ); - OUT_RING( t->regTexHeightLog2[0] ); - OUT_RING( t->regTexBaseH[0] ); - OUT_RING( t->regTexBaseAndPitch[0].baseL ); - OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); - ADVANCE_RING(); - } - - BEGIN_RING(14); - OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB[0] ); - OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD[0] ); - OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat[0] ); - OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop[0] ); - OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog[0] ); - OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat[0] ); - OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb[0] ); - OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa[0] ); - OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog[0] ); - OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa[0] ); - OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc[0] ); - OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias[0] ); - OUT_RING( (HC_SubA_HTXnTBC << 24) | vmesa->regHTXnTBC[0] ); - OUT_RING( (HC_SubA_HTXnTRAH << 24) | vmesa->regHTXnTRAH[0] ); -/* OUT_RING( (HC_SubA_HTXnCLODu << 24) | vmesa->regHTXnCLOD[0] ); */ - ADVANCE_RING(); - - /* KW: This test never succeeds: - */ - if (t->regTexFM == HC_HTXnFM_Index8) { - const struct gl_color_table *table = &texObj->Palette; - const GLfloat *tableF = table->TableF; - - BEGIN_RING(2 + table->Size); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Palette << 16) | (0 << 24) ); - for (j = 0; j < table->Size; j++) - OUT_RING( tableF[j] ); - ADVANCE_RING(); - - } - - QWORD_PAD_RING(); - } - - if (texUnit1->Enabled) { - struct gl_texture_object *texObj = texUnit1->_Current; - struct via_texture_object *t = (struct via_texture_object *)texObj; - GLuint numLevels = t->lastLevel - t->firstLevel + 1; - int texunit = (texUnit0->Enabled ? 1 : 0); - if (VIA_DEBUG & DEBUG_STATE) { - fprintf(stderr, "texture1 enabled\n"); - } - if (numLevels == 8) { - BEGIN_RING(27); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (texunit << 24) ); - OUT_RING( t->regTexFM ); - OUT_RING( (HC_SubA_HTXnL0OS << 24) | - ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); - OUT_RING( t->regTexWidthLog2[0] ); - OUT_RING( t->regTexWidthLog2[1] ); - OUT_RING( t->regTexHeightLog2[0] ); - OUT_RING( t->regTexHeightLog2[1] ); - OUT_RING( t->regTexBaseH[0] ); - OUT_RING( t->regTexBaseH[1] ); - OUT_RING( t->regTexBaseH[2] ); - OUT_RING( t->regTexBaseAndPitch[0].baseL ); - OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[1].baseL ); - OUT_RING( t->regTexBaseAndPitch[1].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[2].baseL ); - OUT_RING( t->regTexBaseAndPitch[2].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[3].baseL ); - OUT_RING( t->regTexBaseAndPitch[3].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[4].baseL ); - OUT_RING( t->regTexBaseAndPitch[4].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[5].baseL ); - OUT_RING( t->regTexBaseAndPitch[5].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[6].baseL ); - OUT_RING( t->regTexBaseAndPitch[6].pitchLog2 ); - OUT_RING( t->regTexBaseAndPitch[7].baseL ); - OUT_RING( t->regTexBaseAndPitch[7].pitchLog2 ); - ADVANCE_RING(); - } - else if (numLevels > 1) { - BEGIN_RING(12 + numLevels * 2); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (texunit << 24) ); - OUT_RING( t->regTexFM ); - OUT_RING( (HC_SubA_HTXnL0OS << 24) | - ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); - OUT_RING( t->regTexWidthLog2[0] ); - OUT_RING( t->regTexHeightLog2[0] ); - - if (numLevels > 6) { - OUT_RING( t->regTexWidthLog2[1] ); - OUT_RING( t->regTexHeightLog2[1] ); - i += 2; - } - - OUT_RING( t->regTexBaseH[0] ); - - if (numLevels > 3) { - OUT_RING( t->regTexBaseH[1] ); - } - if (numLevels > 6) { - OUT_RING( t->regTexBaseH[2] ); - } - if (numLevels > 9) { - OUT_RING( t->regTexBaseH[3] ); - } - - for (j = 0; j < numLevels; j++) { - OUT_RING( t->regTexBaseAndPitch[j].baseL ); - OUT_RING( t->regTexBaseAndPitch[j].pitchLog2 ); - } - ADVANCE_RING_VARIABLE(); - } - else { - BEGIN_RING(9); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Tex << 16) | (texunit << 24) ); - OUT_RING( t->regTexFM ); - OUT_RING( (HC_SubA_HTXnL0OS << 24) | - ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); - OUT_RING( t->regTexWidthLog2[0] ); - OUT_RING( t->regTexHeightLog2[0] ); - OUT_RING( t->regTexBaseH[0] ); - OUT_RING( t->regTexBaseAndPitch[0].baseL ); - OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); - ADVANCE_RING(); - } - - BEGIN_RING(14); - OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB[1] ); - OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD[1] ); - OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat[1] ); - OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop[1] ); - OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog[1] ); - OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat[1] ); - OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb[1] ); - OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa[1] ); - OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog[1] ); - OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa[1] ); - OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc[1] ); - OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias[1] ); - OUT_RING( (HC_SubA_HTXnTBC << 24) | vmesa->regHTXnTBC[1] ); - OUT_RING( (HC_SubA_HTXnTRAH << 24) | vmesa->regHTXnTRAH[1] ); -/* OUT_RING( (HC_SubA_HTXnCLODu << 24) | vmesa->regHTXnCLOD[1] ); */ - ADVANCE_RING(); - - /* KW: This test never succeeds: - */ - if (t->regTexFM == HC_HTXnFM_Index8) { - const struct gl_color_table *table = &texObj->Palette; - const GLfloat *tableF = table->TableF; - - BEGIN_RING(2 + table->Size); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_Palette << 16) | (texunit << 24) ); - for (j = 0; j < table->Size; j++) { - OUT_RING( tableF[j] ); - } - ADVANCE_RING(); - } - - QWORD_PAD_RING(); - } - } - -#if 0 - /* Polygon stipple is broken - for certain stipple values, - * eg. 0xf0f0f0f0, the hardware will refuse to accept the stipple. - * Coincidentally, conform generates just such a stipple. - */ - if (ctx->Polygon.StippleFlag) { - GLuint *stipple = &ctx->PolygonStipple[0]; - __DRIdrawable *dPriv = vmesa->driDrawable; - struct via_renderbuffer *const vrb = - (struct via_renderbuffer *) dPriv->driverPrivate; - GLint i; - - BEGIN_RING(38); - OUT_RING( HC_HEADER2 ); - - OUT_RING( ((HC_ParaType_Palette << 16) | (HC_SubType_Stipple << 24)) ); - for (i = 31; i >= 0; i--) { - GLint j; - GLuint k = 0; - - /* Need to flip bits left to right: - */ - for (j = 0 ; j < 32; j++) - if (stipple[i] & (1<<j)) - k |= 1 << (31-j); - - OUT_RING( k ); - } - - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( (HC_SubA_HSPXYOS << 24) ); - OUT_RING( (HC_SubA_HSPXYOS << 24) ); - - ADVANCE_RING(); - } -#endif - - vmesa->newEmitState = 0; -} - - -static INLINE GLuint viaPackColor(GLuint bpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a) -{ - switch (bpp) { - case 16: - return PACK_COLOR_565(r, g, b); - case 32: - return PACK_COLOR_8888(a, r, g, b); - default: - assert(0); - return 0; - } -} - -static void viaBlendEquationSeparate(struct gl_context *ctx, - GLenum rgbMode, - GLenum aMode) -{ - if (VIA_DEBUG & DEBUG_STATE) - fprintf(stderr, "%s in\n", __FUNCTION__); - - /* GL_EXT_blend_equation_separate not supported */ - ASSERT(rgbMode == aMode); - - /* Can only do GL_ADD equation in hardware */ - FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_BLEND_EQ, - rgbMode != GL_FUNC_ADD_EXT); - - /* BlendEquation sets ColorLogicOpEnabled in an unexpected - * manner. - */ - FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); -} - -static void viaBlendFunc(struct gl_context *ctx, GLenum sfactor, GLenum dfactor) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLboolean fallback = GL_FALSE; - if (VIA_DEBUG & DEBUG_STATE) - fprintf(stderr, "%s in\n", __FUNCTION__); - - switch (ctx->Color.Blend[0].SrcRGB) { - case GL_SRC_ALPHA_SATURATE: - 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: - break; - } - - switch (ctx->Color.Blend[0].DstRGB) { - 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: - break; - } - - FALLBACK(vmesa, VIA_FALLBACK_BLEND_FUNC, fallback); -} - -/* Shouldn't be called as the extension is disabled. - */ -static void viaBlendFuncSeparate(struct gl_context *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA) -{ - if (dfactorRGB != dfactorA || sfactorRGB != sfactorA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBlendEquation (disabled)"); - } - - viaBlendFunc(ctx, sfactorRGB, dfactorRGB); -} - - - - -/* ============================================================= - * Hardware clipping - */ -static void viaScissor(struct gl_context *ctx, GLint x, GLint y, - GLsizei w, GLsizei h) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (!vmesa->driDrawable) - return; - - if (VIA_DEBUG & DEBUG_STATE) - fprintf(stderr, "%s %d,%d %dx%d, drawH %d\n", __FUNCTION__, - x,y,w,h, vmesa->driDrawable->h); - - if (vmesa->scissor) { - VIA_FLUSH_DMA(vmesa); /* don't pipeline cliprect changes */ - } - - vmesa->scissorRect.x1 = x; - vmesa->scissorRect.y1 = vmesa->driDrawable->h - y - h; - vmesa->scissorRect.x2 = x + w; - vmesa->scissorRect.y2 = vmesa->driDrawable->h - y; -} - -static void viaEnable(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - switch (cap) { - case GL_SCISSOR_TEST: - VIA_FLUSH_DMA(vmesa); - vmesa->scissor = state; - break; - default: - break; - } -} - - - -/* Fallback to swrast for select and feedback. - */ -static void viaRenderMode(struct gl_context *ctx, GLenum mode) -{ - FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_RENDERMODE, (mode != GL_RENDER)); -} - - -static void viaDrawBuffer(struct gl_context *ctx, GLenum mode) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (VIA_DEBUG & (DEBUG_DRI|DEBUG_STATE)) - fprintf(stderr, "%s in\n", __FUNCTION__); - - if (!ctx->DrawBuffer) - return; - - if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { - FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE); - return; - } - - switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { - case BUFFER_FRONT_LEFT: - VIA_FLUSH_DMA(vmesa); - vmesa->drawBuffer = &vmesa->front; - FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE); - break; - case BUFFER_BACK_LEFT: - VIA_FLUSH_DMA(vmesa); - vmesa->drawBuffer = &vmesa->back; - FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE); - break; - default: - FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE); - return; - } - - - viaXMesaWindowMoved(vmesa); -} - -static void viaClearColor(struct gl_context *ctx, const GLfloat color[4]) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLubyte pcolor[4]; - CLAMPED_FLOAT_TO_UBYTE(pcolor[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(pcolor[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(pcolor[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(pcolor[3], color[3]); - vmesa->ClearColor = viaPackColor(vmesa->viaScreen->bitsPerPixel, - pcolor[0], pcolor[1], - pcolor[2], pcolor[3]); -} - -#define WRITEMASK_ALPHA_SHIFT 31 -#define WRITEMASK_RED_SHIFT 30 -#define WRITEMASK_GREEN_SHIFT 29 -#define WRITEMASK_BLUE_SHIFT 28 - -static void viaColorMask(struct gl_context *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a) -{ - struct via_context *vmesa = VIA_CONTEXT( ctx ); - - if (VIA_DEBUG & DEBUG_STATE) - fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a); - - vmesa->ClearMask = (((!r) << WRITEMASK_RED_SHIFT) | - ((!g) << WRITEMASK_GREEN_SHIFT) | - ((!b) << WRITEMASK_BLUE_SHIFT) | - ((!a) << WRITEMASK_ALPHA_SHIFT)); -} - - - -/* This hardware just isn't capable of private back buffers without - * glitches and/or a hefty locking scheme. - */ -void viaCalcViewport(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - __DRIdrawable *dPriv = vmesa->driDrawable; - struct via_renderbuffer *const vrb = - (struct via_renderbuffer *) dPriv->driverPrivate; - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = vmesa->ViewportMatrix.m; - - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX] + vrb->drawX + SUBPIXEL_X; - m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = - v[MAT_TY] + vrb->drawY + SUBPIXEL_Y + vrb->drawH; - m[MAT_SZ] = v[MAT_SZ] * (1.0 / vmesa->depth_max); - m[MAT_TZ] = v[MAT_TZ] * (1.0 / vmesa->depth_max); -} - -static void viaViewport(struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - viaCalcViewport(ctx); -} - -static void viaDepthRange(struct gl_context *ctx, - GLclampd nearval, GLclampd farval) -{ - viaCalcViewport(ctx); -} - -void viaInitState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - vmesa->regCmdB = HC_ACMD_HCmdB; - vmesa->regEnable = HC_HenCW_MASK; - - /* Mesa should do this for us: - */ - - ctx->Driver.BlendEquationSeparate( ctx, - ctx->Color.Blend[0].EquationRGB, - ctx->Color.Blend[0].EquationA); - - ctx->Driver.BlendFuncSeparate( ctx, - ctx->Color.Blend[0].SrcRGB, - ctx->Color.Blend[0].DstRGB, - ctx->Color.Blend[0].SrcA, - ctx->Color.Blend[0].DstA); - - ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height ); - - ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] ); -} - -/** - * Convert S and T texture coordinate wrap modes to hardware bits. - */ -static uint32_t -get_wrap_mode( GLenum sWrap, GLenum tWrap ) -{ - uint32_t v = 0; - - - switch( sWrap ) { - case GL_REPEAT: - v |= HC_HTXnMPMD_Srepeat; - break; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - v |= HC_HTXnMPMD_Sclamp; - break; - case GL_MIRRORED_REPEAT: - v |= HC_HTXnMPMD_Smirror; - break; - } - - switch( tWrap ) { - case GL_REPEAT: - v |= HC_HTXnMPMD_Trepeat; - break; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - v |= HC_HTXnMPMD_Tclamp; - break; - case GL_MIRRORED_REPEAT: - v |= HC_HTXnMPMD_Tmirror; - break; - } - - return v; -} - -static uint32_t -get_minmag_filter( GLenum min, GLenum mag ) -{ - uint32_t v = 0; - - switch (min) { - case GL_NEAREST: - v = HC_HTXnFLSs_Nearest | - HC_HTXnFLTs_Nearest; - break; - case GL_LINEAR: - v = HC_HTXnFLSs_Linear | - HC_HTXnFLTs_Linear; - break; - case GL_NEAREST_MIPMAP_NEAREST: - v = HC_HTXnFLSs_Nearest | - HC_HTXnFLTs_Nearest; - v |= HC_HTXnFLDs_Nearest; - break; - case GL_LINEAR_MIPMAP_NEAREST: - v = HC_HTXnFLSs_Linear | - HC_HTXnFLTs_Linear; - v |= HC_HTXnFLDs_Nearest; - break; - case GL_NEAREST_MIPMAP_LINEAR: - v = HC_HTXnFLSs_Nearest | - HC_HTXnFLTs_Nearest; - v |= HC_HTXnFLDs_Linear; - break; - case GL_LINEAR_MIPMAP_LINEAR: - v = HC_HTXnFLSs_Linear | - HC_HTXnFLTs_Linear; - v |= HC_HTXnFLDs_Linear; - break; - default: - break; - } - - switch (mag) { - case GL_LINEAR: - v |= HC_HTXnFLSe_Linear | - HC_HTXnFLTe_Linear; - break; - case GL_NEAREST: - v |= HC_HTXnFLSe_Nearest | - HC_HTXnFLTe_Nearest; - break; - default: - break; - } - - return v; -} - - -static GLboolean viaChooseTextureState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0]; - struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1]; - - if (texUnit0->_ReallyEnabled || texUnit1->_ReallyEnabled) { - vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK; - - if (texUnit0->_ReallyEnabled) { - struct gl_texture_object *texObj = texUnit0->_Current; - - vmesa->regHTXnTB[0] = get_minmag_filter( texObj->Sampler.MinFilter, - texObj->Sampler.MagFilter ); - - vmesa->regHTXnMPMD[0] &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK); - vmesa->regHTXnMPMD[0] |= get_wrap_mode( texObj->Sampler.WrapS, - texObj->Sampler.WrapT ); - - vmesa->regHTXnTB[0] &= ~(HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T); - if (texObj->Image[0][texObj->BaseLevel]->Border > 0) { - vmesa->regHTXnTB[0] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T); - vmesa->regHTXnTBC[0] = - PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[0]), - FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[1]), - FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[2])); - vmesa->regHTXnTRAH[0] = FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[3]); - } - - if (texUnit0->LodBias != 0.0f) { - GLuint b = viaComputeLodBias(texUnit0->LodBias); - vmesa->regHTXnTB[0] &= ~HC_HTXnFLDs_MASK; - vmesa->regHTXnTB[0] |= HC_HTXnFLDs_ConstLOD; - vmesa->regHTXnCLOD[0] = (b&0x1f) | (((~b)&0x1f)<<10); /* FIXME */ - } - - if (!viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 )) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "viaTexCombineState failed for unit 0\n"); - return GL_FALSE; - } - } - - if (texUnit1->_ReallyEnabled) { - struct gl_texture_object *texObj = texUnit1->_Current; - - vmesa->regHTXnTB[1] = get_minmag_filter( texObj->Sampler.MinFilter, - texObj->Sampler.MagFilter ); - vmesa->regHTXnMPMD[1] &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK); - vmesa->regHTXnMPMD[1] |= get_wrap_mode( texObj->Sampler.WrapS, - texObj->Sampler.WrapT ); - - vmesa->regHTXnTB[1] &= ~(HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T); - if (texObj->Image[0][texObj->BaseLevel]->Border > 0) { - vmesa->regHTXnTB[1] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T); - vmesa->regHTXnTBC[1] = - PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[0]), - FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[1]), - FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[2])); - vmesa->regHTXnTRAH[1] = FLOAT_TO_UBYTE(texObj->Sampler.BorderColor.f[3]); - } - - - if (texUnit1->LodBias != 0.0f) { - GLuint b = viaComputeLodBias(texUnit1->LodBias); - vmesa->regHTXnTB[1] &= ~HC_HTXnFLDs_MASK; - vmesa->regHTXnTB[1] |= HC_HTXnFLDs_ConstLOD; - vmesa->regHTXnCLOD[1] = (b&0x1f) | (((~b)&0x1f)<<10); /* FIXME */ - } - - if (!viaTexCombineState( vmesa, texUnit1->_CurrentCombine, 1 )) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "viaTexCombineState failed for unit 1\n"); - return GL_FALSE; - } - } - } - else { - vmesa->regEnable &= ~(HC_HenTXMP_MASK | HC_HenTXCH_MASK | - HC_HenTXPP_MASK); - } - - return GL_TRUE; -} - -static void viaChooseColorState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLenum s = ctx->Color.Blend[0].SrcRGB; - GLenum d = ctx->Color.Blend[0].DstRGB; - - /* The HW's blending equation is: - * (Ca * FCa + Cbias + Cb * FCb) << Cshift - */ - - if (ctx->Color.BlendEnabled) { - vmesa->regEnable |= HC_HenABL_MASK; - /* Ca -- always from source color. - */ - vmesa->regHABLCsat = HC_HABLCsat_MASK | HC_HABLCa_OPC | HC_HABLCa_Csrc; - /* Aa -- always from source alpha. - */ - vmesa->regHABLAsat = HC_HABLAsat_MASK | HC_HABLAa_OPA | HC_HABLAa_Asrc; - /* FCa -- depend on following condition. - * FAa -- depend on following condition. - */ - switch (s) { - case GL_ZERO: - /* (0, 0, 0, 0) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa; - vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_HABLFRA; - vmesa->regHABLRFCa = 0x0; - vmesa->regHABLRAa = 0x0; - break; - case GL_ONE: - /* (1, 1, 1, 1) - */ - vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_HABLRCa; - vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_HABLFRA; - vmesa->regHABLRFCa = 0x0; - vmesa->regHABLRAa = 0x0; - break; - case GL_SRC_COLOR: - /* (Rs, Gs, Bs, As) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Csrc; - vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Asrc; - break; - case GL_ONE_MINUS_SRC_COLOR: - /* (1, 1, 1, 1) - (Rs, Gs, Bs, As) - */ - vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Csrc; - vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Asrc; - break; - case GL_DST_COLOR: - /* (Rd, Gd, Bd, Ad) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Cdst; - vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Adst; - break; - case GL_ONE_MINUS_DST_COLOR: - /* (1, 1, 1, 1) - (Rd, Gd, Bd, Ad) - */ - vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Cdst; - vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Adst; - break; - case GL_SRC_ALPHA: - /* (As, As, As, As) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Asrc; - vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Asrc; - break; - case GL_ONE_MINUS_SRC_ALPHA: - /* (1, 1, 1, 1) - (As, As, As, As) - */ - vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Asrc; - vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Asrc; - break; - case GL_DST_ALPHA: - { - if (vmesa->viaScreen->bitsPerPixel == 16) { - /* (1, 1, 1, 1) - */ - vmesa->regHABLCsat |= (HC_HABLFCa_InvOPC | - HC_HABLFCa_HABLRCa); - vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA | - HC_HABLFAa_HABLFRA); - vmesa->regHABLRFCa = 0x0; - vmesa->regHABLRAa = 0x0; - } - else { - /* (Ad, Ad, Ad, Ad) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Adst; - vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Adst; - } - } - break; - case GL_ONE_MINUS_DST_ALPHA: - { - if (vmesa->viaScreen->bitsPerPixel == 16) { - /* (1, 1, 1, 1) - (1, 1, 1, 1) = (0, 0, 0, 0) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa; - vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_HABLFRA; - vmesa->regHABLRFCa = 0x0; - vmesa->regHABLRAa = 0x0; - } - else { - /* (1, 1, 1, 1) - (Ad, Ad, Ad, Ad) - */ - vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Adst; - vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Adst; - } - } - break; - case GL_SRC_ALPHA_SATURATE: - { - if (vmesa->viaScreen->bitsPerPixel == 16) { - /* (f, f, f, 1), f = min(As, 1 - Ad) = min(As, 1 - 1) = 0 - * So (f, f, f, 1) = (0, 0, 0, 1) - */ - vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa; - vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA | - HC_HABLFAa_HABLFRA); - vmesa->regHABLRFCa = 0x0; - vmesa->regHABLRAa = 0x0; - } - else { - /* (f, f, f, 1), f = min(As, 1 - Ad) - */ - vmesa->regHABLCsat |= (HC_HABLFCa_OPC | - HC_HABLFCa_mimAsrcInvAdst); - vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA | - HC_HABLFAa_HABLFRA); - vmesa->regHABLRFCa = 0x0; - vmesa->regHABLRAa = 0x0; - } - } - break; - } - - /* Op is add. - */ - - /* bias is 0. - */ - vmesa->regHABLCsat |= HC_HABLCbias_HABLRCbias; - vmesa->regHABLAsat |= HC_HABLAbias_HABLRAbias; - - /* Cb -- always from destination color. - */ - vmesa->regHABLCop = HC_HABLCb_OPC | HC_HABLCb_Cdst; - /* Ab -- always from destination alpha. - */ - vmesa->regHABLAop = HC_HABLAb_OPA | HC_HABLAb_Adst; - /* FCb -- depend on following condition. - */ - switch (d) { - case GL_ZERO: - /* (0, 0, 0, 0) - */ - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_HABLRCb; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_HABLFRA; - vmesa->regHABLRFCb = 0x0; - vmesa->regHABLRAb = 0x0; - break; - case GL_ONE: - /* (1, 1, 1, 1) - */ - vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_HABLRCb; - vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_HABLFRA; - vmesa->regHABLRFCb = 0x0; - vmesa->regHABLRAb = 0x0; - break; - case GL_SRC_COLOR: - /* (Rs, Gs, Bs, As) - */ - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Csrc; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Asrc; - break; - case GL_ONE_MINUS_SRC_COLOR: - /* (1, 1, 1, 1) - (Rs, Gs, Bs, As) - */ - vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Csrc; - vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Asrc; - break; - case GL_DST_COLOR: - /* (Rd, Gd, Bd, Ad) - */ - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Cdst; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Adst; - break; - case GL_ONE_MINUS_DST_COLOR: - /* (1, 1, 1, 1) - (Rd, Gd, Bd, Ad) - */ - vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Cdst; - vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Adst; - break; - case GL_SRC_ALPHA: - /* (As, As, As, As) - */ - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Asrc; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Asrc; - break; - case GL_ONE_MINUS_SRC_ALPHA: - /* (1, 1, 1, 1) - (As, As, As, As) - */ - vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Asrc; - vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Asrc; - break; - case GL_DST_ALPHA: - { - if (vmesa->viaScreen->bitsPerPixel == 16) { - /* (1, 1, 1, 1) - */ - vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_HABLRCb; - vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_HABLFRA; - vmesa->regHABLRFCb = 0x0; - vmesa->regHABLRAb = 0x0; - } - else { - /* (Ad, Ad, Ad, Ad) - */ - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Adst; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Adst; - } - } - break; - case GL_ONE_MINUS_DST_ALPHA: - { - if (vmesa->viaScreen->bitsPerPixel == 16) { - /* (1, 1, 1, 1) - (1, 1, 1, 1) = (0, 0, 0, 0) - */ - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_HABLRCb; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_HABLFRA; - vmesa->regHABLRFCb = 0x0; - vmesa->regHABLRAb = 0x0; - } - else { - /* (1, 1, 1, 1) - (Ad, Ad, Ad, Ad) - */ - vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Adst; - vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Adst; - } - } - break; - default: - vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_HABLRCb; - vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_HABLFRA; - vmesa->regHABLRFCb = 0x0; - vmesa->regHABLRAb = 0x0; - break; - } - - if (vmesa->viaScreen->bitsPerPixel <= 16) - vmesa->regEnable &= ~HC_HenDT_MASK; - - } - else { - vmesa->regEnable &= (~HC_HenABL_MASK); - } - - if (ctx->Color.AlphaEnabled) { - vmesa->regEnable |= HC_HenAT_MASK; - vmesa->regHATMD = FLOAT_TO_UBYTE(ctx->Color.AlphaRef) | - ((ctx->Color.AlphaFunc - GL_NEVER) << 8); - } - else { - vmesa->regEnable &= (~HC_HenAT_MASK); - } - - if (ctx->Color.DitherFlag && (vmesa->viaScreen->bitsPerPixel < 32)) { - if (ctx->Color.BlendEnabled) { - vmesa->regEnable &= ~HC_HenDT_MASK; - } - else { - vmesa->regEnable |= HC_HenDT_MASK; - } - } - - - vmesa->regEnable &= ~HC_HenDT_MASK; - - if (ctx->Color.ColorLogicOpEnabled) - vmesa->regHROP = ROP[ctx->Color.LogicOp & 0xF]; - else - vmesa->regHROP = HC_HROP_P; - - vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0][0], - ctx->Color.ColorMask[0][1], - ctx->Color.ColorMask[0][2]); - vmesa->regHROP |= ctx->Color.ColorMask[0][3]; - - if (ctx->Color.ColorMask[0][3]) - vmesa->regEnable |= HC_HenAW_MASK; - else - vmesa->regEnable &= ~HC_HenAW_MASK; -} - -static void viaChooseFogState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (ctx->Fog.Enabled) { - GLubyte r, g, b, a; - - vmesa->regEnable |= HC_HenFOG_MASK; - - /* Use fog equation 0 (OpenGL's default) & local fog. - */ - vmesa->regHFogLF = 0x0; - - r = (GLubyte)(ctx->Fog.Color[0] * 255.0F); - g = (GLubyte)(ctx->Fog.Color[1] * 255.0F); - b = (GLubyte)(ctx->Fog.Color[2] * 255.0F); - a = (GLubyte)(ctx->Fog.Color[3] * 255.0F); - vmesa->regHFogCL = (r << 16) | (g << 8) | b; - vmesa->regHFogCH = a; - } - else { - vmesa->regEnable &= ~HC_HenFOG_MASK; - } -} - -static void viaChooseDepthState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - if (ctx->Depth.Test) { - vmesa->regEnable |= HC_HenZT_MASK; - if (ctx->Depth.Mask) - vmesa->regEnable |= HC_HenZW_MASK; - else - vmesa->regEnable &= (~HC_HenZW_MASK); - vmesa->regHZWTMD = (ctx->Depth.Func - GL_NEVER) << 16; - - } - else { - vmesa->regEnable &= ~HC_HenZT_MASK; - - /*=* [DBG] racer : can't display cars in car selection menu *=*/ - /*if (ctx->Depth.Mask) - vmesa->regEnable |= HC_HenZW_MASK; - else - vmesa->regEnable &= (~HC_HenZW_MASK);*/ - vmesa->regEnable &= (~HC_HenZW_MASK); - } -} - -static void viaChooseLineState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (ctx->Line.StippleFlag) { - vmesa->regEnable |= HC_HenLP_MASK; - vmesa->regHLP = ctx->Line.StipplePattern; - vmesa->regHLPRF = ctx->Line.StippleFactor; - } - else { - vmesa->regEnable &= ~HC_HenLP_MASK; - } -} - -static void viaChoosePolygonState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - -#if 0 - /* Polygon stipple is broken - see via_state.c - */ - if (ctx->Polygon.StippleFlag) { - vmesa->regEnable |= HC_HenSP_MASK; - } - else { - vmesa->regEnable &= ~HC_HenSP_MASK; - } -#else - FALLBACK(vmesa, VIA_FALLBACK_POLY_STIPPLE, - ctx->Polygon.StippleFlag); -#endif - - if (ctx->Polygon.CullFlag) { - vmesa->regEnable |= HC_HenFBCull_MASK; - } - else { - vmesa->regEnable &= ~HC_HenFBCull_MASK; - } -} - -static void viaChooseStencilState(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (ctx->Stencil._Enabled) { - GLuint temp; - - vmesa->regEnable |= HC_HenST_MASK; - temp = (ctx->Stencil.Ref[0] & 0xFF) << HC_HSTREF_SHIFT; - temp |= 0xFF << HC_HSTOPMSK_SHIFT; - temp |= (ctx->Stencil.ValueMask[0] & 0xFF); - vmesa->regHSTREF = temp; - - temp = (ctx->Stencil.Function[0] - GL_NEVER) << 16; - - switch (ctx->Stencil.FailFunc[0]) { - case GL_KEEP: - temp |= HC_HSTOPSF_KEEP; - break; - case GL_ZERO: - temp |= HC_HSTOPSF_ZERO; - break; - case GL_REPLACE: - temp |= HC_HSTOPSF_REPLACE; - break; - case GL_INVERT: - temp |= HC_HSTOPSF_INVERT; - break; - case GL_INCR: - temp |= HC_HSTOPSF_INCR; - break; - case GL_DECR: - temp |= HC_HSTOPSF_DECR; - break; - } - - switch (ctx->Stencil.ZFailFunc[0]) { - case GL_KEEP: - temp |= HC_HSTOPSPZF_KEEP; - break; - case GL_ZERO: - temp |= HC_HSTOPSPZF_ZERO; - break; - case GL_REPLACE: - temp |= HC_HSTOPSPZF_REPLACE; - break; - case GL_INVERT: - temp |= HC_HSTOPSPZF_INVERT; - break; - case GL_INCR: - temp |= HC_HSTOPSPZF_INCR; - break; - case GL_DECR: - temp |= HC_HSTOPSPZF_DECR; - break; - } - - switch (ctx->Stencil.ZPassFunc[0]) { - case GL_KEEP: - temp |= HC_HSTOPSPZP_KEEP; - break; - case GL_ZERO: - temp |= HC_HSTOPSPZP_ZERO; - break; - case GL_REPLACE: - temp |= HC_HSTOPSPZP_REPLACE; - break; - case GL_INVERT: - temp |= HC_HSTOPSPZP_INVERT; - break; - case GL_INCR: - temp |= HC_HSTOPSPZP_INCR; - break; - case GL_DECR: - temp |= HC_HSTOPSPZP_DECR; - break; - } - vmesa->regHSTMD = temp; - } - else { - vmesa->regEnable &= ~HC_HenST_MASK; - } -} - - - -static void viaChooseTriangle(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (ctx->Polygon.CullFlag == GL_TRUE) { - switch (ctx->Polygon.CullFaceMode) { - case GL_FRONT: - if (ctx->Polygon.FrontFace == GL_CCW) - vmesa->regCmdB |= HC_HBFace_MASK; - else - vmesa->regCmdB &= ~HC_HBFace_MASK; - break; - case GL_BACK: - if (ctx->Polygon.FrontFace == GL_CW) - vmesa->regCmdB |= HC_HBFace_MASK; - else - vmesa->regCmdB &= ~HC_HBFace_MASK; - break; - case GL_FRONT_AND_BACK: - return; - } - } -} - -void viaValidateState( struct gl_context *ctx ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (vmesa->newState & _NEW_TEXTURE) { - GLboolean ok = (viaChooseTextureState(ctx) && - viaUpdateTextureState(ctx)); - - FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, !ok); - } - - if (vmesa->newState & _NEW_COLOR) - viaChooseColorState(ctx); - - if (vmesa->newState & _NEW_DEPTH) - viaChooseDepthState(ctx); - - if (vmesa->newState & _NEW_FOG) - viaChooseFogState(ctx); - - if (vmesa->newState & _NEW_LINE) - viaChooseLineState(ctx); - - if (vmesa->newState & (_NEW_POLYGON | _NEW_POLYGONSTIPPLE)) { - viaChoosePolygonState(ctx); - viaChooseTriangle(ctx); - } - - if ((vmesa->newState & _NEW_STENCIL) && vmesa->have_hw_stencil) - viaChooseStencilState(ctx); - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - vmesa->regEnable |= HC_HenCS_MASK; - else - vmesa->regEnable &= ~HC_HenCS_MASK; - - if (ctx->Point.SmoothFlag || - ctx->Line.SmoothFlag || - ctx->Polygon.SmoothFlag) - vmesa->regEnable |= HC_HenAA_MASK; - else - vmesa->regEnable &= ~HC_HenAA_MASK; - - vmesa->newEmitState |= vmesa->newState; - vmesa->newState = 0; -} - -static void viaInvalidateState(struct gl_context *ctx, GLuint newState) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - VIA_FINISH_PRIM( vmesa ); - vmesa->newState |= newState; - - _swrast_InvalidateState(ctx, newState); - _swsetup_InvalidateState(ctx, newState); - _vbo_InvalidateState(ctx, newState); - _tnl_InvalidateState(ctx, newState); -} - -void viaInitStateFuncs(struct gl_context *ctx) -{ - /* Callbacks for internal Mesa events. - */ - ctx->Driver.UpdateState = viaInvalidateState; - - /* API callbacks - */ - ctx->Driver.BlendEquationSeparate = viaBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = viaBlendFuncSeparate; - ctx->Driver.ClearColor = viaClearColor; - ctx->Driver.ColorMask = viaColorMask; - ctx->Driver.DrawBuffer = viaDrawBuffer; - ctx->Driver.RenderMode = viaRenderMode; - ctx->Driver.Scissor = viaScissor; - ctx->Driver.DepthRange = viaDepthRange; - ctx->Driver.Viewport = viaViewport; - ctx->Driver.Enable = viaEnable; - - /* XXX this should go away */ - ctx->Driver.ResizeBuffers = viaReAllocateBuffers; -} diff --git a/src/mesa/drivers/dri/unichrome/via_state.h b/src/mesa/drivers/dri/unichrome/via_state.h deleted file mode 100644 index 8a237055201..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_state.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIA_STATE_H -#define _VIA_STATE_H - -#include "via_context.h" - -extern void viaInitState(struct gl_context *ctx); -extern void viaInitStateFuncs(struct gl_context *ctx); -extern void viaCalcViewport(struct gl_context *ctx); -extern void viaValidateState(struct gl_context *ctx); -extern void viaEmitState(struct via_context *vmesa); - -extern void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode); -#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode) - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c deleted file mode 100644 index fe5480ff25c..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_tex.c +++ /dev/null @@ -1,946 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include <stdlib.h> -#include <stdio.h> - -#include "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/enums.h" -#include "main/formats.h" -#include "main/context.h" -#include "main/mipmap.h" -#include "main/mm.h" -#include "main/pbo.h" -#include "main/simple_list.h" -#include "main/texobj.h" -#include "main/texstore.h" - -#include "via_context.h" -#include "via_fb.h" -#include "via_tex.h" -#include "via_ioctl.h" -#include "via_3d_reg.h" - -static gl_format -viaChooseTexFormat( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - const GLboolean do32bpt = ( vmesa->viaScreen->bitsPerPixel == 32 -/* && vmesa->viaScreen->textureSize > 4*1024*1024 */ - ); - - - switch ( internalFormat ) { - case 4: - case GL_RGBA: - case GL_COMPRESSED_RGBA: - if ( format == GL_BGRA ) { - if ( type == GL_UNSIGNED_INT_8_8_8_8_REV || - type == GL_UNSIGNED_BYTE ) { - return MESA_FORMAT_ARGB8888; - } - else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { - return MESA_FORMAT_ARGB4444; - } - else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { - return MESA_FORMAT_ARGB1555; - } - } - else if ( type == GL_UNSIGNED_BYTE || - type == GL_UNSIGNED_INT_8_8_8_8_REV || - type == GL_UNSIGNED_INT_8_8_8_8 ) { - return MESA_FORMAT_ARGB8888; - } - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444; - - case 3: - case GL_RGB: - case GL_COMPRESSED_RGB: - if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) { - return MESA_FORMAT_RGB565; - } - else if ( type == GL_UNSIGNED_BYTE ) { - return MESA_FORMAT_ARGB8888; - } - return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565; - - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return MESA_FORMAT_ARGB8888; - - case GL_RGBA4: - case GL_RGBA2: - return MESA_FORMAT_ARGB4444; - - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return MESA_FORMAT_ARGB8888; - - case GL_RGB5: - case GL_RGB4: - case GL_R3_G3_B2: - return MESA_FORMAT_RGB565; - - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - return MESA_FORMAT_A8; - - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - return MESA_FORMAT_L8; - - case 2: - case GL_LUMINANCE_ALPHA: - 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 GL_COMPRESSED_LUMINANCE_ALPHA: - return MESA_FORMAT_AL88; - - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return MESA_FORMAT_I8; - - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_MESA || - type == GL_UNSIGNED_BYTE) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return MESA_FORMAT_RGB_DXT1; - - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return MESA_FORMAT_RGBA_DXT1; - - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return MESA_FORMAT_RGBA_DXT3; - - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return MESA_FORMAT_RGBA_DXT5; - - 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_FORMAT_CI8; - - default: - fprintf(stderr, "unexpected texture format %s in %s\n", - _mesa_lookup_enum_by_nr(internalFormat), - __FUNCTION__); - return MESA_FORMAT_NONE; - } - - return MESA_FORMAT_NONE; /* never get here */ -} - - -static const char *get_memtype_name( GLint memType ) -{ - static const char *names[] = { - "VIA_MEM_VIDEO", - "VIA_MEM_AGP", - "VIA_MEM_SYSTEM", - "VIA_MEM_MIXED", - "VIA_MEM_UNKNOWN" - }; - - return names[memType]; -} - - -static GLboolean viaMoveTexBuffers( struct via_context *vmesa, - struct via_tex_buffer **buffers, - GLuint nr, - GLint newMemType ) -{ - struct via_tex_buffer *newTexBuf[VIA_MAX_TEXLEVELS]; - GLint i; - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s to %s\n", - __FUNCTION__, - get_memtype_name(newMemType)); - - memset(newTexBuf, 0, sizeof(newTexBuf)); - - /* First do all the allocations (or fail): - */ - for (i = 0; i < nr; i++) { - if (buffers[i]->memType != newMemType) { - - /* Don't allow uploads in a thrash state. Should try and - * catch this earlier. - */ - if (vmesa->thrashing && newMemType != VIA_MEM_SYSTEM) - goto cleanup; - - newTexBuf[i] = via_alloc_texture(vmesa, - buffers[i]->size, - newMemType); - if (!newTexBuf[i]) - goto cleanup; - } - } - - - /* Now copy all the image data and free the old texture memory. - */ - for (i = 0; i < nr; i++) { - if (newTexBuf[i]) { - memcpy(newTexBuf[i]->bufAddr, - buffers[i]->bufAddr, - buffers[i]->size); - - newTexBuf[i]->image = buffers[i]->image; - newTexBuf[i]->image->texMem = newTexBuf[i]; - newTexBuf[i]->image->image.Data = newTexBuf[i]->bufAddr; - via_free_texture(vmesa, buffers[i]); - } - } - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s - success\n", __FUNCTION__); - - return GL_TRUE; - - cleanup: - /* Release any allocations made prior to failure: - */ - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s - failed\n", __FUNCTION__); - - for (i = 0; i < nr; i++) { - if (newTexBuf[i]) { - via_free_texture(vmesa, newTexBuf[i]); - } - } - - return GL_FALSE; -} - - -static GLboolean viaMoveTexObject( struct via_context *vmesa, - struct via_texture_object *viaObj, - GLint newMemType ) -{ - struct via_texture_image **viaImage = - (struct via_texture_image **)&viaObj->obj.Image[0][0]; - struct via_tex_buffer *buffers[VIA_MAX_TEXLEVELS]; - GLuint i, nr = 0; - - for (i = viaObj->firstLevel; i <= viaObj->lastLevel; i++) - buffers[nr++] = viaImage[i]->texMem; - - if (viaMoveTexBuffers( vmesa, &buffers[0], nr, newMemType )) { - viaObj->memType = newMemType; - return GL_TRUE; - } - - return GL_FALSE; -} - - - -static GLboolean viaSwapInTexObject( struct via_context *vmesa, - struct via_texture_object *viaObj ) -{ - const struct via_texture_image *baseImage = - (struct via_texture_image *)viaObj->obj.Image[0][viaObj->obj.BaseLevel]; - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s\n", __FUNCTION__); - - if (baseImage->texMem->memType != VIA_MEM_SYSTEM) - return viaMoveTexObject( vmesa, viaObj, baseImage->texMem->memType ); - - return (viaMoveTexObject( vmesa, viaObj, VIA_MEM_AGP ) || - viaMoveTexObject( vmesa, viaObj, VIA_MEM_VIDEO )); -} - - -/* This seems crude, but it asks a fairly pertinent question and gives - * an accurate answer: - */ -static GLboolean viaIsTexMemLow( struct via_context *vmesa, - GLuint heap ) -{ - struct via_tex_buffer *buf = via_alloc_texture(vmesa, 512 * 1024, heap ); - if (!buf) - return GL_TRUE; - - via_free_texture(vmesa, buf); - return GL_FALSE; -} - - -/* Speculatively move texture images which haven't been used in a - * while back to system memory. - * - * TODO: only do this when texture memory is low. - * - * TODO: use dma. - * - * TODO: keep the fb/agp version hanging around and use the local - * version as backing store, so re-upload might be avoided. - * - * TODO: do this properly in the kernel... - */ -GLboolean viaSwapOutWork( struct via_context *vmesa ) -{ - struct via_tex_buffer *s, *tmp; - GLuint done = 0; - GLuint heap, target; - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s VID %d AGP %d SYS %d\n", __FUNCTION__, - vmesa->total_alloc[VIA_MEM_VIDEO], - vmesa->total_alloc[VIA_MEM_AGP], - vmesa->total_alloc[VIA_MEM_SYSTEM]); - - - for (heap = VIA_MEM_VIDEO; heap <= VIA_MEM_AGP; heap++) { - GLuint nr = 0, sz = 0; - - if (vmesa->thrashing) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "Heap %d: trash flag\n", heap); - target = 1*1024*1024; - } - else if (viaIsTexMemLow(vmesa, heap)) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "Heap %d: low memory\n", heap); - target = 64*1024; - } - else { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "Heap %d: nothing to do\n", heap); - continue; - } - - foreach_s( s, tmp, &vmesa->tex_image_list[heap] ) { - if (s->lastUsed < vmesa->lastSwap[1]) { - struct via_texture_object *viaObj = - (struct via_texture_object *) s->image->image.TexObject; - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, - "back copy tex sz %d, lastUsed %d lastSwap %d\n", - s->size, s->lastUsed, vmesa->lastSwap[1]); - - if (viaMoveTexBuffers( vmesa, &s, 1, VIA_MEM_SYSTEM )) { - viaObj->memType = VIA_MEM_MIXED; - done += s->size; - } - else { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "Failed to back copy texture!\n"); - sz += s->size; - } - } - else { - nr ++; - sz += s->size; - } - - if (done > target) { - vmesa->thrashing = GL_FALSE; /* might not get set otherwise? */ - return GL_TRUE; - } - } - - assert(sz == vmesa->total_alloc[heap]); - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "Heap %d: nr %d tot sz %d\n", heap, nr, sz); - } - - - return done != 0; -} - - - -/* Basically, just collect the image dimensions and addresses for each - * image and update the texture object state accordingly. - */ -static GLboolean viaSetTexImages(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - struct via_texture_object *viaObj = (struct via_texture_object *)texObj; - const struct via_texture_image *baseImage = - (struct via_texture_image *)texObj->Image[0][texObj->BaseLevel]; - GLint firstLevel, lastLevel, numLevels; - GLuint texFormat; - GLint w, h, p; - GLint i, j = 0, k = 0, l = 0, m = 0; - GLuint texBase; - GLuint basH = 0; - GLuint widthExp = 0; - GLuint heightExp = 0; - - switch (baseImage->image.TexFormat) { - case MESA_FORMAT_ARGB8888: - texFormat = HC_HTXnFM_ARGB8888; - break; - case MESA_FORMAT_ARGB4444: - texFormat = HC_HTXnFM_ARGB4444; - break; - case MESA_FORMAT_RGB565: - texFormat = HC_HTXnFM_RGB565; - break; - case MESA_FORMAT_ARGB1555: - texFormat = HC_HTXnFM_ARGB1555; - break; - case MESA_FORMAT_RGB888: - texFormat = HC_HTXnFM_ARGB0888; - break; - case MESA_FORMAT_L8: - texFormat = HC_HTXnFM_L8; - break; - case MESA_FORMAT_I8: - texFormat = HC_HTXnFM_T8; - break; - case MESA_FORMAT_CI8: - texFormat = HC_HTXnFM_Index8; - break; - case MESA_FORMAT_AL88: - texFormat = HC_HTXnFM_AL88; - break; - case MESA_FORMAT_A8: - texFormat = HC_HTXnFM_A8; - break; - default: - _mesa_problem(vmesa->glCtx, "Bad texture format in viaSetTexImages"); - return GL_FALSE; - } - - /* 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 (texObj->Sampler.MinFilter == GL_LINEAR || texObj->Sampler.MinFilter == GL_NEAREST) { - firstLevel = lastLevel = texObj->BaseLevel; - } - else { - firstLevel = texObj->BaseLevel + (GLint)(texObj->Sampler.MinLod + 0.5); - firstLevel = MAX2(firstLevel, texObj->BaseLevel); - lastLevel = texObj->BaseLevel + (GLint)(texObj->Sampler.MaxLod + 0.5); - lastLevel = MAX2(lastLevel, texObj->BaseLevel); - lastLevel = MIN2(lastLevel, texObj->BaseLevel + baseImage->image.MaxLog2); - lastLevel = MIN2(lastLevel, texObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ - } - - numLevels = lastLevel - firstLevel + 1; - - /* The hardware supports only 10 mipmap levels; ignore higher levels. - */ - if ((numLevels > 10) && (ctx->Const.MaxTextureLevels > 10)) { - lastLevel -= numLevels - 10; - numLevels = 10; - } - - /* save these values, check if they effect the residency of the - * texture: - */ - if (viaObj->firstLevel != firstLevel || - viaObj->lastLevel != lastLevel) { - viaObj->firstLevel = firstLevel; - viaObj->lastLevel = lastLevel; - viaObj->memType = VIA_MEM_MIXED; - } - - if (VIA_DEBUG & DEBUG_TEXTURE & 0) - fprintf(stderr, "%s, current memType: %s\n", - __FUNCTION__, - get_memtype_name(viaObj->memType)); - - - if (viaObj->memType == VIA_MEM_MIXED || - viaObj->memType == VIA_MEM_SYSTEM) { - if (!viaSwapInTexObject(vmesa, viaObj)) { - if (VIA_DEBUG & DEBUG_TEXTURE) - if (!vmesa->thrashing) - fprintf(stderr, "Thrashing flag set for frame %d\n", - vmesa->swap_count); - vmesa->thrashing = GL_TRUE; - return GL_FALSE; - } - } - - if (viaObj->memType == VIA_MEM_AGP) - viaObj->regTexFM = (HC_SubA_HTXnFM << 24) | HC_HTXnLoc_AGP | texFormat; - else - viaObj->regTexFM = (HC_SubA_HTXnFM << 24) | HC_HTXnLoc_Local | texFormat; - - - for (i = 0; i < numLevels; i++) { - struct via_texture_image *viaImage = - (struct via_texture_image *)texObj->Image[0][firstLevel + i]; - - w = viaImage->image.WidthLog2; - h = viaImage->image.HeightLog2; - p = viaImage->pitchLog2; - - assert(viaImage->texMem->memType == viaObj->memType); - - texBase = viaImage->texMem->texBase; - if (!texBase) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s: no texBase[%d]\n", __FUNCTION__, i); - return GL_FALSE; - } - - /* Image has to remain resident until the coming fence is retired. - */ - move_to_head( &vmesa->tex_image_list[viaImage->texMem->memType], - viaImage->texMem ); - viaImage->texMem->lastUsed = vmesa->lastBreadcrumbWrite; - - - viaObj->regTexBaseAndPitch[i].baseL = - ((HC_SubA_HTXnL0BasL + i) << 24) | (texBase & 0xFFFFFF); - - viaObj->regTexBaseAndPitch[i].pitchLog2 = - ((HC_SubA_HTXnL0Pit + i) << 24) | (p << 20); - - - /* The base high bytes for each 3 levels are packed - * together into one register: - */ - j = i / 3; - k = 3 - (i % 3); - basH |= ((texBase & 0xFF000000) >> (k << 3)); - if (k == 1) { - viaObj->regTexBaseH[j] = ((j + HC_SubA_HTXnL012BasH) << 24) | basH; - basH = 0; - } - - /* Likewise, sets of 6 log2width and log2height values are - * packed into individual registers: - */ - l = i / 6; - m = i % 6; - widthExp |= (((GLuint)w & 0xF) << (m << 2)); - heightExp |= (((GLuint)h & 0xF) << (m << 2)); - if (m == 5) { - viaObj->regTexWidthLog2[l] = - (l + HC_SubA_HTXnL0_5WE) << 24 | widthExp; - viaObj->regTexHeightLog2[l] = - (l + HC_SubA_HTXnL0_5HE) << 24 | heightExp; - widthExp = 0; - heightExp = 0; - } - if (w) w--; - if (h) h--; - if (p) p--; - } - - if (k != 1) { - viaObj->regTexBaseH[j] = ((j + HC_SubA_HTXnL012BasH) << 24) | basH; - } - if (m != 5) { - viaObj->regTexWidthLog2[l] = (l + HC_SubA_HTXnL0_5WE) << 24 | widthExp; - viaObj->regTexHeightLog2[l] = (l + HC_SubA_HTXnL0_5HE) << 24 | heightExp; - } - - return GL_TRUE; -} - - -GLboolean viaUpdateTextureState( struct gl_context *ctx ) -{ - struct gl_texture_unit *texUnit = ctx->Texture.Unit; - GLuint i; - - for (i = 0; i < 2; i++) { - if (texUnit[i]._ReallyEnabled == TEXTURE_2D_BIT || - texUnit[i]._ReallyEnabled == TEXTURE_1D_BIT) { - - if (!viaSetTexImages(ctx, texUnit[i]._Current)) - return GL_FALSE; - } - else if (texUnit[i]._ReallyEnabled) { - return GL_FALSE; - } - } - - return GL_TRUE; -} - - - - - - - - -static void viaTexImage(struct gl_context *ctx, - GLint dims, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLint postConvWidth = width; - GLint postConvHeight = height; - GLint texelBytes, sizeInBytes; - struct via_texture_object *viaObj = (struct via_texture_object *)texObj; - struct via_texture_image *viaImage = (struct via_texture_image *)texImage; - int heaps[3], nheaps, i; - - if (!is_empty_list(&vmesa->freed_tex_buffers)) { - viaCheckBreadcrumb(vmesa, 0); - via_release_pending_textures(vmesa); - } - - /* choose the texture format */ - texImage->TexFormat = viaChooseTexFormat(ctx, internalFormat, - format, type); - - assert(texImage->TexFormat); - - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); - - /* Minimum pitch of 32 bytes */ - if (postConvWidth * texelBytes < 32) { - postConvWidth = 32 / texelBytes; - texImage->RowStride = postConvWidth; - } - - assert(texImage->RowStride == postConvWidth); - viaImage->pitchLog2 = _mesa_logbase2(postConvWidth * texelBytes); - - /* allocate memory */ - if (_mesa_is_format_compressed(texImage->TexFormat)) - sizeInBytes = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth); - else - sizeInBytes = postConvWidth * postConvHeight * texelBytes; - - - /* Attempt to allocate texture memory directly, otherwise use main - * memory and this texture will always be a fallback. FIXME! - * - * TODO: make room in agp if this fails. - * TODO: use fb ram for textures as well. - */ - - - switch (viaObj->memType) { - case VIA_MEM_UNKNOWN: - heaps[0] = VIA_MEM_AGP; - heaps[1] = VIA_MEM_VIDEO; - heaps[2] = VIA_MEM_SYSTEM; - nheaps = 3; - break; - case VIA_MEM_AGP: - case VIA_MEM_VIDEO: - heaps[0] = viaObj->memType; - heaps[1] = VIA_MEM_SYSTEM; - nheaps = 2; - break; - case VIA_MEM_MIXED: - case VIA_MEM_SYSTEM: - default: - heaps[0] = VIA_MEM_SYSTEM; - nheaps = 1; - break; - } - - for (i = 0; i < nheaps && !viaImage->texMem; i++) { - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "try %s (obj %s)\n", get_memtype_name(heaps[i]), - get_memtype_name(viaObj->memType)); - viaImage->texMem = via_alloc_texture(vmesa, sizeInBytes, heaps[i]); - } - - if (!viaImage->texMem) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - return; - } - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "upload %d bytes to %s\n", sizeInBytes, - get_memtype_name(viaImage->texMem->memType)); - - viaImage->texMem->image = viaImage; - texImage->Data = viaImage->texMem->bufAddr; - - if (viaObj->memType == VIA_MEM_UNKNOWN) - viaObj->memType = viaImage->texMem->memType; - else if (viaObj->memType != viaImage->texMem->memType) - viaObj->memType = VIA_MEM_MIXED; - - if (VIA_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "%s, obj %s, image : %s\n", - __FUNCTION__, - get_memtype_name(viaObj->memType), - get_memtype_name(viaImage->texMem->memType)); - - vmesa->clearTexCache = 1; - - pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1, - format, type, - pixels, packing, "glTexImage"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - GLint dstRowStride; - GLboolean success; - - if (_mesa_is_format_compressed(texImage->TexFormat)) { - dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width); - } - else { - dstRowStride = postConvWidth * _mesa_get_format_bytes(texImage->TexFormat); - } - success = _mesa_texstore(ctx, dims, - texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - -static void viaTexImage2D(struct gl_context *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - viaTexImage( ctx, 2, target, level, - internalFormat, width, height, border, - format, type, pixels, - packing, texObj, texImage ); -} - -static void viaTexSubImage2D(struct gl_context *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) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - viaWaitIdle(vmesa, GL_TRUE); - vmesa->clearTexCache = 1; - - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); -} - -static void viaTexImage1D(struct gl_context *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - viaTexImage( ctx, 1, target, level, - internalFormat, width, 1, border, - format, type, pixels, - packing, texObj, texImage ); -} - -static void viaTexSubImage1D(struct gl_context *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) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - viaWaitIdle(vmesa, GL_TRUE); - vmesa->clearTexCache = 1; - - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, packing, texObj, - texImage); -} - - - -static GLboolean viaIsTextureResident(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - struct via_texture_object *viaObj = - (struct via_texture_object *)texObj; - - return (viaObj->memType == VIA_MEM_AGP || - viaObj->memType == VIA_MEM_VIDEO); -} - - - -static struct gl_texture_image *viaNewTextureImage( struct gl_context *ctx ) -{ - (void) ctx; - return (struct gl_texture_image *)CALLOC_STRUCT(via_texture_image); -} - - -static struct gl_texture_object *viaNewTextureObject( struct gl_context *ctx, - GLuint name, - GLenum target ) -{ - struct via_texture_object *obj = CALLOC_STRUCT(via_texture_object); - - _mesa_initialize_texture_object(&obj->obj, name, target); - (void) ctx; - - obj->memType = VIA_MEM_UNKNOWN; - - return &obj->obj; -} - - -static void viaFreeTextureImageData( struct gl_context *ctx, - struct gl_texture_image *texImage ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - struct via_texture_image *image = (struct via_texture_image *)texImage; - - if (image->texMem) { - via_free_texture(vmesa, image->texMem); - image->texMem = NULL; - } - - texImage->Data = NULL; -} - - - - -void viaInitTextureFuncs(struct dd_function_table * functions) -{ - functions->ChooseTextureFormat = viaChooseTexFormat; - functions->TexImage1D = viaTexImage1D; - functions->TexImage2D = viaTexImage2D; - functions->TexSubImage1D = viaTexSubImage1D; - functions->TexSubImage2D = viaTexSubImage2D; - - functions->NewTextureObject = viaNewTextureObject; - functions->NewTextureImage = viaNewTextureImage; - functions->DeleteTexture = _mesa_delete_texture_object; - functions->FreeTexImageData = viaFreeTextureImageData; - -#if 0 && defined( USE_SSE_ASM ) - /* - * XXX this code is disabled for now because the via_sse_memcpy() - * routine causes segfaults with flightgear. - * See Mesa3d-dev mail list messages from 7/15/2005 for details. - * Note that this function is currently disabled in via_tris.c too. - */ - if (getenv("VIA_NO_SSE")) - functions->TextureMemCpy = memcpy; - else - functions->TextureMemCpy = via_sse_memcpy; -#else - functions->TextureMemCpy = memcpy; -#endif - - functions->IsTextureResident = viaIsTextureResident; -} - - diff --git a/src/mesa/drivers/dri/unichrome/via_tex.h b/src/mesa/drivers/dri/unichrome/via_tex.h deleted file mode 100644 index 9495c956b5a..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_tex.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _VIATEX_H -#define _VIATEX_H - -#include "main/mtypes.h" - -struct via_context; - -GLboolean viaUpdateTextureState(struct gl_context *ctx); -void viaInitTextureFuncs(struct dd_function_table * functions); -GLboolean viaSwapOutWork( struct via_context *vmesa ); - -#if defined( USE_SSE_ASM ) -void via_sse_memcpy( void *to, const void *from, size_t sz ); -#endif /* defined( USE_SSE_ASM ) */ - -#endif diff --git a/src/mesa/drivers/dri/unichrome/via_texcombine.c b/src/mesa/drivers/dri/unichrome/via_texcombine.c deleted file mode 100644 index f87ba071f3b..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_texcombine.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to 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 - * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file via_texcombine.c - * Calculate texture combine hardware state. - * - * \author Ian Romanick <[email protected]> - */ - -#include <stdio.h> - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/colormac.h" -#include "main/enums.h" - -#include "via_context.h" -#include "via_tex.h" -#include "via_3d_reg.h" - - -#define VIA_USE_ALPHA (HC_XTC_Adif - HC_XTC_Dif) - -#define INPUT_A_SHIFT 14 -#define INPUT_B_SHIFT 7 -#define INPUT_C_SHIFT 0 -#define INPUT_CBias_SHIFT 14 - -#define CONST_ONE (HC_XTC_0 | HC_XTC_InvTOPC) - -static const unsigned color_operand_modifier[4] = { - 0, - HC_XTC_InvTOPC, - VIA_USE_ALPHA, - VIA_USE_ALPHA | HC_XTC_InvTOPC, -}; - -static const unsigned alpha_operand_modifier[2] = { - 0, HC_XTA_InvTOPA -}; - -static const unsigned bias_alpha_operand_modifier[2] = { - 0, HC_HTXnTBLAbias_Inv -}; - - -static const unsigned c_shift_table[3] = { - HC_HTXnTBLCshift_No, HC_HTXnTBLCshift_1, HC_HTXnTBLCshift_2 -}; - -static const unsigned a_shift_table[3] = { - HC_HTXnTBLAshift_No, HC_HTXnTBLAshift_1, HC_HTXnTBLAshift_2 -}; - - -/** - * Calculate the hardware state for the specified texture combine mode - * - * \bug - * All forms of DOT3 bumpmapping are completely untested, and are most - * likely wrong. KW: Looks like it will never be quite right as the - * hardware seems to experience overflow in color calculation at the - * 4x shift levels, which need to be programed for DOT3. Maybe newer - * hardware fixes these issues. - * - * \bug - * KW: needs attention to the case where texunit 1 is enabled but - * texunit 0 is not. - */ -GLboolean -viaTexCombineState( struct via_context *vmesa, - const struct gl_tex_env_combine_state * combine, - unsigned unit ) -{ - unsigned color_arg[3]; - unsigned alpha_arg[3]; - unsigned bias_alpha_arg[3]; - unsigned color = HC_HTXnTBLCsat_MASK; - unsigned alpha = HC_HTXnTBLAsat_MASK; - unsigned bias = 0; - unsigned op = 0; - unsigned a_shift = combine->ScaleShiftA; - unsigned c_shift = combine->ScaleShiftRGB; - unsigned i; - unsigned constant_color[3]; - unsigned ordered_constant_color[4]; - unsigned constant_alpha[3]; - unsigned bias_alpha = 0; - unsigned abc_alpha = 0; - const struct gl_texture_unit * texUnit = - &vmesa->glCtx->Texture.Unit[unit]; - unsigned env_color[4]; - - /* It seems that the color clamping can be overwhelmed at the 4x - * scale settings, necessitating this fallback: - */ - if (c_shift == 2 || a_shift == 2) { - return GL_FALSE; - } - - CLAMPED_FLOAT_TO_UBYTE(env_color[0], texUnit->EnvColor[0]); - CLAMPED_FLOAT_TO_UBYTE(env_color[1], texUnit->EnvColor[1]); - CLAMPED_FLOAT_TO_UBYTE(env_color[2], texUnit->EnvColor[2]); - CLAMPED_FLOAT_TO_UBYTE(env_color[3], texUnit->EnvColor[3]); - - (void) memset( constant_color, 0, sizeof( constant_color ) ); - (void) memset( ordered_constant_color, 0, sizeof( ordered_constant_color ) ); - (void) memset( constant_alpha, 0, sizeof( constant_alpha ) ); - - for ( i = 0 ; i < combine->_NumArgsRGB ; i++ ) { - const GLint op = combine->OperandRGB[i] - GL_SRC_COLOR; - - switch ( combine->SourceRGB[i] ) { - case GL_TEXTURE: - color_arg[i] = HC_XTC_Tex; - color_arg[i] += color_operand_modifier[op]; - break; - case GL_CONSTANT: - color_arg[i] = HC_XTC_HTXnTBLRC; - - switch( op ) { - case 0: /* GL_SRC_COLOR */ - constant_color[i] = ((env_color[0] << 16) | - (env_color[1] << 8) | - env_color[2]); - break; - case 1: /* GL_ONE_MINUS_SRC_COLOR */ - constant_color[i] = ~((env_color[0] << 16) | - (env_color[1] << 8) | - env_color[2]) & 0x00ffffff; - break; - case 2: /* GL_SRC_ALPHA */ - constant_color[i] = ((env_color[3] << 16) | - (env_color[3] << 8) | - env_color[3]); - break; - case 3: /* GL_ONE_MINUS_SRC_ALPHA */ - constant_color[i] = ~((env_color[3] << 16) | - (env_color[3] << 8) | - env_color[3]) & 0x00ffffff; - break; - } - break; - case GL_PRIMARY_COLOR: - color_arg[i] = HC_XTC_Dif; - color_arg[i] += color_operand_modifier[op]; - break; - case GL_PREVIOUS: - color_arg[i] = (unit == 0) ? HC_XTC_Dif : HC_XTC_Cur; - color_arg[i] += color_operand_modifier[op]; - break; - } - } - - - /* On the Unichrome, all combine operations take on some form of: - * - * (xA * (xB op xC) + xBias) << xShift - * - * 'op' can be selected as add, subtract, min, max, or mask. The min, max - * and mask modes are currently unused. With the exception of DOT3, all - * standard GL_COMBINE modes can be implemented simply by selecting the - * correct inputs for A, B, C, and Bias and the correct operation for op. - * - * NOTE: xBias (when read from the constant registers) is signed, - * and scaled to fit -255..255 in 8 bits, ie 0x1 == 2. - */ - - switch( combine->ModeRGB ) { - /* Ca = 1.0, Cb = arg0, Cc = 0, Cbias = 0 - */ - case GL_REPLACE: - color |= ((CONST_ONE << INPUT_A_SHIFT) | - (color_arg[0] << INPUT_B_SHIFT)); - - ordered_constant_color[1] = constant_color[0]; - break; - - /* Ca = arg[0], Cb = arg[1], Cc = 0, Cbias = 0 - */ - case GL_MODULATE: - color |= ((color_arg[0] << INPUT_A_SHIFT) | - (color_arg[1] << INPUT_B_SHIFT)); - - ordered_constant_color[0] = constant_color[0]; - ordered_constant_color[1] = constant_color[1]; - break; - - /* Ca = 1.0, Cb = arg[0], Cc = arg[1], Cbias = 0 - */ - case GL_ADD: - case GL_SUBTRACT: - if ( combine->ModeRGB == GL_SUBTRACT ) { - op |= HC_HTXnTBLCop_Sub; - } - - color |= ((CONST_ONE << INPUT_A_SHIFT) | - (color_arg[0] << INPUT_B_SHIFT) | - (color_arg[1] << INPUT_C_SHIFT)); - - ordered_constant_color[1] = constant_color[0]; - ordered_constant_color[2] = constant_color[1]; - break; - - /* Ca = 1.0, Cb = arg[0], Cc = arg[1], Cbias = -0.5 - */ - case GL_ADD_SIGNED: - color |= ((CONST_ONE << INPUT_A_SHIFT) | - (color_arg[0] << INPUT_B_SHIFT) | - (color_arg[1] << INPUT_C_SHIFT)); - - bias |= HC_HTXnTBLCbias_HTXnTBLRC; - - ordered_constant_color[1] = constant_color[0]; - ordered_constant_color[2] = constant_color[1]; - ordered_constant_color[3] = 0x00bfbfbf; /* -.5 */ - break; - - /* Ca = arg[2], Cb = arg[0], Cc = arg[1], Cbias = arg[1] - */ - case GL_INTERPOLATE: - op |= HC_HTXnTBLCop_Sub; - - color |= ((color_arg[2] << INPUT_A_SHIFT) | - (color_arg[0] << INPUT_B_SHIFT) | - (color_arg[1] << INPUT_C_SHIFT)); - - bias |= (color_arg[1] << INPUT_CBias_SHIFT); - - ordered_constant_color[0] = constant_color[2]; - ordered_constant_color[1] = constant_color[0]; - ordered_constant_color[2] = constant_color[1]; - ordered_constant_color[3] = (constant_color[1] >> 1) & 0x7f7f7f; - break; - -#if 0 - /* At this point this code is completely untested. It appears that the - * Unichrome has the same limitation as the Radeon R100. The only - * supported post-scale when doing DOT3 bumpmapping is 1x. - */ - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - c_shift = 2; - a_shift = 2; - color |= ((color_arg[0] << INPUT_A_SHIFT) | - (color_arg[1] << INPUT_B_SHIFT)); - op |= HC_HTXnTBLDOT4; - break; -#endif - - default: - assert(0); - break; - } - - - - - /* The alpha blend stage has the annoying quirk of not having a - * hard-wired 0 input, like the color stage. As a result, we have - * to program the constant register with 0 and use that as our - * 0 input. - * - * (xA * (xB op xC) + xBias) << xShift - * - */ - - for ( i = 0 ; i < combine->_NumArgsA ; i++ ) { - const GLint op = combine->OperandA[i] - GL_SRC_ALPHA; - - switch ( combine->SourceA[i] ) { - case GL_TEXTURE: - alpha_arg[i] = HC_XTA_Atex; - alpha_arg[i] += alpha_operand_modifier[op]; - bias_alpha_arg[i] = HC_HTXnTBLAbias_Atex; - bias_alpha_arg[i] += bias_alpha_operand_modifier[op]; - break; - case GL_CONSTANT: - alpha_arg[i] = HC_XTA_HTXnTBLRA; - bias_alpha_arg[i] = HC_HTXnTBLAbias_HTXnTBLRAbias; - constant_alpha[i] = (op == 0) ? env_color[3] : (~env_color[3] & 0xff); - break; - case GL_PRIMARY_COLOR: - alpha_arg[i] = HC_XTA_Adif; - alpha_arg[i] += alpha_operand_modifier[op]; - bias_alpha_arg[i] = HC_HTXnTBLAbias_Adif; - bias_alpha_arg[i] += bias_alpha_operand_modifier[op]; - break; - case GL_PREVIOUS: - alpha_arg[i] = (unit == 0) ? HC_XTA_Adif : HC_XTA_Acur; - alpha_arg[i] += alpha_operand_modifier[op]; - bias_alpha_arg[i] = (unit == 0 ? - HC_HTXnTBLAbias_Adif : - HC_HTXnTBLAbias_Acur); - bias_alpha_arg[i] += bias_alpha_operand_modifier[op]; - break; - } - } - - switch( combine->ModeA ) { - /* Aa = 0, Ab = 0, Ac = 0, Abias = arg0 - */ - case GL_REPLACE: - alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | - (HC_XTA_HTXnTBLRA << INPUT_B_SHIFT) | - (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT)); - abc_alpha = 0; - - bias |= bias_alpha_arg[0]; - bias_alpha = constant_alpha[0] >> 1; - break; - - /* Aa = arg[0], Ab = arg[1], Ac = 0, Abias = 0 - */ - case GL_MODULATE: - alpha |= ((alpha_arg[1] << INPUT_A_SHIFT) | - (alpha_arg[0] << INPUT_B_SHIFT) | - (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT)); - - abc_alpha = ((constant_alpha[1] << HC_HTXnTBLRAa_SHIFT) | - (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | - (0 << HC_HTXnTBLRAc_SHIFT)); - - bias |= HC_HTXnTBLAbias_HTXnTBLRAbias; - bias_alpha = 0; - break; - - /* Aa = 1.0, Ab = arg[0], Ac = arg[1], Abias = 0 - */ - case GL_ADD: - case GL_SUBTRACT: - if ( combine->ModeA == GL_SUBTRACT ) { - op |= HC_HTXnTBLAop_Sub; - } - - alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | - (alpha_arg[0] << INPUT_B_SHIFT) | - (alpha_arg[1] << INPUT_C_SHIFT)); - - abc_alpha = ((0xff << HC_HTXnTBLRAa_SHIFT) | - (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | - (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT)); - - bias |= HC_HTXnTBLAbias_HTXnTBLRAbias; - bias_alpha = 0; - break; - - /* Aa = 1.0, Ab = arg[0], Ac = arg[1], Abias = -0.5 - */ - case GL_ADD_SIGNED: - alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | - (alpha_arg[0] << INPUT_B_SHIFT) | - (alpha_arg[1] << INPUT_C_SHIFT)); - abc_alpha = ((0xff << HC_HTXnTBLRAa_SHIFT) | - (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | - (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT)); - - bias |= HC_HTXnTBLAbias_HTXnTBLRAbias; - bias_alpha = 0xbf; - break; - - /* Aa = arg[2], Ab = arg[0], Ac = arg[1], Abias = arg[1] - */ - case GL_INTERPOLATE: - op |= HC_HTXnTBLAop_Sub; - - alpha |= ((alpha_arg[2] << INPUT_A_SHIFT) | - (alpha_arg[0] << INPUT_B_SHIFT) | - (alpha_arg[1] << INPUT_C_SHIFT)); - abc_alpha = ((constant_alpha[2] << HC_HTXnTBLRAa_SHIFT) | - (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | - (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT)); - - bias |= bias_alpha_arg[1]; - bias_alpha = constant_alpha[1] >> 1; - break; - } - - - op |= c_shift_table[ c_shift ] | a_shift_table[ a_shift ]; - - - vmesa->regHTXnTBLMPfog[unit] = HC_HTXnTBLMPfog_Fog; - - vmesa->regHTXnTBLCsat[unit] = color; - vmesa->regHTXnTBLAsat[unit] = alpha; - vmesa->regHTXnTBLCop[unit] = op | bias; - vmesa->regHTXnTBLRAa[unit] = abc_alpha; - vmesa->regHTXnTBLRFog[unit] = bias_alpha; - - vmesa->regHTXnTBLRCa[unit] = ordered_constant_color[0]; - vmesa->regHTXnTBLRCb[unit] = ordered_constant_color[1]; - vmesa->regHTXnTBLRCc[unit] = ordered_constant_color[2]; - vmesa->regHTXnTBLRCbias[unit] = ordered_constant_color[3]; - - return GL_TRUE; -} - diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c deleted file mode 100644 index 51f6af9228a..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_tris.c +++ /dev/null @@ -1,1194 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <stdio.h> -#include <math.h> - -#include "main/glheader.h" -#include "main/context.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" -#include "main/enums.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "via_context.h" -#include "via_tris.h" -#include "via_state.h" -#include "via_span.h" -#include "via_ioctl.h" -#include "via_3d_reg.h" -#include "via_tex.h" - -/*********************************************************************** - * Emit primitives as inline vertices * - ***********************************************************************/ -#define LINE_FALLBACK (0) -#define POINT_FALLBACK (0) -#define TRI_FALLBACK (0) -#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK) -#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) - - -#if 0 -#define COPY_DWORDS(vb, vertsize, v) \ -do { \ - via_sse_memcpy(vb, v, vertsize * 4); \ - vb += vertsize; \ -} while (0) -#else -#if defined( USE_X86_ASM ) -#define COPY_DWORDS(vb, vertsize, v) \ - do { \ - int j; \ - 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(vb, vertsize, v) \ - do { \ - int j; \ - for (j = 0; j < vertsize; j++) \ - vb[j] = ((GLuint *)v)[j]; \ - vb += vertsize; \ - } while (0) -#endif -#endif - -static void via_draw_triangle(struct via_context *vmesa, - viaVertexPtr v0, - viaVertexPtr v1, - viaVertexPtr v2) -{ - GLuint vertsize = vmesa->vertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize); - - COPY_DWORDS(vb, vertsize, v0); - COPY_DWORDS(vb, vertsize, v1); - COPY_DWORDS(vb, vertsize, v2); -} - - -static void via_draw_quad(struct via_context *vmesa, - viaVertexPtr v0, - viaVertexPtr v1, - viaVertexPtr v2, - viaVertexPtr v3) -{ - GLuint vertsize = vmesa->vertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize); - - COPY_DWORDS(vb, vertsize, v0); - COPY_DWORDS(vb, vertsize, v1); - COPY_DWORDS(vb, vertsize, v3); - COPY_DWORDS(vb, vertsize, v1); - COPY_DWORDS(vb, vertsize, v2); - COPY_DWORDS(vb, vertsize, v3); -} - -static void via_draw_line(struct via_context *vmesa, - viaVertexPtr v0, - viaVertexPtr v1) -{ - GLuint vertsize = vmesa->vertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize); - COPY_DWORDS(vb, vertsize, v0); - COPY_DWORDS(vb, vertsize, v1); -} - - -static void via_draw_point(struct via_context *vmesa, - viaVertexPtr v0) -{ - GLuint vertsize = vmesa->vertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize); - COPY_DWORDS(vb, vertsize, v0); -} - - -/* Fallback drawing functions for the ptex hack. - */ -#define PTEX_VERTEX( tmp, vertex_size, v) \ -do { \ - GLuint j; \ - GLfloat rhw = 1.0 / v->f[vertex_size]; \ - for ( j = 0 ; j < vertex_size ; j++ ) \ - tmp.f[j] = v->f[j]; \ - tmp.f[3] *= v->f[vertex_size]; \ - tmp.f[vertex_size-2] *= rhw; \ - tmp.f[vertex_size-1] *= rhw; \ -} while (0) - -static void via_ptex_tri (struct via_context *vmesa, - viaVertexPtr v0, - viaVertexPtr v1, - viaVertexPtr v2) -{ - GLuint vertsize = vmesa->hwVertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 3*4*vertsize); - viaVertex tmp; - - PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp); - PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp); - PTEX_VERTEX(tmp, vertsize, v2); COPY_DWORDS(vb, vertsize, &tmp); -} - -static void via_ptex_line (struct via_context *vmesa, - viaVertexPtr v0, - viaVertexPtr v1) -{ - GLuint vertsize = vmesa->hwVertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 2*4*vertsize); - viaVertex tmp; - - PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp); - PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp); -} - -static void via_ptex_point (struct via_context *vmesa, - viaVertexPtr v0) -{ - GLuint vertsize = vmesa->hwVertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, 1*4*vertsize); - viaVertex tmp; - - PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp); -} - - - - - -/*********************************************************************** - * Macros for via_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI(a, b, c) \ - do { \ - if (DO_FALLBACK) \ - vmesa->drawTri(vmesa, a, b, c); \ - else \ - via_draw_triangle(vmesa, a, b, c); \ - } while (0) - -#define QUAD(a, b, c, d) \ - do { \ - if (DO_FALLBACK) { \ - vmesa->drawTri(vmesa, a, b, d); \ - vmesa->drawTri(vmesa, b, c, d); \ - } \ - else \ - via_draw_quad(vmesa, a, b, c, d); \ - } while (0) - -#define LINE(v0, v1) \ - do { \ - if (DO_FALLBACK) \ - vmesa->drawLine(vmesa, v0, v1); \ - else \ - via_draw_line(vmesa, v0, v1); \ - } while (0) - -#define POINT(v0) \ - do { \ - if (DO_FALLBACK) \ - vmesa->drawPoint(vmesa, v0); \ - else \ - via_draw_point(vmesa, v0); \ - } while (0) - - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define VIA_OFFSET_BIT 0x01 -#define VIA_TWOSIDE_BIT 0x02 -#define VIA_UNFILLED_BIT 0x04 -#define VIA_FALLBACK_BIT 0x08 -#define VIA_MAX_TRIFUNC 0x10 - - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[VIA_MAX_TRIFUNC + 1]; - - -#define DO_FALLBACK (IND & VIA_FALLBACK_BIT) -#define DO_OFFSET (IND & VIA_OFFSET_BIT) -#define DO_UNFILLED (IND & VIA_UNFILLED_BIT) -#define DO_TWOSIDE (IND & VIA_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_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX viaVertex -#define TAB rast_tab - -/* Only used to pull back colors into vertices (ie, we know color is - * floating point). - */ -#define VIA_COLOR(dst, src) \ - do { \ - dst[0] = src[2]; \ - dst[1] = src[1]; \ - dst[2] = src[0]; \ - dst[3] = src[3]; \ - } while (0) - -#define VIA_SPEC(dst, src) \ - do { \ - dst[0] = src[2]; \ - dst[1] = src[1]; \ - dst[2] = src[0]; \ - } while (0) - - -#define DEPTH_SCALE vmesa->polygon_offset_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) (vmesa->verts + (e * vmesa->vertexSize * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - via_color_t *color = (via_color_t *)&((v)->ui[coloroffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] - -#define VERT_SET_SPEC( v, c ) \ -do { \ - if (specoffset) { \ - via_color_t *color = (via_color_t *)&((v)->ui[specoffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - } \ -} while (0) -#define VERT_COPY_SPEC( v0, v1 ) \ -do { \ - if (specoffset) { \ - v0->ub4[specoffset][0] = v1->ub4[specoffset][0]; \ - v0->ub4[specoffset][1] = v1->ub4[specoffset][1]; \ - v0->ub4[specoffset][2] = v1->ub4[specoffset][2]; \ - } \ -} while (0) - - -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] -#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset] -#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx] - - -#define LOCAL_VARS(n) \ - struct via_context *vmesa = VIA_CONTEXT(ctx); \ - GLuint color[n] = { 0 }; \ - GLuint spec[n] = { 0 }; \ - GLuint coloroffset = vmesa->coloroffset; \ - GLuint specoffset = vmesa->specoffset; \ - (void)color; (void)spec; (void)coloroffset; (void)specoffset; - - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -static const GLenum hwPrim[GL_POLYGON + 2] = { - GL_POINTS, - GL_LINES, - GL_LINES, - GL_LINES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_POLYGON+1 -}; - - -#define RASTERIZE(x) viaRasterPrimitive( ctx, x, hwPrim[x] ) -#define RENDER_PRIMITIVE vmesa->renderPrimitive -#define TAG(x) x -#define IND VIA_FALLBACK_BIT -#include "tnl_dd/t_dd_unfilled.h" -#undef IND -#undef RASTERIZE - -/*********************************************************************** - * Generate GL render functions * - ***********************************************************************/ -#define RASTERIZE(x) - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_OFFSET_BIT|VIA_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_OFFSET_BIT|VIA_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_UNFILLED_BIT|VIA_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_OFFSET_BIT|VIA_UNFILLED_BIT|VIA_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_UNFILLED_BIT|VIA_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_UNFILLED_BIT| \ - VIA_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - - -/* Catchall case for flat, separate specular triangles (via has flat - * diffuse shading, but always does specular color with gouraud). - */ -#undef DO_FALLBACK -#undef DO_OFFSET -#undef DO_UNFILLED -#undef DO_TWOSIDE -#undef DO_FLAT -#define DO_FALLBACK (0) -#define DO_OFFSET (ctx->_TriangleCaps & DD_TRI_OFFSET) -#define DO_UNFILLED (ctx->_TriangleCaps & DD_TRI_UNFILLED) -#define DO_TWOSIDE (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) -#define DO_FLAT 1 -#define TAG(x) x##_flat_specular -#define IND VIA_MAX_TRIFUNC -#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_specular(); /* special! */ -} - - -/*********************************************************************** - * 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 -via_fallback_tri(struct via_context *vmesa, - viaVertex *v0, - viaVertex *v1, - viaVertex *v2) -{ - struct gl_context *ctx = vmesa->glCtx; - SWvertex v[3]; - _swsetup_Translate(ctx, v0, &v[0]); - _swsetup_Translate(ctx, v1, &v[1]); - _swsetup_Translate(ctx, v2, &v[2]); - viaSpanRenderStart( ctx ); - _swrast_Triangle(ctx, &v[0], &v[1], &v[2]); - viaSpanRenderFinish( ctx ); -} - - -static void -via_fallback_line(struct via_context *vmesa, - viaVertex *v0, - viaVertex *v1) -{ - struct gl_context *ctx = vmesa->glCtx; - SWvertex v[2]; - _swsetup_Translate(ctx, v0, &v[0]); - _swsetup_Translate(ctx, v1, &v[1]); - viaSpanRenderStart( ctx ); - _swrast_Line(ctx, &v[0], &v[1]); - viaSpanRenderFinish( ctx ); -} - - -static void -via_fallback_point(struct via_context *vmesa, - viaVertex *v0) -{ - struct gl_context *ctx = vmesa->glCtx; - SWvertex v[1]; - _swsetup_Translate(ctx, v0, &v[0]); - viaSpanRenderStart( ctx ); - _swrast_Point(ctx, &v[0]); - viaSpanRenderFinish( ctx ); -} - -static void viaResetLineStipple( struct gl_context *ctx ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - vmesa->regCmdB |= HC_HLPrst_MASK; -} - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ -#define IND 0 -#define V(x) (viaVertex *)(vertptr + ((x) * vertsize * sizeof(int))) -#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) viaRasterPrimitive(ctx, x, hwPrim[x]) -#undef LOCAL_VARS -#define LOCAL_VARS \ - struct via_context *vmesa = VIA_CONTEXT(ctx); \ - GLubyte *vertptr = (GLubyte *)vmesa->verts; \ - const GLuint vertsize = vmesa->vertexSize; \ - const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) elt; (void) stipple; -#define RESET_STIPPLE if ( stipple ) viaResetLineStipple( ctx ); -#define RESET_OCCLUSION -#define PRESERVE_VB_DEFS -#define ELT(x) x -#define TAG(x) via_##x##_verts -#include "tnl/t_vb_rendertmp.h" -#undef ELT -#undef TAG -#define TAG(x) via_##x##_elts -#define ELT(x) elt[x] -#include "tnl/t_vb_rendertmp.h" -#undef ELT -#undef TAG -#undef NEED_EDGEFLAG_SETUP -#undef EDGEFLAG_GET -#undef EDGEFLAG_SET -#undef RESET_OCCLUSION - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - - - -static void viaRenderClippedPoly(struct gl_context *ctx, const GLuint *elts, - GLuint n) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLuint prim = VIA_CONTEXT(ctx)->renderPrimitive; - - /* 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 && - prim != GL_POLYGON + 1) - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); -} - -static void viaRenderClippedLine(struct gl_context *ctx, GLuint ii, GLuint jj) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line(ctx, ii, jj); -} - -static void viaFastRenderClippedPoly(struct gl_context *ctx, const GLuint *elts, - GLuint n) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLuint vertsize = vmesa->vertexSize; - GLuint *vb = viaExtendPrimitive(vmesa, (n - 2) * 3 * 4 * vertsize); - GLubyte *vertptr = (GLubyte *)vmesa->verts; - const GLuint *start = (const GLuint *)V(elts[0]); - int i; - - for (i = 2; i < n; i++) { - COPY_DWORDS(vb, vertsize, V(elts[i - 1])); - COPY_DWORDS(vb, vertsize, V(elts[i])); - COPY_DWORDS(vb, vertsize, start); - } -} - - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - -#define _VIA_NEW_VERTEX (_NEW_TEXTURE | \ - _DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _NEW_FOG) - -#define _VIA_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) - - -static void viaChooseRenderState(struct gl_context *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (vmesa->ptexHack) { - vmesa->drawPoint = via_ptex_point; - vmesa->drawLine = via_ptex_line; - vmesa->drawTri = via_ptex_tri; - index |= VIA_FALLBACK_BIT; - } - else { - vmesa->drawPoint = via_draw_point; - vmesa->drawLine = via_draw_line; - vmesa->drawTri = via_draw_triangle; - } - - if (flags & (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)) { - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - index |= VIA_TWOSIDE_BIT; - if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) - index |= VIA_UNFILLED_BIT; - if (flags & DD_TRI_OFFSET) - index |= VIA_OFFSET_BIT; - if (flags & ANY_FALLBACK_FLAGS) - index |= VIA_FALLBACK_BIT; - - /* Hook in fallbacks for specific primitives. */ - if (flags & POINT_FALLBACK) - vmesa->drawPoint = via_fallback_point; - - if (flags & LINE_FALLBACK) - vmesa->drawLine = via_fallback_line; - - if (flags & TRI_FALLBACK) - vmesa->drawTri = via_fallback_tri; - } - - if ((flags & DD_SEPARATE_SPECULAR) && ctx->Light.ShadeModel == GL_FLAT) - index = VIA_MAX_TRIFUNC; /* flat specular */ - - if (vmesa->renderIndex != index) { - vmesa->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 = via_render_tab_verts; - tnl->Driver.Render.PrimTabElts = via_render_tab_elts; - tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */ - tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly; - } - else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = viaRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly; - } - } -} - - -#define VIA_EMIT_TEX1 0x01 -#define VIA_EMIT_TEX0 0x02 -#define VIA_EMIT_PTEX0 0x04 -#define VIA_EMIT_RGBA 0x08 -#define VIA_EMIT_SPEC 0x10 -#define VIA_EMIT_FOG 0x20 -#define VIA_EMIT_W 0x40 - -#define EMIT_ATTR( ATTR, STYLE, INDEX, REGB ) \ -do { \ - vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = (ATTR); \ - vmesa->vertex_attrs[vmesa->vertex_attr_count].format = (STYLE); \ - vmesa->vertex_attr_count++; \ - setupIndex |= (INDEX); \ - regCmdB |= (REGB); \ -} while (0) - -#define EMIT_PAD( N ) \ -do { \ - vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = 0; \ - vmesa->vertex_attrs[vmesa->vertex_attr_count].format = EMIT_PAD; \ - vmesa->vertex_attrs[vmesa->vertex_attr_count].offset = (N); \ - vmesa->vertex_attr_count++; \ -} while (0) - - - -static void viaChooseVertexState( struct gl_context *ctx ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - DECLARE_RENDERINPUTS(index_bitset); - GLuint regCmdB = HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z; - GLuint setupIndex = 0; - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - vmesa->vertex_attr_count = 0; - - /* EMIT_ATTR's must be in order as they tell t_vertex.c how to - * build up a hardware vertex. - */ - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX ) || - RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VIA_EMIT_W, HC_HVPMSK_W ); - vmesa->coloroffset = 4; - } - else { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 ); - vmesa->coloroffset = 3; - } - - /* t_context.c always includes a diffuse color */ - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VIA_EMIT_RGBA, - HC_HVPMSK_Cd ); - - vmesa->specoffset = 0; - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || - RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { - vmesa->specoffset = vmesa->coloroffset + 1; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VIA_EMIT_SPEC, - HC_HVPMSK_Cs ); - } - else - EMIT_PAD( 3 ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VIA_EMIT_FOG, HC_HVPMSK_Cs ); - else - EMIT_PAD( 1 ); - } - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 )) { - if (vmesa->ptexHack) - EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, VIA_EMIT_PTEX0, - (HC_HVPMSK_S | HC_HVPMSK_T) ); - else - EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, VIA_EMIT_TEX0, - (HC_HVPMSK_S | HC_HVPMSK_T) ); - } - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 )) { - EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, VIA_EMIT_TEX1, - (HC_HVPMSK_S | HC_HVPMSK_T) ); - } - - if (setupIndex != vmesa->setupIndex) { - vmesa->vertexSize = _tnl_install_attrs( ctx, - vmesa->vertex_attrs, - vmesa->vertex_attr_count, - vmesa->ViewportMatrix.m, 0 ); - vmesa->vertexSize >>= 2; - vmesa->setupIndex = setupIndex; - vmesa->regCmdB &= ~HC_HVPMSK_MASK; - vmesa->regCmdB |= regCmdB; - - if (vmesa->ptexHack) - vmesa->hwVertexSize = vmesa->vertexSize - 1; - else - vmesa->hwVertexSize = vmesa->vertexSize; - } -} - - - - -/* Check if projective texture coordinates are used and if we can fake - * them. Fallback to swrast if we can't. Returns GL_TRUE if projective - * texture coordinates must be faked, GL_FALSE otherwise. - */ -static GLboolean viaCheckPTexHack( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - GLboolean fallback = GL_FALSE; - GLboolean ptexHack = GL_FALSE; - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) { - if (!RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_ATTRIB_TEX1, _TNL_LAST_TEX )) - ptexHack = GL_TRUE; - else - fallback = GL_TRUE; - } - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4) - fallback = GL_TRUE; - - FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_PROJ_TEXTURE, fallback); - return ptexHack; -} - - - - -/**********************************************************************/ -/* High level hooks for t_vb_render.c */ -/**********************************************************************/ - - -static void viaRenderStart(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - { - GLboolean ptexHack = viaCheckPTexHack( ctx ); - if (ptexHack != vmesa->ptexHack) { - vmesa->ptexHack = ptexHack; - vmesa->newRenderState |= _VIA_NEW_RENDERSTATE; - } - } - - if (vmesa->newState) { - vmesa->newRenderState |= vmesa->newState; - viaValidateState( ctx ); - } - - if (vmesa->Fallback) { - tnl->Driver.Render.Start(ctx); - return; - } - - if (vmesa->newRenderState) { - viaChooseVertexState(ctx); - viaChooseRenderState(ctx); - vmesa->newRenderState = 0; - } - - /* Important: - */ - VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; -} - -static void viaRenderFinish(struct gl_context *ctx) -{ - VIA_FINISH_PRIM(VIA_CONTEXT(ctx)); -} - - -/* System to flush dma and emit state changes based on the rasterized - * primitive. - */ -void viaRasterPrimitive(struct gl_context *ctx, - GLenum glprim, - GLenum hwprim) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - GLuint regCmdB; - RING_VARS; - - if (VIA_DEBUG & DEBUG_PRIMS) - fprintf(stderr, "%s: %s/%s/%s\n", - __FUNCTION__, _mesa_lookup_enum_by_nr(glprim), - _mesa_lookup_enum_by_nr(hwprim), - _mesa_lookup_enum_by_nr(ctx->Light.ShadeModel)); - - assert (!vmesa->newState); - - vmesa->renderPrimitive = glprim; - - if (hwprim != vmesa->hwPrimitive || - ctx->Light.ShadeModel != vmesa->hwShadeModel) { - - VIA_FINISH_PRIM(vmesa); - - /* Ensure no wrapping inside this function */ - viaCheckDma( vmesa, 1024 ); - - if (vmesa->newEmitState) { - viaEmitState(vmesa); - } - - vmesa->regCmdA_End = HC_ACMD_HCmdA; - - if (ctx->Light.ShadeModel == GL_SMOOTH) { - vmesa->regCmdA_End |= HC_HShading_Gouraud; - } - - vmesa->hwShadeModel = ctx->Light.ShadeModel; - regCmdB = vmesa->regCmdB; - - switch (hwprim) { - case GL_POINTS: - vmesa->regCmdA_End |= HC_HPMType_Point | HC_HVCycle_Full; - vmesa->regCmdA_End |= HC_HShading_Gouraud; /* always Gouraud - shade points?!? */ - break; - case GL_LINES: - vmesa->regCmdA_End |= HC_HPMType_Line | HC_HVCycle_Full; - regCmdB |= HC_HLPrst_MASK; - if (ctx->Light.ShadeModel == GL_FLAT) - vmesa->regCmdA_End |= HC_HShading_FlatB; - break; - case GL_LINE_LOOP: - case GL_LINE_STRIP: - vmesa->regCmdA_End |= HC_HPMType_Line | HC_HVCycle_AFP | - HC_HVCycle_AB | HC_HVCycle_NewB; - regCmdB |= HC_HVCycle_AB | HC_HVCycle_NewB | HC_HLPrst_MASK; - if (ctx->Light.ShadeModel == GL_FLAT) - vmesa->regCmdA_End |= HC_HShading_FlatB; - break; - case GL_TRIANGLES: - vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_Full; - if (ctx->Light.ShadeModel == GL_FLAT) - vmesa->regCmdA_End |= HC_HShading_FlatC; - break; - case GL_TRIANGLE_STRIP: - vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_AFP | - HC_HVCycle_AC | HC_HVCycle_BB | HC_HVCycle_NewC; - regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC; - if (ctx->Light.ShadeModel == GL_FLAT) - vmesa->regCmdA_End |= HC_HShading_FlatC; - break; - case GL_TRIANGLE_FAN: - vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_AFP | - HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC; - regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC; - if (ctx->Light.ShadeModel == GL_FLAT) - vmesa->regCmdA_End |= HC_HShading_FlatC; - break; - case GL_QUADS: - abort(); - return; - case GL_QUAD_STRIP: - abort(); - return; - case GL_POLYGON: - vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_AFP | - HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC; - regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC; - if (ctx->Light.ShadeModel == GL_FLAT) - vmesa->regCmdA_End |= HC_HShading_FlatC; - break; - default: - abort(); - return; - } - -/* assert((vmesa->dmaLow & 0x4) == 0); */ - - if (vmesa->dmaCliprectAddr == ~0) { - if (VIA_DEBUG & DEBUG_DMA) - fprintf(stderr, "reserve cliprect space at %x\n", vmesa->dmaLow); - vmesa->dmaCliprectAddr = vmesa->dmaLow; - BEGIN_RING(8); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( 0xCCCCCCCC ); - OUT_RING( 0xCCCCCCCC ); - OUT_RING( 0xCCCCCCCC ); - OUT_RING( 0xCCCCCCCC ); - OUT_RING( 0xCCCCCCCC ); - OUT_RING( 0xCCCCCCCC ); - ADVANCE_RING(); - } - - assert(vmesa->dmaLastPrim == 0); - - BEGIN_RING(8); - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_NotTex << 16) ); - OUT_RING( 0xCCCCCCCC ); - OUT_RING( 0xDDDDDDDD ); - - OUT_RING( HC_HEADER2 ); - OUT_RING( (HC_ParaType_CmdVdata << 16) ); - OUT_RING( regCmdB ); - OUT_RING( vmesa->regCmdA_End ); - ADVANCE_RING(); - - vmesa->hwPrimitive = hwprim; - vmesa->dmaLastPrim = vmesa->dmaLow; - } - else { - assert(!vmesa->newEmitState); - } -} - -/* Callback for mesa: - */ -static void viaRenderPrimitive( struct gl_context *ctx, GLuint prim ) -{ - viaRasterPrimitive( ctx, prim, hwPrim[prim] ); -} - - -void viaFinishPrimitive(struct via_context *vmesa) -{ - if (VIA_DEBUG & (DEBUG_DMA|DEBUG_PRIMS)) - fprintf(stderr, "%s\n", __FUNCTION__); - - if (!vmesa->dmaLastPrim || vmesa->dmaCliprectAddr == ~0) { - assert(0); - } - else if (vmesa->dmaLow != vmesa->dmaLastPrim) { - GLuint cmdA = (vmesa->regCmdA_End | HC_HPLEND_MASK | - HC_HPMValidN_MASK | HC_HE3Fire_MASK); - RING_VARS; - - vmesa->dmaLastPrim = 0; - - /* KW: modified 0x1 to 0x4 below: - */ - if ((vmesa->dmaLow & 0x4) || !vmesa->useAgp) { - BEGIN_RING_NOCHECK( 1 ); - OUT_RING( cmdA ); - ADVANCE_RING(); - } - else { - BEGIN_RING_NOCHECK( 2 ); - OUT_RING( cmdA ); - OUT_RING( cmdA ); - ADVANCE_RING(); - } - - if (vmesa->dmaLow > VIA_DMA_HIGHWATER) - viaFlushDma( vmesa ); - } - else { - if (VIA_DEBUG & (DEBUG_DMA|DEBUG_PRIMS)) - fprintf(stderr, "remove empty primitive\n"); - - /* Remove the primitive header: - */ - vmesa->dmaLastPrim = 0; - vmesa->dmaLow -= 8 * sizeof(GLuint); - - /* Maybe remove the cliprect as well: - */ - if (vmesa->dmaCliprectAddr == vmesa->dmaLow - 8 * sizeof(GLuint)) { - vmesa->dmaLow -= 8 * sizeof(GLuint); - vmesa->dmaCliprectAddr = ~0; - } - } - - vmesa->renderPrimitive = GL_POLYGON + 1; - vmesa->hwPrimitive = GL_POLYGON + 1; - vmesa->dmaLastPrim = 0; -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - - -void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode) -{ - struct gl_context *ctx = vmesa->glCtx; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = vmesa->Fallback; - - if (mode) { - vmesa->Fallback |= bit; - if (oldfallback == 0) { - VIA_FLUSH_DMA(vmesa); - - if (VIA_DEBUG & DEBUG_FALLBACKS) - fprintf(stderr, "ENTER FALLBACK %x\n", bit); - - _swsetup_Wakeup(ctx); - vmesa->renderIndex = ~0; - } - } - else { - vmesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - - if (VIA_DEBUG & DEBUG_FALLBACKS) - fprintf(stderr, "LEAVE FALLBACK %x\n", bit); - - tnl->Driver.Render.Start = viaRenderStart; - tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive; - tnl->Driver.Render.Finish = viaRenderFinish; - - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - tnl->Driver.Render.ResetLineStipple = viaResetLineStipple; - - _tnl_invalidate_vertex_state( ctx, ~0 ); - _tnl_invalidate_vertices( ctx, ~0 ); - _tnl_install_attrs( ctx, - vmesa->vertex_attrs, - vmesa->vertex_attr_count, - vmesa->ViewportMatrix.m, 0 ); - - vmesa->newState |= (_VIA_NEW_RENDERSTATE|_VIA_NEW_VERTEX); - } - } -} - -static void viaRunPipeline( struct gl_context *ctx ) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - - if (vmesa->newState) { - vmesa->newRenderState |= vmesa->newState; - viaValidateState( ctx ); - } - - _tnl_run_pipeline( ctx ); -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - - -void viaInitTriFuncs(struct gl_context *ctx) -{ - struct via_context *vmesa = VIA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - } - - tnl->Driver.RunPipeline = viaRunPipeline; - tnl->Driver.Render.Start = viaRenderStart; - tnl->Driver.Render.Finish = viaRenderFinish; - tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = viaResetLineStipple; - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; - - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) ); - - vmesa->verts = (GLubyte *)tnl->clipspace.vertex_buf; - -} diff --git a/src/mesa/drivers/dri/unichrome/via_tris.h b/src/mesa/drivers/dri/unichrome/via_tris.h deleted file mode 100644 index 4bc83fc6242..00000000000 --- a/src/mesa/drivers/dri/unichrome/via_tris.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _VIATRIS_H -#define _VIATRIS_H - -#include "main/mtypes.h" - -extern void viaPrintRenderState(const char *msg, GLuint state); -extern void viaInitTriFuncs(struct gl_context *ctx); -extern void viaRasterPrimitive(struct gl_context *ctx, GLenum rPrim, GLuint hwPrim); -extern void viaRasterPrimitiveFinish(struct gl_context *ctx); - -#endif |