mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-11 06:28:09 +02:00
Imported the Savage DRI driver from the savage-2-0-0-branch of DRI CVS
with modifications to make it work with current Mesa 6.
This commit is contained in:
parent
6e450f22bb
commit
263581bba4
21 changed files with 10537 additions and 0 deletions
1063
src/mesa/drivers/dri/savage/savage_3d_reg.h
Normal file
1063
src/mesa/drivers/dri/savage/savage_3d_reg.h
Normal file
File diff suppressed because it is too large
Load diff
741
src/mesa/drivers/dri/savage/savage_bci.h
Normal file
741
src/mesa/drivers/dri/savage/savage_bci.h
Normal file
|
|
@ -0,0 +1,741 @@
|
|||
/*
|
||||
* 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 {
|
||||
ZCF_Never,
|
||||
ZCF_Less,
|
||||
ZCF_Equal,
|
||||
ZCF_LessEqual,
|
||||
ZCF_Greater,
|
||||
ZCF_NotEqual,
|
||||
ZCF_GreaterEqual,
|
||||
ZCF_Always
|
||||
}ZCmpFunc; /* same for Alpha test compare function*/
|
||||
|
||||
|
||||
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_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
|
||||
|
||||
/*
|
||||
* 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
|
||||
{
|
||||
STC_COMP_Never,
|
||||
STC_COMP_Less,
|
||||
STC_COMP_Equal,
|
||||
STC_COMP_LessEqual,
|
||||
STC_COMP_Greater,
|
||||
STC_COMP_NotEqual,
|
||||
STC_COMP_GreaterEqual,
|
||||
STC_COMP_Always
|
||||
} StencilCompareMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STC_FAIL_Keep,
|
||||
STC_FAIL_Zero,
|
||||
STC_FAIL_Equal,
|
||||
STC_FAIL_IncClamp,
|
||||
STC_FAIL_DecClamp,
|
||||
STC_FAIL_Invert,
|
||||
STC_FAIL_Inc,
|
||||
STC_FAIL_Dec
|
||||
} StencilFailOp;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STC_ZPASS_Keep,
|
||||
STC_ZPASS_Zero,
|
||||
STC_ZPASS_Equal,
|
||||
STC_ZPASS_IncClamp,
|
||||
STC_ZPASS_DecClamp,
|
||||
STC_ZPASS_Invert,
|
||||
STC_ZPASS_Inc,
|
||||
STC_ZPASS_Dec
|
||||
} StencilZPassOp;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STC_ZFAIL_Keep,
|
||||
STC_ZFAIL_Zero,
|
||||
STC_ZFAIL_Equal,
|
||||
STC_ZFAIL_IncClamp,
|
||||
STC_ZFAIL_DecClamp,
|
||||
STC_ZFAIL_Invert,
|
||||
STC_ZFAIL_Inc,
|
||||
STC_ZFAIL_Dec
|
||||
} StencilZFailOp;
|
||||
|
||||
/***************************************************************
|
||||
*** 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_UV0 ((1<<4) | (1<<5))
|
||||
#define SAVAGE_HW_NO_UV1 ((1<<6) | (1<<7))
|
||||
|
||||
#define SAVAGE_HW_TRIANGLE_TYPE (3UL<<25)
|
||||
#define SAVAGE_HW_TRIANGLE_CONT (1UL<<24)
|
||||
#define SAVAGE_HW_TRIANGLE_LIST (0<<25)
|
||||
#define SAVAGE_HW_TRIANGLE_STRIP (1<<25)
|
||||
#define SAVAGE_HW_TRIANGLE_FAN (2<<25)
|
||||
#define SAVAGE_HW_QUAD (3<<25)
|
||||
|
||||
#define __HW_TEXTURE_CHANGED 0x00002FE
|
||||
#define __HW_HAS_SCISSORS_CHANGED 0x00001800
|
||||
#define __HW_ALL_CHANGED 0x1FFFFFF
|
||||
/*Frank 2001/11/14 Wait commands*/
|
||||
#define WAIT_3D_IDLE 0xC0010000
|
||||
#define WAIT_3D_2D_IDLE 0xC0030000
|
||||
|
||||
#define SET_REGISTER(index, count) \
|
||||
((CMD_SetRegister << 27) | (0x6000000) | ((count) << 16) | (index))
|
||||
|
||||
/*frank 2001/11/20 */
|
||||
#define MAXLOOP 0xFFFFFF
|
||||
/*#define MAXFIFO 0x7F00*/
|
||||
#define MAXFIFO 0x1FF00
|
||||
|
||||
/* get eventtag from shadow status */
|
||||
/* here we use eventTag1 because eventTag0 is used by HWXvMC*/
|
||||
#define GET_EVENTTAG \
|
||||
(((*(volatile GLuint *)(imesa->MMIO_BASE+0x48c04)) & 0xffff0000L)>>16)
|
||||
|
||||
#define SHADOW_WAIT(imesa ) do \
|
||||
{ \
|
||||
int loop=0; \
|
||||
imesa->shadowCounter = (imesa->shadowCounter + 1) & 0xffff;\
|
||||
if(imesa->shadowCounter == 0)\
|
||||
imesa->shadowCounter = MAX_SHADOWCOUNTER;\
|
||||
*(volatile GLuint *)imesa->BCIBase = imesa->shadowCounter | 0x98400000L;\
|
||||
while(\
|
||||
(GET_EVENTTAG) != imesa->shadowCounter &&\
|
||||
(loop++ < MAXLOOP));\
|
||||
}while(0);
|
||||
|
||||
#define SHADOW_WAIT_IDLE(imesa ) do \
|
||||
{ \
|
||||
int loop=0; \
|
||||
imesa->shadowCounter = (imesa->shadowCounter + 1) & 0xffff;\
|
||||
if(imesa->shadowCounter == 0)\
|
||||
imesa->shadowCounter = MAX_SHADOWCOUNTER;\
|
||||
/* *(volatile GLuint *)imesa->BCIBase = WAIT_3D_IDLE;\*/\
|
||||
*(volatile GLuint *)imesa->BCIBase = imesa->shadowCounter | 0x98400000L;\
|
||||
while ( \
|
||||
(GET_EVENTTAG) != imesa->shadowCounter && \
|
||||
(loop++ < MAXLOOP)); \
|
||||
}while(0);
|
||||
|
||||
#if 0
|
||||
#define ALT_STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c60))
|
||||
|
||||
#define PAGE_PENDING(result) do{\
|
||||
result=((ALT_STATUS_WORD0 & 0x08000000)?GL_TRUE:GL_FALSE);\
|
||||
}while(0)
|
||||
|
||||
#define WAIT_FOR_FIFO(count) do{\
|
||||
int loop = 0; \
|
||||
int slots = MAXFIFO-count; \
|
||||
while(((ALT_STATUS_WORD0 &0x001fffff)>slots)&&(loop++<MAXLOOP)); \
|
||||
}while(0)
|
||||
|
||||
|
||||
#define WAIT_IDLE_EMPTY do{\
|
||||
int loop = 0; \
|
||||
if (/*imesa->shadowStatus*/0)\
|
||||
{\
|
||||
SHADOW_WAIT_IDLE(imesa);\
|
||||
}\
|
||||
else\
|
||||
{ \
|
||||
while(((ALT_STATUS_WORD0 &0x00ffffff)!=0x00E00000L)&&(loop++<MAXLOOP));\
|
||||
}\
|
||||
}while(0)
|
||||
|
||||
#define WAIT_IDLE do{\
|
||||
int loop = 0; \
|
||||
if (imesa->shadowStatus)\
|
||||
while((((*imesa->shadowPointer) & 0x0E000000L)!=0x0E000000L)&&(loop++<MAXLOOP));\
|
||||
else\
|
||||
while(((ALT_STATUS_WORD0 &0x00E00000)!=0x00E00000L)&&(loop++<MAXLOOP)); \
|
||||
}while(0)
|
||||
#endif /* 0 */
|
||||
|
||||
#define SAVAGE_DRAW_PRIMITIVE(count, typeandvertexSkip, isCont) \
|
||||
( ((count)<<16) | (typeandvertexSkip) | (isCont | (1<<31)));
|
||||
|
||||
static __inline volatile GLuint * SAVAGE_GET_BCI_POINTER(savageContextPtr imesa, GLuint count)
|
||||
{
|
||||
WAIT_FOR_FIFO(count);
|
||||
return (volatile GLuint *)(imesa->BCIBase);
|
||||
}
|
||||
|
||||
/*use this set bci cmd now!*/
|
||||
#define WRITE_CMD(buf,cmd,type) do {\
|
||||
*((type*)buf)=cmd;\
|
||||
buf++;\
|
||||
}while(0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
161
src/mesa/drivers/dri/savage/savage_init.h
Normal file
161
src/mesa/drivers/dri/savage/savage_init.h
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* 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_
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "dri_util.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
typedef struct {
|
||||
drmHandle handle;
|
||||
drmSize size;
|
||||
char *map;
|
||||
} savageRegion, *savageRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
savageRegion front;
|
||||
savageRegion back;
|
||||
savageRegion depth;
|
||||
savageRegion aperture;
|
||||
|
||||
int chipset;
|
||||
int width;
|
||||
int height;
|
||||
int mem;
|
||||
|
||||
int cpp; /* for front and back buffers */
|
||||
int zpp;
|
||||
#if 0
|
||||
int bitsPerPixel;
|
||||
#endif
|
||||
unsigned int frontFormat;
|
||||
unsigned int frontOffset;
|
||||
unsigned int frontPitch;
|
||||
unsigned int frontBitmapDesc;
|
||||
|
||||
unsigned int backOffset;
|
||||
unsigned int backBitmapDesc;
|
||||
unsigned int depthOffset;
|
||||
unsigned int depthBitmapDesc;
|
||||
|
||||
unsigned int backPitch;
|
||||
unsigned int backPitchBits;
|
||||
|
||||
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];
|
||||
|
||||
__DRIscreenPrivate *driScrnPriv;
|
||||
drmBufMapPtr bufs;
|
||||
int use_copy_buf;
|
||||
unsigned int sarea_priv_offset;
|
||||
} savageScreenPrivate;
|
||||
|
||||
|
||||
#include "savagecontext.h"
|
||||
|
||||
extern void savageGetLock( savageContextPtr imesa, GLuint flags );
|
||||
extern void savageEmitHwStateLocked( savageContextPtr imesa );
|
||||
extern void savageEmitScissorValues( savageContextPtr imesa, int box_nr, int emit );
|
||||
extern void savageEmitDrawingRectangle( savageContextPtr imesa );
|
||||
extern void savageXMesaSetBackClipRects( savageContextPtr imesa );
|
||||
extern void savageXMesaSetFrontClipRects( 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
|
||||
#endif
|
||||
800
src/mesa/drivers/dri/savage/savage_xmesa.c
Normal file
800
src/mesa/drivers/dri/savage/savage_xmesa.c
Normal file
|
|
@ -0,0 +1,800 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
#include <X11/Xlibint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "savagecontext.h"
|
||||
#include "context.h"
|
||||
#include "matrix.h"
|
||||
|
||||
#include "simple_list.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "array_cache/acache.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
|
||||
#include "savagedd.h"
|
||||
#include "savagestate.h"
|
||||
#include "savagetex.h"
|
||||
#include "savagespan.h"
|
||||
#include "savagetris.h"
|
||||
#include "savagevb.h"
|
||||
#include "savageioctl.h"
|
||||
#include "savage_bci.h"
|
||||
|
||||
#include "savage_dri.h"
|
||||
|
||||
#include "savagedma.h"
|
||||
|
||||
#ifndef SAVAGE_DEBUG
|
||||
int SAVAGE_DEBUG = (0
|
||||
/* | DEBUG_ALWAYS_SYNC */
|
||||
/* | DEBUG_VERBOSE_RING */
|
||||
/* | DEBUG_VERBOSE_OUTREG */
|
||||
/* | DEBUG_VERBOSE_MSG */
|
||||
/* | DEBUG_NO_OUTRING */
|
||||
/* | DEBUG_NO_OUTREG */
|
||||
/* | DEBUG_VERBOSE_API */
|
||||
/* | DEBUG_VERBOSE_2D */
|
||||
/* | DEBUG_VERBOSE_DRI */
|
||||
/* | DEBUG_VALIDATE_RING */
|
||||
/* | DEBUG_VERBOSE_IOCTL */
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
/*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
|
||||
|
||||
/* this is first function called in dirver*/
|
||||
|
||||
static GLboolean
|
||||
savageInitDriver(__DRIscreenPrivate *sPriv)
|
||||
{
|
||||
savageScreenPrivate *savageScreen;
|
||||
SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
|
||||
|
||||
|
||||
/* Check the DRI version */
|
||||
{
|
||||
int major, minor, patch;
|
||||
if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
|
||||
if (major != 4 || minor < 0) {
|
||||
__driUtilMessage("savage DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that the DDX driver version is compatible */
|
||||
if (sPriv->ddxMajor != 1 ||
|
||||
sPriv->ddxMinor < 0) {
|
||||
__driUtilMessage("savage DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Check that the DRM driver version is compatible */
|
||||
if (sPriv->drmMajor != 1 ||
|
||||
sPriv->drmMinor < 0) {
|
||||
__driUtilMessage("savage DRI driver expected DRM driver version 1.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Allocate the private area */
|
||||
savageScreen = (savageScreenPrivate *)Xmalloc(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->frontPitch=gDRIPriv->frontPitch;
|
||||
savageScreen->frontOffset=gDRIPriv->frontOffset;
|
||||
savageScreen->frontBitmapDesc = gDRIPriv->frontBitmapDesc;
|
||||
|
||||
if (gDRIPriv->cpp == 4)
|
||||
savageScreen->frontFormat = DV_PF_8888;
|
||||
else
|
||||
savageScreen->frontFormat = DV_PF_565;
|
||||
|
||||
savageScreen->backOffset = gDRIPriv->backOffset;
|
||||
savageScreen->backBitmapDesc = gDRIPriv->backBitmapDesc;
|
||||
savageScreen->depthOffset=gDRIPriv->depthOffset;
|
||||
savageScreen->depthBitmapDesc = gDRIPriv->depthBitmapDesc;
|
||||
#if 0
|
||||
savageScreen->backPitch = gDRIPriv->auxPitch;
|
||||
savageScreen->backPitchBits = gDRIPriv->auxPitchBits;
|
||||
#endif
|
||||
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->agpTextures.handle;
|
||||
savageScreen->textureSize[SAVAGE_AGP_HEAP] =
|
||||
gDRIPriv->agpTextures.size;
|
||||
savageScreen->logTextureGranularity[SAVAGE_AGP_HEAP] =
|
||||
gDRIPriv->logAgpTextureGranularity;
|
||||
|
||||
savageScreen->back.handle = gDRIPriv->backbuffer;
|
||||
savageScreen->back.size = gDRIPriv->backbufferSize;
|
||||
savageScreen->back.map =
|
||||
(drmAddress)(((unsigned int)sPriv->pFB)+gDRIPriv->backOffset);
|
||||
|
||||
savageScreen->depth.handle = gDRIPriv->depthbuffer;
|
||||
savageScreen->depth.size = gDRIPriv->depthbufferSize;
|
||||
|
||||
savageScreen->depth.map =
|
||||
(drmAddress)(((unsigned int)sPriv->pFB)+gDRIPriv->depthOffset);
|
||||
|
||||
savageScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
|
||||
|
||||
savageScreen->texVirtual[SAVAGE_CARD_HEAP] =
|
||||
(drmAddress)(((unsigned int)sPriv->pFB)+gDRIPriv->textureOffset);
|
||||
#if 0
|
||||
savageDDFastPathInit();
|
||||
savageDDTrifuncInit();
|
||||
savageDDSetupInit();
|
||||
#endif
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Accessed by dlsym from dri_mesa_init.c
|
||||
*/
|
||||
static void
|
||||
savageDestroyScreen(__DRIscreenPrivate *sPriv)
|
||||
{
|
||||
savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
|
||||
|
||||
|
||||
Xfree(savageScreen);
|
||||
sPriv->private = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
GLvisual *XMesaCreateVisual(Display *dpy,
|
||||
__DRIscreenPrivate *driScrnPriv,
|
||||
const XVisualInfo *visinfo,
|
||||
const __GLXvisualConfig *config)
|
||||
{
|
||||
/* Drivers may change the args to _mesa_create_visual() in order to
|
||||
* setup special visuals.
|
||||
*/
|
||||
return _mesa_create_visual( config->rgba,
|
||||
config->doubleBuffer,
|
||||
config->stereo,
|
||||
_mesa_bitcount(visinfo->red_mask),
|
||||
_mesa_bitcount(visinfo->green_mask),
|
||||
_mesa_bitcount(visinfo->blue_mask),
|
||||
config->alphaSize,
|
||||
0, /* index bits */
|
||||
config->depthSize,
|
||||
config->stencilSize,
|
||||
config->accumRedSize,
|
||||
config->accumGreenSize,
|
||||
config->accumBlueSize,
|
||||
config->accumAlphaSize,
|
||||
0 /* num samples */ );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GLboolean
|
||||
savageCreateContext( const __GLcontextModes *mesaVis,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate )
|
||||
{
|
||||
GLcontext *ctx, *shareCtx;
|
||||
savageContextPtr imesa;
|
||||
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
|
||||
struct dd_function_table functions;
|
||||
SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
|
||||
savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
|
||||
drm_savage_sarea_t *saPriv=(drm_savage_sarea_t *)(((char*)sPriv->pSAREA)+
|
||||
savageScreen->sarea_priv_offset);
|
||||
int i;
|
||||
imesa = (savageContextPtr)Xcalloc(sizeof(savageContext), 1);
|
||||
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(mesaVis, shareCtx, &functions, imesa);
|
||||
if (!ctx) {
|
||||
Xfree(imesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
driContextPriv->driverPrivate = imesa;
|
||||
|
||||
/* BEGIN;*/
|
||||
/* Set the maximum texture size small enough that we can guarentee
|
||||
* that both texture units can bind a maximal texture and have them
|
||||
* in memory at once.
|
||||
*/
|
||||
if (savageScreen->textureSize[SAVAGE_CARD_HEAP] < 2*1024*1024) {
|
||||
ctx->Const.MaxTextureLevels = 9;
|
||||
} else if (savageScreen->textureSize[SAVAGE_CARD_HEAP] < 8*1024*1024) {
|
||||
ctx->Const.MaxTextureLevels = 10;
|
||||
} else {
|
||||
ctx->Const.MaxTextureLevels = 11;
|
||||
}
|
||||
if (savageScreen->chipset >= S3_SAVAGE4)
|
||||
ctx->Const.MaxTextureUnits = 2;
|
||||
else
|
||||
ctx->Const.MaxTextureUnits = 1;
|
||||
|
||||
#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
|
||||
|
||||
/* 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 */
|
||||
|
||||
/*The shadow pointer*/
|
||||
imesa->shadowPointer =
|
||||
(volatile GLuint *)((((GLuint)(&saPriv->shadow_status)) + 31) & 0xffffffe0L) ;
|
||||
/* here we use eventTag1 because eventTag0 is used by HWXvMC*/
|
||||
imesa->eventTag1 = (volatile GLuint *)(imesa->shadowPointer + 6);
|
||||
/* imesa->eventTag1=(volatile GLuint *)(imesa->MMIO_BASE+0x48c04);*/
|
||||
imesa->shadowCounter = MAX_SHADOWCOUNTER;
|
||||
imesa->shadowStatus = GL_TRUE;/*Will judge by 2d message */
|
||||
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->registers.handle,
|
||||
gDRIPriv->registers.size,
|
||||
(drmAddress *)&(gDRIPriv->registers.map)) != 0)
|
||||
{
|
||||
Xfree(savageScreen);
|
||||
sPriv->private = NULL;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (drmMap(sPriv->fd,
|
||||
gDRIPriv->agpTextures.handle,
|
||||
gDRIPriv->agpTextures.size,
|
||||
(drmAddress *)&(gDRIPriv->agpTextures.map)) != 0)
|
||||
{
|
||||
Xfree(savageScreen);
|
||||
sPriv->private = NULL;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* agp texture*/
|
||||
savageScreen->texVirtual[SAVAGE_AGP_HEAP] =
|
||||
(drmAddress)(gDRIPriv->agpTextures.map);
|
||||
|
||||
|
||||
|
||||
gDRIPriv->BCIcmdBuf.map = (drmAddress *)
|
||||
((unsigned int)gDRIPriv->registers.map+0x00010000);
|
||||
|
||||
imesa->MMIO_BASE = (GLuint)gDRIPriv->registers.map;
|
||||
imesa->BCIBase= (GLuint)gDRIPriv->BCIcmdBuf.map;
|
||||
|
||||
savageScreen->aperture.handle = gDRIPriv->aperture.handle;
|
||||
savageScreen->aperture.size = gDRIPriv->aperture.size;
|
||||
if (drmMap(sPriv->fd,
|
||||
savageScreen->aperture.handle,
|
||||
savageScreen->aperture.size,
|
||||
(drmAddress *)&savageScreen->aperture.map) != 0)
|
||||
{
|
||||
Xfree(savageScreen);
|
||||
sPriv->private = NULL;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
imesa->apertureBase[i] = ((GLuint)savageScreen->aperture.map +
|
||||
0x01000000 * i );
|
||||
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
volatile unsigned int * tmp;
|
||||
|
||||
tmp=(volatile unsigned int *)(imesa->MMIO_BASE + 0x850C);
|
||||
|
||||
|
||||
tmp=(volatile unsigned int *)(imesa->MMIO_BASE + 0x48C40);
|
||||
|
||||
|
||||
tmp=(volatile unsigned int *)(imesa->MMIO_BASE + 0x48C44);
|
||||
|
||||
|
||||
tmp=(volatile unsigned int *)(imesa->MMIO_BASE + 0x48C48);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
imesa->aperturePitch = gDRIPriv->aperturePitch;
|
||||
|
||||
|
||||
/* change texHeap initialize to support two kind of texture heap*/
|
||||
/* here is some parts of initialization, others in InitDriver() */
|
||||
|
||||
imesa->lastTexHeap = savageScreen->texVirtual[SAVAGE_AGP_HEAP] ? 2 : 1;
|
||||
|
||||
/*allocate texHeap for multi-tex*/
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<SAVAGE_NR_TEX_HEAPS;i++)
|
||||
{
|
||||
imesa->texHeap[i] = mmInit( 0, savageScreen->textureSize[i] );
|
||||
make_empty_list(&imesa->TexObjList[i]);
|
||||
}
|
||||
|
||||
make_empty_list(&imesa->SwappedOut);
|
||||
}
|
||||
|
||||
imesa->hw_stencil = GL_FALSE;
|
||||
#if HW_STENCIL
|
||||
imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
|
||||
#endif
|
||||
imesa->depth_scale = (imesa->savageScreen->zpp == 2) ?
|
||||
(1.0F/0x10000):(1.0F/0x1000000);
|
||||
|
||||
/* Utah stuff
|
||||
*/
|
||||
imesa->new_state = ~0;
|
||||
imesa->RenderIndex = ~0;
|
||||
imesa->dirty = ~0;
|
||||
imesa->vertex_format = 0;
|
||||
imesa->TextureMode = ctx->Texture.Unit[0].EnvMode;
|
||||
imesa->CurrentTexObj[0] = 0;
|
||||
imesa->CurrentTexObj[1] = 0;
|
||||
imesa->texAge[SAVAGE_CARD_HEAP]=0;
|
||||
imesa->texAge[SAVAGE_AGP_HEAP]=0;
|
||||
|
||||
/* Initialize the software rasterizer and helper modules.
|
||||
*/
|
||||
_swrast_CreateContext( ctx );
|
||||
_ac_CreateContext( ctx );
|
||||
_tnl_CreateContext( ctx );
|
||||
|
||||
_swsetup_CreateContext( ctx );
|
||||
|
||||
/* Install the customized pipeline:
|
||||
*/
|
||||
#if 0
|
||||
_tnl_destroy_pipeline( ctx );
|
||||
_tnl_install_pipeline( ctx, savage_pipeline );
|
||||
#endif
|
||||
|
||||
/* Configure swrast to match hardware characteristics:
|
||||
*/
|
||||
_swrast_allow_pixel_fog( ctx, GL_FALSE );
|
||||
_swrast_allow_vertex_fog( ctx, GL_TRUE );
|
||||
|
||||
ctx->DriverCtx = (void *) imesa;
|
||||
imesa->glCtx = ctx;
|
||||
if (savageDMAInit(imesa) == GL_FALSE)
|
||||
return GL_FALSE;
|
||||
|
||||
savageDDExtensionsInit( ctx );
|
||||
|
||||
savageDDInitStateFuncs( ctx );
|
||||
savageDDInitSpanFuncs( ctx );
|
||||
savageDDInitDriverFuncs( ctx );
|
||||
savageDDInitIoctlFuncs( ctx );
|
||||
savageInitTriFuncs( ctx );
|
||||
|
||||
savageInitVB( ctx );
|
||||
savageDDInitState( imesa );
|
||||
|
||||
driContextPriv->driverPrivate = (void *) imesa;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
savageDestroyContext(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
assert (imesa); /* should never be NULL */
|
||||
if (imesa) {
|
||||
savageTextureObjectPtr next_t, t;
|
||||
|
||||
/* update for multi-tex*/
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<SAVAGE_NR_TEX_HEAPS;i++)
|
||||
foreach_s (t, next_t, &(imesa->TexObjList[i]))
|
||||
savageDestroyTexObj(imesa, t);
|
||||
}
|
||||
foreach_s (t, next_t, &(imesa->SwappedOut))
|
||||
savageDestroyTexObj(imesa, t);
|
||||
/*free the dma buffer*/
|
||||
savageDMAClose(imesa);
|
||||
_swsetup_DestroyContext(imesa->glCtx );
|
||||
_tnl_DestroyContext( imesa->glCtx );
|
||||
_ac_DestroyContext( imesa->glCtx );
|
||||
_swrast_DestroyContext( imesa->glCtx );
|
||||
|
||||
savageFreeVB( imesa->glCtx );
|
||||
|
||||
/* free the Mesa context */
|
||||
imesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context(imesa->glCtx);
|
||||
|
||||
/* no longer use vertex_dma_buf*/
|
||||
Xfree(imesa);
|
||||
}
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap)
|
||||
{
|
||||
if (isPixmap) {
|
||||
return GL_FALSE; /* not implemented */
|
||||
}
|
||||
else {
|
||||
#if HW_STENCIL
|
||||
GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
|
||||
#else
|
||||
GLboolean swStencil = mesaVis->stencilBits > 0;
|
||||
#endif
|
||||
driDrawPriv->driverPrivate = (void *)
|
||||
_mesa_create_framebuffer(mesaVis,
|
||||
GL_FALSE, /* software depth buffer? */
|
||||
swStencil,
|
||||
mesaVis->accumRedBits > 0,
|
||||
mesaVis->alphaBits > 0 );
|
||||
|
||||
return (driDrawPriv->driverPrivate != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
savageDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
|
||||
{
|
||||
_mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
|
||||
}
|
||||
|
||||
#if 0
|
||||
void XMesaSwapBuffers(__DRIdrawablePrivate *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 savageXMesaSetFrontClipRects( savageContextPtr imesa )
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
|
||||
|
||||
imesa->numClipRects = dPriv->numClipRects;
|
||||
imesa->pClipRects = dPriv->pClipRects;
|
||||
imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
|
||||
imesa->drawX = dPriv->x;
|
||||
imesa->drawY = dPriv->y;
|
||||
|
||||
savageEmitDrawingRectangle( imesa );
|
||||
}
|
||||
|
||||
|
||||
void savageXMesaSetBackClipRects( savageContextPtr imesa )
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
|
||||
|
||||
if (dPriv->numBackClipRects == 0)
|
||||
{
|
||||
|
||||
|
||||
imesa->numClipRects = dPriv->numClipRects;
|
||||
imesa->pClipRects = dPriv->pClipRects;
|
||||
imesa->drawX = dPriv->x;
|
||||
imesa->drawY = dPriv->y;
|
||||
} else {
|
||||
|
||||
|
||||
imesa->numClipRects = dPriv->numBackClipRects;
|
||||
imesa->pClipRects = dPriv->pBackClipRects;
|
||||
imesa->drawX = dPriv->backX;
|
||||
imesa->drawY = dPriv->backY;
|
||||
}
|
||||
|
||||
savageEmitDrawingRectangle( imesa );
|
||||
imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void savageXMesaWindowMoved( savageContextPtr imesa )
|
||||
{
|
||||
if (0)
|
||||
fprintf(stderr, "savageXMesaWindowMoved\n\n");
|
||||
|
||||
switch (imesa->glCtx->Color._DrawDestMask) {
|
||||
case FRONT_LEFT_BIT:
|
||||
savageXMesaSetFrontClipRects( imesa );
|
||||
break;
|
||||
case BACK_LEFT_BIT:
|
||||
savageXMesaSetBackClipRects( imesa );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
savageUnbindContext(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
savageContextPtr savage = (savageContextPtr) driContextPriv->driverPrivate;
|
||||
if (savage)
|
||||
savage->dirty = ~0;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
savageOpenFullScreen(__DRIcontextPrivate *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(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
|
||||
if (driContextPriv) {
|
||||
savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
|
||||
WAIT_IDLE_EMPTY;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
__DRIdrawablePrivate *driReadPriv)
|
||||
{
|
||||
if (driContextPriv) {
|
||||
savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
imesa->driReadable = driReadPriv;
|
||||
imesa->driDrawable = driDrawPriv;
|
||||
imesa->mesa_drawable = driDrawPriv;
|
||||
imesa->dirty = ~0;
|
||||
|
||||
_mesa_make_current2(imesa->glCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate);
|
||||
|
||||
savageXMesaWindowMoved( imesa );
|
||||
|
||||
if (!imesa->glCtx->Viewport.Width)
|
||||
_mesa_set_viewport(imesa->glCtx, 0, 0,
|
||||
driDrawPriv->w, driDrawPriv->h);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mesa_make_current(NULL, NULL);
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
void savageGetLock( savageContextPtr imesa, GLuint flags )
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
|
||||
__DRIscreenPrivate *sPriv = imesa->driScreen;
|
||||
drm_savage_sarea_t *sarea = imesa->sarea;
|
||||
int me = imesa->hHWContext;
|
||||
int stamp = dPriv->lastStamp;
|
||||
int heap;
|
||||
|
||||
|
||||
|
||||
/* 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, dPriv);
|
||||
|
||||
|
||||
|
||||
|
||||
/* If we lost context, need to dump all registers to hardware.
|
||||
* Note that we don't care about 2d contexts, even if they perform
|
||||
* accelerated commands, so the DRI locking in the X server is even
|
||||
* more broken than usual.
|
||||
*/
|
||||
if (sarea->ctxOwner != me) {
|
||||
imesa->dirty |= (SAVAGE_UPLOAD_CTX |
|
||||
SAVAGE_UPLOAD_CLIPRECTS |
|
||||
SAVAGE_UPLOAD_TEX0 |
|
||||
SAVAGE_UPLOAD_TEX1);
|
||||
imesa->Registers.changed.uiRegistersChanged = __HW_ALL_CHANGED;
|
||||
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.
|
||||
*/
|
||||
/*frank just for compiling,texAge,texList,AGP*/
|
||||
|
||||
for(heap= 0 ;heap < imesa->lastTexHeap ; heap++)
|
||||
{
|
||||
if (sarea->texAge[heap] != imesa->texAge[heap]) {
|
||||
int sz = 1 << (imesa->savageScreen->logTextureGranularity[heap]);
|
||||
int idx, nr = 0;
|
||||
|
||||
/* Have to go right round from the back to ensure stuff ends up
|
||||
* LRU in our local list...
|
||||
*/
|
||||
for (idx = sarea->texList[heap][SAVAGE_NR_TEX_REGIONS].prev ;
|
||||
idx != SAVAGE_NR_TEX_REGIONS && nr < SAVAGE_NR_TEX_REGIONS ;
|
||||
idx = sarea->texList[heap][idx].prev, nr++)
|
||||
{
|
||||
if (sarea->texList[heap][idx].age > imesa->texAge[heap])
|
||||
{
|
||||
savageTexturesGone(imesa, heap ,idx * sz, sz,
|
||||
sarea->texList[heap][idx].in_use);
|
||||
}
|
||||
}
|
||||
|
||||
if (nr == SAVAGE_NR_TEX_REGIONS)
|
||||
{
|
||||
savageTexturesGone(imesa, heap, 0,
|
||||
imesa->savageScreen->textureSize[heap], 0);
|
||||
savageResetGlobalLRU( imesa , heap );
|
||||
}
|
||||
|
||||
imesa->dirty |= SAVAGE_UPLOAD_TEX0IMAGE;
|
||||
imesa->dirty |= SAVAGE_UPLOAD_TEX1IMAGE;
|
||||
imesa->texAge[heap] = sarea->texAge[heap];
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
if (dPriv->lastStamp != stamp)
|
||||
savageXMesaWindowMoved( imesa );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const struct __DriverAPIRec savageAPI = {
|
||||
savageInitDriver,
|
||||
savageDestroyScreen,
|
||||
savageCreateContext,
|
||||
savageDestroyContext,
|
||||
savageCreateBuffer,
|
||||
savageDestroyBuffer,
|
||||
savageSwapBuffers,
|
||||
savageMakeCurrent,
|
||||
savageUnbindContext,
|
||||
savageOpenFullScreen,
|
||||
savageCloseFullScreen
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This is the bootstrap function for the driver.
|
||||
* The __driCreateScreen name is the symbol that libGL.so fetches.
|
||||
* Return: pointer to a __DRIscreenPrivate.
|
||||
*/
|
||||
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
|
||||
int numConfigs, __GLXvisualConfig *config)
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &savageAPI);
|
||||
return (void *) psp;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
299
src/mesa/drivers/dri/savage/savagecontext.h
Normal file
299
src/mesa/drivers/dri/savage/savagecontext.h
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
/*
|
||||
* 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 <X11/Xlibint.h>
|
||||
#include "dri_util.h"
|
||||
#include "mtypes.h"
|
||||
#include "xf86drm.h"
|
||||
#include "drm.h"
|
||||
#include "savage_drm.h"
|
||||
#include "savage_sarea.h"
|
||||
#include "savage_init.h"
|
||||
#include "mm.h"
|
||||
|
||||
#include "savagetex.h"
|
||||
#include "savagedma.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_STIPPLE 0x10
|
||||
#define SAVAGE_FALLBACK_SPECULAR 0x20
|
||||
#define SAVAGE_FALLBACK_LOGICOP 0x40
|
||||
/*frank 2001/11/12 add the stencil fallbak*/
|
||||
#define SAVAGE_FALLBACK_STENCIL 0x80
|
||||
#define SAVAGE_FALLBACK_RENDERMODE 0x100
|
||||
#define SAVAGE_FALLBACK_BLEND_EQ 0x200
|
||||
|
||||
|
||||
#define HW_STENCIL 1
|
||||
#define HW_CULL 1
|
||||
|
||||
/* for savagectx.new_state - manage GL->driver state changes
|
||||
*/
|
||||
#define SAVAGE_NEW_TEXTURE 0x1
|
||||
|
||||
|
||||
/*define the max numer of vertex in vertex buf*/
|
||||
#define SAVAGE_MAX_VERTEXS 0x10000
|
||||
|
||||
/* 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_context_t {
|
||||
GLint refcount;
|
||||
|
||||
GLcontext *glCtx;
|
||||
|
||||
int lastTexHeap;
|
||||
savageTextureObjectPtr CurrentTexObj[2];
|
||||
|
||||
struct savage_texture_object_t TexObjList[SAVAGE_NR_TEX_HEAPS];
|
||||
struct savage_texture_object_t SwappedOut;
|
||||
|
||||
GLuint c_texupload;
|
||||
GLuint c_texusage;
|
||||
GLuint tex_thrash;
|
||||
|
||||
GLuint TextureMode;
|
||||
|
||||
|
||||
/* Hardware state
|
||||
*/
|
||||
|
||||
REGISTERS Registers;
|
||||
|
||||
/* Manage our own state */
|
||||
GLuint new_state;
|
||||
GLuint new_gl_state;
|
||||
|
||||
GLuint BCIBase;
|
||||
GLuint MMIO_BASE;
|
||||
|
||||
/* DMA command buffer */
|
||||
DMABuffer_t DMABuf;
|
||||
|
||||
/* aperture base */
|
||||
GLuint apertureBase[5];
|
||||
GLuint aperturePitch;
|
||||
/* Manage hardware state */
|
||||
GLuint dirty;
|
||||
memHeap_t *texHeap[SAVAGE_NR_TEX_HEAPS];
|
||||
GLuint bTexEn1;
|
||||
/* One of the few bits of hardware state that can't be calculated
|
||||
* completely on the fly:
|
||||
*/
|
||||
GLuint LcsCullMode;
|
||||
|
||||
/* Rasterization state
|
||||
*/
|
||||
GLuint SetupNewInputs;
|
||||
GLuint SetupIndex;
|
||||
GLuint RenderIndex;
|
||||
|
||||
GLuint hw_primitive;
|
||||
GLenum raster_primitive;
|
||||
GLenum render_primitive;
|
||||
|
||||
GLubyte *verts;
|
||||
GLuint vertex_format;
|
||||
GLuint vertex_size;
|
||||
GLuint DrawPrimitiveCmd;
|
||||
GLuint DrawPrimitiveMask;
|
||||
|
||||
/* 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 */
|
||||
drmBufPtr vertex_dma_buffer;
|
||||
|
||||
GLframebuffer *glBuffer;
|
||||
|
||||
/* Two flags to keep track of fallbacks. */
|
||||
GLuint Fallback;
|
||||
|
||||
GLuint needClip;
|
||||
|
||||
/* These refer to the current draw (front vs. back) buffer:
|
||||
*/
|
||||
char *drawMap; /* draw buffer address in virtual mem */
|
||||
char *readMap;
|
||||
int drawX; /* origin of drawable in draw buffer */
|
||||
int drawY;
|
||||
GLuint numClipRects; /* cliprects for that buffer */
|
||||
GLint currentClip;
|
||||
XF86DRIClipRectPtr pClipRects;
|
||||
|
||||
/* use this bit to support single/double buffer */
|
||||
GLuint IsDouble;
|
||||
/* use this to indicate Fullscreen mode */
|
||||
GLuint IsFullScreen;
|
||||
GLuint backup_frontOffset;
|
||||
GLuint backup_backOffset;
|
||||
GLuint backup_frontBitmapDesc;
|
||||
GLuint toggle;
|
||||
GLuint backup_streamFIFO;
|
||||
GLuint NotFirstFrame;
|
||||
|
||||
GLuint lastSwap;
|
||||
GLuint secondLastSwap;
|
||||
GLuint ctxAge;
|
||||
GLuint dirtyAge;
|
||||
GLuint any_contend; /* throttle me harder */
|
||||
|
||||
GLuint scissor;
|
||||
drm_clip_rect_t draw_rect;
|
||||
drm_clip_rect_t scissor_rect;
|
||||
XF86DRIClipRectRec tmp_boxes[2][SAVAGE_NR_SAREA_CLIPRECTS];
|
||||
/*Texture aging and DMA based aging*/
|
||||
unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
|
||||
|
||||
drmContext hHWContext;
|
||||
drmLock *driHwLock;
|
||||
GLuint driFd;
|
||||
|
||||
__DRIdrawablePrivate *driDrawable;
|
||||
__DRIdrawablePrivate *driReadable;
|
||||
|
||||
/**
|
||||
* Drawable used by Mesa for software fallbacks for reading and
|
||||
* writing. It is set by Mesa's \c SetBuffer callback, and will always be
|
||||
* either \c mga_context_t::driDrawable or \c mga_context_t::driReadable.
|
||||
*/
|
||||
__DRIdrawablePrivate *mesa_drawable;
|
||||
|
||||
__DRIscreenPrivate *driScreen;
|
||||
savageScreenPrivate *savageScreen;
|
||||
drm_savage_sarea_t *sarea;
|
||||
|
||||
GLboolean hw_stencil;
|
||||
|
||||
/*shadow pointer*/
|
||||
volatile GLuint *shadowPointer;
|
||||
volatile GLuint *eventTag1;
|
||||
GLuint shadowCounter;
|
||||
GLboolean shadowStatus;
|
||||
};
|
||||
|
||||
#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.
|
||||
*/
|
||||
#define SAVAGE_DEBUG 0
|
||||
#ifndef SAVAGE_DEBUG
|
||||
#warning "Debugging enabled - expect reduced performance"
|
||||
extern int SAVAGE_DEBUG;
|
||||
#endif
|
||||
|
||||
#define DEBUG_VERBOSE_2D 0x1
|
||||
#define DEBUG_VERBOSE_RING 0x8
|
||||
#define DEBUG_VERBOSE_OUTREG 0x10
|
||||
#define DEBUG_ALWAYS_SYNC 0x40
|
||||
#define DEBUG_VERBOSE_MSG 0x80
|
||||
#define DEBUG_NO_OUTRING 0x100
|
||||
#define DEBUG_NO_OUTREG 0x200
|
||||
#define DEBUG_VERBOSE_API 0x400
|
||||
#define DEBUG_VALIDATE_RING 0x800
|
||||
#define DEBUG_VERBOSE_LRU 0x1000
|
||||
#define DEBUG_VERBOSE_DRI 0x2000
|
||||
#define DEBUG_VERBOSE_IOCTL 0x4000
|
||||
|
||||
#define TARGET_FRONT 0x0
|
||||
#define TARGET_BACK 0x1
|
||||
#define TARGET_DEPTH 0x2
|
||||
|
||||
#define SAVAGEDEBUG 0
|
||||
#define _SAVAGE_DEBUG
|
||||
/*frank remove the least debug information*/
|
||||
#ifdef _SAVAGE_DEBUG
|
||||
#define fprintf fprintf
|
||||
#else
|
||||
#define fprintf(...)
|
||||
#endif
|
||||
|
||||
#define SUBPIXEL_X -0.5
|
||||
#define SUBPIXEL_Y -0.375
|
||||
|
||||
#endif
|
||||
106
src/mesa/drivers/dri/savage/savagedd.c
Normal file
106
src/mesa/drivers/dri/savage/savagedd.c
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* 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 "mtypes.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mm.h"
|
||||
#include "savagedd.h"
|
||||
#include "savagestate.h"
|
||||
#include "savagespan.h"
|
||||
#include "savagetex.h"
|
||||
#include "savagetris.h"
|
||||
#include "savagevb.h"
|
||||
#include "savagecontext.h"
|
||||
#include "extensions.h"
|
||||
|
||||
|
||||
extern int xf86VTSema;
|
||||
|
||||
|
||||
/***************************************
|
||||
* Mesa's Driver Functions
|
||||
***************************************/
|
||||
|
||||
|
||||
static const GLubyte *savageDDGetString( GLcontext *ctx, GLenum name )
|
||||
{
|
||||
switch (name) {
|
||||
case GL_VENDOR:
|
||||
return (GLubyte *)"S3 Graphics Inc.";
|
||||
case GL_RENDERER:
|
||||
return (GLubyte *)"Mesa DRI SAVAGE Linux_1.1.18";
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
static GLint savageGetParameteri(const GLcontext *ctx, GLint param)
|
||||
{
|
||||
switch (param) {
|
||||
case DD_HAVE_HARDWARE_FOG:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void savageBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
|
||||
/* Need to lock to make sure the driDrawable is uptodate. This
|
||||
* information is used to resize Mesa's software buffers, so it has
|
||||
* to be correct.
|
||||
*/
|
||||
LOCK_HARDWARE(imesa);
|
||||
*width = imesa->driDrawable->w;
|
||||
*height = imesa->driDrawable->h;
|
||||
UNLOCK_HARDWARE(imesa);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void savageDDExtensionsInit( GLcontext *ctx )
|
||||
{
|
||||
_mesa_enable_extension( ctx, "GL_ARB_multitexture" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void savageDDInitDriverFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.GetBufferSize = savageBufferSize;
|
||||
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
|
||||
ctx->Driver.GetString = savageDDGetString;
|
||||
}
|
||||
33
src/mesa/drivers/dri/savage/savagedd.h
Normal file
33
src/mesa/drivers/dri/savage/savagedd.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 "context.h"
|
||||
|
||||
void savageDDExtensionsInit( GLcontext *ctx );
|
||||
void savageDDInitDriverFuncs( GLcontext *ctx );
|
||||
#endif
|
||||
298
src/mesa/drivers/dri/savage/savagedma.c
Normal file
298
src/mesa/drivers/dri/savage/savagedma.c
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
/*
|
||||
* 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 <X11/Xlibint.h>
|
||||
#include <stdio.h>
|
||||
#include "savageioctl.h"
|
||||
#include "savagedma.h"
|
||||
#include "savage_bci.h"
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Commit does not depend on whether we use real DMA or fake it via the BCI */
|
||||
void savageDMACommit (savageContextPtr imesa, void *endPtr) {
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
GLuint end = (GLuint)endPtr;
|
||||
|
||||
/* make sure that enough space was allocated */
|
||||
assert (end <= dmaBuff->allocEnd);
|
||||
|
||||
dmaBuff->allocEnd = dmaBuff->end = end;
|
||||
|
||||
/* TODO: check commands, either here or in flush */
|
||||
}
|
||||
|
||||
#if SAVAGE_CMD_DMA
|
||||
/* flag =
|
||||
0 return -1 if no available page
|
||||
1 wait until a page be available */
|
||||
static GLuint getDMAPage (savageContextPtr imesa, int flag) {
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
GLuint page;
|
||||
GLuint eventTag1;
|
||||
|
||||
if (dmaBuff->kickFlag == GL_FALSE)
|
||||
return dmaBuff->usingPage;
|
||||
|
||||
page = dmaBuff->usingPage + 1;
|
||||
|
||||
/* overflow */
|
||||
if (page >= (dmaBuff->buf->size * dmaBuff->buf->type)/DMA_PAGE_SIZE)
|
||||
page = 0;
|
||||
|
||||
eventTag1 = GET_EVENTTAG;
|
||||
if ( eventTag1 == page) { /* is kicking off */
|
||||
if (flag == 1)
|
||||
while (GET_EVENTTAG == page); /* FIXME: add a max loop count? */
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ok, that's it */
|
||||
dmaBuff->usingPage = page;
|
||||
dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd =
|
||||
(dmaBuff->buf->linear + DMA_PAGE_SIZE * page);
|
||||
dmaBuff->kickFlag = GL_FALSE;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/* Allocate space in a real DMA buffer */
|
||||
void *savageDMAAlloc (savageContextPtr imesa, GLuint size) {
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
|
||||
/* make sure that everything has been filled in and committed */
|
||||
assert (dmaBuff->end == dmaBuff->allocEnd);
|
||||
|
||||
size *= sizeof (GLuint); /* size in bytes */
|
||||
if (dmaBuff->kickFlag == GL_TRUE) {
|
||||
if (size > DMA_PAGE_SIZE)
|
||||
return NULL;
|
||||
getDMAPage (imesa, 1);
|
||||
} else if (dmaBuff->end + size >=
|
||||
dmaBuff->buf->linear + DMA_PAGE_SIZE*(dmaBuff->usingPage+1)) {
|
||||
/* need kick off */
|
||||
savageDMAFlush (imesa);
|
||||
getDMAPage (imesa, 1);
|
||||
}
|
||||
dmaBuff->allocEnd = dmaBuff->end + size;
|
||||
return (void *)dmaBuff->end;
|
||||
}
|
||||
|
||||
/* Flush DMA buffer via DMA */
|
||||
void savageDMAFlush (savageContextPtr imesa) {
|
||||
volatile GLuint* BCIbase;
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
GLuint phyAddress;
|
||||
GLuint dmaCount, dmaCount1, remain;
|
||||
int i;
|
||||
|
||||
/* make sure that everything has been filled in and committed */
|
||||
assert (dmaBuff->allocEnd == dmaBuff->end);
|
||||
|
||||
if (dmaBuff->kickFlag == GL_TRUE) /* has been kicked off? */
|
||||
return;
|
||||
if (dmaBuff->start == dmaBuff->end) /* no command? */
|
||||
return;
|
||||
|
||||
/* get bci base */
|
||||
BCIbase = (volatile GLuint *)SAVAGE_GET_BCI_POINTER(imesa,4);
|
||||
|
||||
/* set the eventtag */
|
||||
*BCIbase = (dmaBuff->usingPage & 0xffffL) | (CMD_UpdateShadowStat << 27)
|
||||
| (1 << 22);
|
||||
*BCIbase = 0x96010051; /* set register x51*/
|
||||
/* set the DMA buffer address */
|
||||
phyAddress = (dmaBuff->buf->phyaddress + dmaBuff->usingPage*DMA_PAGE_SIZE)
|
||||
& MDT_SRCADD_ALIGMENT;
|
||||
if (dmaBuff->buf->location == DRM_SAVAGE_MEM_LOCATION_AGP)
|
||||
*BCIbase = (phyAddress) | MDT_SRC_AGP;
|
||||
else
|
||||
*BCIbase = (phyAddress) | MDT_SRC_PCI;
|
||||
|
||||
/* pad with noops to multiple of 32 bytes */
|
||||
dmaCount = (GLuint)(dmaBuff->end - dmaBuff->start);
|
||||
dmaCount1 = (dmaCount + 31UL) & ~31UL;
|
||||
remain = (dmaCount1 - dmaCount) >> 2;
|
||||
for (i = 0; i < remain; i++) {
|
||||
*((GLuint *)dmaBuff->end) = 0x40000000L;
|
||||
dmaBuff->end+=4;
|
||||
}
|
||||
dmaCount = (dmaCount1 >> 3) - 1;
|
||||
dmaBuff->allocEnd = dmaBuff->end;
|
||||
|
||||
/* kick off */
|
||||
*BCIbase = (0xA8000000L)|dmaCount;
|
||||
dmaBuff->kickFlag = GL_TRUE;
|
||||
}
|
||||
|
||||
/* Init real DMA */
|
||||
int savageDMAInit (savageContextPtr imesa)
|
||||
{
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
drm_savage_alloc_cont_mem_t * req;
|
||||
int i;
|
||||
long ret;
|
||||
|
||||
req = (drm_savage_alloc_cont_mem_t *)
|
||||
malloc (sizeof(drm_savage_alloc_cont_mem_t));
|
||||
if (!req)
|
||||
return GL_FALSE;
|
||||
|
||||
req->type = DRM_SAVAGE_MEM_PAGE;
|
||||
req->linear = 0;
|
||||
|
||||
/* try agp first */
|
||||
req->phyaddress = imesa->sarea->agp_offset;
|
||||
if (req->phyaddress) {
|
||||
if (drmMap (imesa->driFd,
|
||||
req->phyaddress,
|
||||
DRM_SAVAGE_DMA_AGP_SIZE,
|
||||
(drmAddressPtr)&req->linear) < 0) {
|
||||
fprintf (stderr, "AGP map error.\n");
|
||||
goto dma;
|
||||
}
|
||||
if (0) fprintf (stderr,"Using AGP dma|\n");
|
||||
req->location = DRM_SAVAGE_MEM_LOCATION_AGP;
|
||||
req->size = DRM_SAVAGE_DMA_AGP_SIZE/DRM_SAVAGE_MEM_PAGE;
|
||||
}
|
||||
|
||||
dma:
|
||||
if (!req->linear) {
|
||||
req->size = DMA_BUFFER_SIZE/DRM_SAVAGE_MEM_PAGE;
|
||||
for (i = 0; i < DMA_TRY_COUNT; i++) {
|
||||
if ((ret = savageAllocDMABuffer (imesa, req)) != 0)
|
||||
break;
|
||||
req->size = req->size/2;
|
||||
}
|
||||
|
||||
if (ret <= 0) {
|
||||
fprintf(stderr, "Can't alloc DMA memory(system and agp)\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
req->location = DRM_SAVAGE_MEM_LOCATION_PCI;
|
||||
}
|
||||
|
||||
dmaBuff->buf = req;
|
||||
|
||||
dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd = req->linear;
|
||||
dmaBuff->usingPage = 0;
|
||||
dmaBuff->kickFlag = GL_FALSE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Close real DMA */
|
||||
int savageDMAClose (savageContextPtr imesa)
|
||||
{
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
drm_savage_alloc_cont_mem_t * req = dmaBuff->buf;
|
||||
|
||||
if(req->location == DRM_SAVAGE_MEM_LOCATION_PCI)
|
||||
savageFreeDMABuffer (imesa, req);
|
||||
else { /* AGP memory */
|
||||
drmUnmap ((drmAddress)req->linear, req->size*req->type);
|
||||
drmRmMap (imesa->driFd, req->phyaddress);
|
||||
}
|
||||
free (req);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
#else
|
||||
/* Allocate space in faked DMA buffer */
|
||||
void *savageDMAAlloc (savageContextPtr imesa, GLuint size) {
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
|
||||
/* make sure that everything has been filled in and committed */
|
||||
assert (dmaBuff->end == dmaBuff->allocEnd);
|
||||
|
||||
size *= sizeof (GLuint); /* size in bytes */
|
||||
if (dmaBuff->end + size >= dmaBuff->buf->linear + DMA_PAGE_SIZE) {
|
||||
/* need kick off */
|
||||
savageDMAFlush (imesa);
|
||||
}
|
||||
dmaBuff->allocEnd = dmaBuff->end + size;
|
||||
return (void *)dmaBuff->end;
|
||||
}
|
||||
|
||||
/* Flush DMA buffer via BCI (faked DMA) */
|
||||
void savageDMAFlush(savageContextPtr imesa) {
|
||||
volatile GLuint* BCIbase;
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
GLuint *entry;
|
||||
|
||||
/* make sure that everything has been filled in and committed */
|
||||
assert (dmaBuff->allocEnd == dmaBuff->end);
|
||||
|
||||
if (dmaBuff->start == dmaBuff->end) /* no command? */
|
||||
return;
|
||||
|
||||
/* get bci base */
|
||||
BCIbase = (volatile GLuint *)SAVAGE_GET_BCI_POINTER(
|
||||
imesa, (dmaBuff->end - dmaBuff->start) / sizeof (GLuint));
|
||||
|
||||
for (entry = (GLuint *)dmaBuff->start;
|
||||
entry < (GLuint *)dmaBuff->end; ++entry)
|
||||
*BCIbase = *entry;
|
||||
|
||||
dmaBuff->end = dmaBuff->allocEnd = dmaBuff->start;
|
||||
}
|
||||
|
||||
/* Init faked DMA */
|
||||
int savageDMAInit (savageContextPtr imesa) {
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
drm_savage_alloc_cont_mem_t * req;
|
||||
|
||||
req = (drm_savage_alloc_cont_mem_t *)
|
||||
malloc (sizeof(drm_savage_alloc_cont_mem_t));
|
||||
if (!req)
|
||||
return GL_FALSE;
|
||||
|
||||
req->linear = (GLuint)malloc (DMA_PAGE_SIZE);
|
||||
if (!req->linear) {
|
||||
free (req);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
dmaBuff->buf = req;
|
||||
|
||||
dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd = req->linear;
|
||||
dmaBuff->usingPage = 0;
|
||||
dmaBuff->kickFlag = GL_FALSE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Close faked DMA */
|
||||
int savageDMAClose (savageContextPtr imesa) {
|
||||
DMABufferPtr dmaBuff = &imesa->DMABuf;
|
||||
drm_savage_alloc_cont_mem_t * req = dmaBuff->buf;
|
||||
|
||||
free ((void *)req->linear);
|
||||
free (req);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
50
src/mesa/drivers/dri/savage/savagedma.h
Normal file
50
src/mesa/drivers/dri/savage/savagedma.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 SAVAGEDMA
|
||||
#define SAVAGEDMA
|
||||
|
||||
/* Whether use DMA to transfer the 3d commands and data */
|
||||
#define SAVAGE_CMD_DMA 0
|
||||
|
||||
#define DMA_BUFFER_SIZE (4*1024*1024) /*4M*/
|
||||
#define MAX_DMA_BUFFER_SIZE (16*1024*1024)
|
||||
#define DMA_PAGE_SIZE (4*1024) /* savage4 , twister, prosavage,...*/
|
||||
#define DMA_TRY_COUNT 4
|
||||
|
||||
#define MAX_SHADOWCOUNTER (MAX_DMA_BUFFER_SIZE / DMA_PAGE_SIZE)
|
||||
typedef struct DMABuffer{
|
||||
drm_savage_alloc_cont_mem_t * buf;
|
||||
GLuint start, end, allocEnd;
|
||||
GLuint usingPage; /*current page */
|
||||
unsigned int kickFlag; /* usingPage is kicked off ?*/
|
||||
} DMABuffer_t, * DMABufferPtr;
|
||||
|
||||
void *savageDMAAlloc (savageContextPtr imesa, GLuint size);
|
||||
void savageDMACommit (savageContextPtr imesa, void *end);
|
||||
void savageDMAFlush (savageContextPtr imesa);
|
||||
int savageDMAInit (savageContextPtr imesa);
|
||||
int savageDMAClose (savageContextPtr);
|
||||
#endif
|
||||
521
src/mesa/drivers/dri/savage/savageioctl.c
Normal file
521
src/mesa/drivers/dri/savage/savageioctl.c
Normal file
|
|
@ -0,0 +1,521 @@
|
|||
/*
|
||||
* 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 "mtypes.h"
|
||||
#include "macros.h"
|
||||
#include "dd.h"
|
||||
#include "context.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "mm.h"
|
||||
#include "savagecontext.h"
|
||||
#include "savageioctl.h"
|
||||
#include "savage_bci.h"
|
||||
#include "savagedma.h"
|
||||
|
||||
#include "drm.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
extern GLuint bcicount;
|
||||
#define DEPTH_SCALE_16 ((1<<16)-1)
|
||||
#define DEPTH_SCALE_24 ((1<<24)-1)
|
||||
|
||||
static void savage_BCI_clear(GLcontext *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+1;
|
||||
unsigned int height = pbox->y2 - y+1;
|
||||
unsigned int *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) && imesa->IsFullScreen) {
|
||||
bciptr = savageDMAAlloc (imesa, 8);
|
||||
WRITE_CMD((bciptr) , 0x4BCC8C00,GLuint);
|
||||
WRITE_CMD((bciptr) , imesa->savageScreen->frontOffset,GLuint);
|
||||
WRITE_CMD((bciptr) , imesa->savageScreen->frontBitmapDesc,GLuint);
|
||||
WRITE_CMD((bciptr) , pclear->clear_color,GLuint);
|
||||
WRITE_CMD((bciptr) , (y <<16) | x,GLuint);
|
||||
WRITE_CMD((bciptr) , (height << 16) | width,GLuint);
|
||||
savageDMACommit (imesa, bciptr);
|
||||
}
|
||||
else if ( pclear->flags & (SAVAGE_BACK|SAVAGE_FRONT) ) {
|
||||
bciptr = savageDMAAlloc (imesa, 8);
|
||||
WRITE_CMD((bciptr) , 0x4BCC8C00,GLuint);
|
||||
WRITE_CMD((bciptr) , imesa->savageScreen->backOffset,GLuint);
|
||||
WRITE_CMD((bciptr) , imesa->savageScreen->backBitmapDesc,GLuint);
|
||||
WRITE_CMD((bciptr) , pclear->clear_color,GLuint);
|
||||
WRITE_CMD((bciptr) , (y <<16) | x,GLuint);
|
||||
WRITE_CMD((bciptr) , (height << 16) | width,GLuint);
|
||||
savageDMACommit (imesa, bciptr);
|
||||
}
|
||||
|
||||
if ( pclear->flags & (SAVAGE_DEPTH |SAVAGE_STENCIL) ) {
|
||||
GLuint writeMask = 0x0;
|
||||
#if HW_STENCIL
|
||||
if(imesa->hw_stencil)
|
||||
{
|
||||
if(pclear->flags & SAVAGE_STENCIL)
|
||||
{
|
||||
|
||||
writeMask |= 0xFF000000;
|
||||
}
|
||||
if(pclear->flags & SAVAGE_DEPTH)
|
||||
{
|
||||
writeMask |= 0x00FFFFFF;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(imesa->IsFullScreen && imesa->NotFirstFrame &&
|
||||
imesa->savageScreen->chipset >= S3_SAVAGE4)
|
||||
{
|
||||
imesa->Registers.ZBufCtrl.s4.autoZEnable = GL_TRUE;
|
||||
imesa->Registers.ZBufCtrl.s4.frameID = ~imesa->Registers.ZBufCtrl.s4.frameID;
|
||||
|
||||
imesa->dirty |= SAVAGE_UPLOAD_CTX;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(imesa->IsFullScreen)
|
||||
imesa->NotFirstFrame = GL_TRUE;
|
||||
|
||||
#if HW_STENCIL
|
||||
if(imesa->hw_stencil)
|
||||
{
|
||||
bciptr = savageDMAAlloc (imesa, 10);
|
||||
if(writeMask != 0xFFFFFFFF)
|
||||
{
|
||||
WRITE_CMD((bciptr) , 0x960100D7,GLuint);
|
||||
WRITE_CMD((bciptr) , writeMask,GLuint);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
bciptr = savageDMAAlloc (imesa, 6);
|
||||
}
|
||||
|
||||
WRITE_CMD((bciptr) , 0x4BCC8C00,GLuint);
|
||||
WRITE_CMD((bciptr) , imesa->savageScreen->depthOffset,GLuint);
|
||||
WRITE_CMD((bciptr) , imesa->savageScreen->depthBitmapDesc,GLuint);
|
||||
WRITE_CMD((bciptr) , pclear->clear_depth,GLuint);
|
||||
WRITE_CMD((bciptr) , (y <<16) | x,GLuint);
|
||||
WRITE_CMD((bciptr) , (height << 16) | width,GLuint);
|
||||
#if HW_STENCIL
|
||||
if(imesa->hw_stencil)
|
||||
{
|
||||
if(writeMask != 0xFFFFFFFF)
|
||||
{
|
||||
WRITE_CMD((bciptr) , 0x960100D7,GLuint);
|
||||
WRITE_CMD((bciptr) , 0xFFFFFFFF,GLuint);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
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);
|
||||
}
|
||||
|
||||
struct timeb a,b;
|
||||
|
||||
static void savage_BCI_swap(savageContextPtr imesa)
|
||||
{
|
||||
int nbox = imesa->sarea->nbox;
|
||||
drm_clip_rect_t *pbox = imesa->sarea->boxes;
|
||||
int i;
|
||||
volatile unsigned int *bciptr;
|
||||
|
||||
if (nbox > SAVAGE_NR_SAREA_CLIPRECTS)
|
||||
nbox = SAVAGE_NR_SAREA_CLIPRECTS;
|
||||
savageDMAFlush (imesa);
|
||||
WAIT_IDLE_EMPTY;
|
||||
|
||||
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;
|
||||
|
||||
imesa->drawMap = (char *)imesa->apertureBase[imesa->toggle];
|
||||
imesa->readMap = (char *)imesa->apertureBase[imesa->toggle];
|
||||
|
||||
imesa->Registers.DestCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
|
||||
imesa->Registers.changed.ni.fDestCtrlChanged = GL_TRUE;
|
||||
imesa->dirty |= SAVAGE_UPLOAD_CTX;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
GLint cx, GLint cy, GLint cw, GLint ch )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
|
||||
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
|
||||
drm_savage_clear_t clear;
|
||||
int i;
|
||||
|
||||
clear.flags = 0;
|
||||
clear.clear_color = imesa->ClearColor;
|
||||
|
||||
if(imesa->savageScreen->zpp == 2)
|
||||
clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_16);
|
||||
else
|
||||
clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_24);
|
||||
#if 0
|
||||
FLUSH_BATCH( imesa );
|
||||
#endif
|
||||
if ((mask & DD_FRONT_LEFT_BIT) && ((colorMask&0xffffffUL)==0xffffffUL) ){
|
||||
clear.flags |= SAVAGE_FRONT;
|
||||
mask &= ~DD_FRONT_LEFT_BIT;
|
||||
}
|
||||
|
||||
if ((mask & DD_BACK_LEFT_BIT) && ((colorMask&0xffffffUL)==0xffffffUL) ) {
|
||||
clear.flags |= SAVAGE_BACK;
|
||||
mask &= ~DD_BACK_LEFT_BIT;
|
||||
}
|
||||
|
||||
if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
|
||||
clear.flags |= SAVAGE_DEPTH;
|
||||
mask &= ~DD_DEPTH_BIT;
|
||||
}
|
||||
|
||||
if((mask & DD_STENCIL_BIT) && imesa->hw_stencil)
|
||||
{
|
||||
clear.flags |= SAVAGE_STENCIL;
|
||||
mask &= ~DD_STENCIL_BIT;
|
||||
}
|
||||
|
||||
if (clear.flags) {
|
||||
LOCK_HARDWARE( imesa );
|
||||
|
||||
/* flip top to bottom */
|
||||
cy = dPriv->h-cy-ch;
|
||||
cx += imesa->drawX;
|
||||
cy += imesa->drawY;
|
||||
|
||||
for (i = 0 ; i < imesa->numClipRects ; ) {
|
||||
int nr = MIN2(i + SAVAGE_NR_SAREA_CLIPRECTS, imesa->numClipRects);
|
||||
XF86DRIClipRectRec *box = imesa->pClipRects;
|
||||
drm_clip_rect_t *b = imesa->sarea->boxes;
|
||||
int n = 0;
|
||||
|
||||
if (!all) {
|
||||
for ( ; i < nr ; i++) {
|
||||
GLint x = box[i].x1;
|
||||
GLint y = box[i].y1;
|
||||
GLint w = box[i].x2 - x;
|
||||
GLint h = box[i].y2 - y;
|
||||
|
||||
if (x < cx) w -= cx - x, x = cx;
|
||||
if (y < cy) h -= cy - y, y = cy;
|
||||
if (x + w > cx + cw) w = cx + cw - x;
|
||||
if (y + h > cy + ch) h = cy + ch - y;
|
||||
if (w <= 0) continue;
|
||||
if (h <= 0) continue;
|
||||
|
||||
b->x1 = x;
|
||||
b->y1 = y;
|
||||
b->x2 = x + w;
|
||||
b->y2 = y + h;
|
||||
b++;
|
||||
n++;
|
||||
}
|
||||
} else {
|
||||
for ( ; i < nr ; i++) {
|
||||
*b++ = *(drm_clip_rect_t *)&box[i];
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
imesa->sarea->nbox = n;
|
||||
|
||||
savage_BCI_clear(ctx,&clear);
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE( imesa );
|
||||
imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS|SAVAGE_UPLOAD_CTX;
|
||||
}
|
||||
|
||||
if (mask)
|
||||
_swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copy the back buffer to the front buffer.
|
||||
*/
|
||||
void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
|
||||
{
|
||||
savageContextPtr imesa;
|
||||
XF86DRIClipRectPtr pbox;
|
||||
int nbox;
|
||||
int i;
|
||||
|
||||
GLboolean pending;
|
||||
|
||||
assert(dPriv);
|
||||
assert(dPriv->driContextPriv);
|
||||
assert(dPriv->driContextPriv->driverPrivate);
|
||||
|
||||
imesa = (savageContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
if (imesa->IsDouble)
|
||||
_mesa_notifySwapBuffers( imesa->glCtx );
|
||||
|
||||
LOCK_HARDWARE( imesa );
|
||||
PAGE_PENDING(pending);
|
||||
|
||||
if(!pending)
|
||||
{
|
||||
pbox = dPriv->pClipRects;
|
||||
nbox = dPriv->numClipRects;
|
||||
|
||||
for (i = 0 ; i < nbox ; )
|
||||
{
|
||||
int nr = MIN2(i + SAVAGE_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
|
||||
XF86DRIClipRectRec *b = (XF86DRIClipRectRec *)imesa->sarea->boxes;
|
||||
|
||||
imesa->sarea->nbox = nr - i;
|
||||
|
||||
for ( ; i < nr ; i++)
|
||||
*b++ = pbox[i];
|
||||
savage_BCI_swap(imesa) ;
|
||||
}
|
||||
}
|
||||
UNLOCK_HARDWARE( imesa );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* This waits for *everybody* to finish rendering -- overkill.
|
||||
*/
|
||||
void savageDmaFinish( savageContextPtr imesa )
|
||||
{
|
||||
savageDMAFlush(imesa);
|
||||
WAIT_IDLE_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
void savageRegetLockQuiescent( savageContextPtr imesa )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void savageWaitAgeLocked( savageContextPtr imesa, int age )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void savageWaitAge( savageContextPtr imesa, int age )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void savageFlushVertices( savageContextPtr imesa )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void savageFlushVerticesLocked( savageContextPtr imesa )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
int savage_check_copy(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void savageDDFlush( GLcontext *ctx )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void savageDDFinish( GLcontext *ctx )
|
||||
{
|
||||
}
|
||||
|
||||
#define ALT_STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c60))
|
||||
#define STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c00))
|
||||
#define MAXFIFO_S4 0x1FF00
|
||||
#define MAXFIFO_S3D 0x7F00
|
||||
|
||||
static GLboolean savagePagePending_s4( savageContextPtr imesa ) {
|
||||
return (ALT_STATUS_WORD0 & 0x08000000) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
static GLboolean savagePagePending_s3d( savageContextPtr imesa ) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
static void savageWaitForFIFO_s4( savageContextPtr imesa, unsigned count ) {
|
||||
int loop = 0;
|
||||
int slots = MAXFIFO_S4-count;
|
||||
while((ALT_STATUS_WORD0 & 0x001fffff) > slots && loop++ < MAXLOOP);
|
||||
}
|
||||
static void savageWaitForFIFO_s3d( savageContextPtr imesa, unsigned count ) {
|
||||
int loop = 0;
|
||||
int slots = MAXFIFO_S3D-count;
|
||||
while((STATUS_WORD0 & 0x0001ffff) > slots && loop++ < MAXLOOP);
|
||||
}
|
||||
static void savageWaitIdleEmpty_s4( savageContextPtr imesa ) {
|
||||
int loop = 0;
|
||||
while((ALT_STATUS_WORD0 & 0x00ffffff) != 0x00E00000L && loop++ < MAXLOOP);
|
||||
}
|
||||
static void savageWaitIdleEmpty_s3d( savageContextPtr imesa ) {
|
||||
int loop = 0;
|
||||
while((STATUS_WORD0 & 0x000fffff) != 0x000E0000L && loop++ < MAXLOOP);
|
||||
}
|
||||
|
||||
GLboolean (*savagePagePending)( savageContextPtr imesa ) = NULL;
|
||||
void (*savageWaitForFIFO)( savageContextPtr imesa, unsigned count ) = NULL;
|
||||
void (*savageWaitIdleEmpty)( savageContextPtr imesa ) = NULL;
|
||||
|
||||
|
||||
void savageDDInitIoctlFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.Clear = savageDDClear;
|
||||
ctx->Driver.Flush = savageDDFlush;
|
||||
ctx->Driver.Finish = savageDDFinish;
|
||||
if (SAVAGE_CONTEXT( ctx )->savageScreen->chipset >= S3_SAVAGE4) {
|
||||
savagePagePending = savagePagePending_s4;
|
||||
savageWaitForFIFO = savageWaitForFIFO_s4;
|
||||
savageWaitIdleEmpty = savageWaitIdleEmpty_s4;
|
||||
} else {
|
||||
savagePagePending = savagePagePending_s3d;
|
||||
savageWaitForFIFO = savageWaitForFIFO_s3d;
|
||||
savageWaitIdleEmpty = savageWaitIdleEmpty_s3d;
|
||||
}
|
||||
}
|
||||
|
||||
#if SAVAGE_CMD_DMA
|
||||
/* Alloc a continuous memory */
|
||||
/* return: 0 error when kernel alloc pages(can try a half memory size)
|
||||
>0 sucess
|
||||
<0 Other error*/
|
||||
int savageAllocDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req)
|
||||
{
|
||||
int ret;
|
||||
if (req ==NULL)
|
||||
return 0;
|
||||
|
||||
if ((ret=ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_ALLOC_CONTINUOUS_MEM, req)) <=0)
|
||||
return ret;
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/* get the physics address*/
|
||||
GLuint savageGetPhyAddress(savageContextPtr imesa,void * pointer)
|
||||
{
|
||||
|
||||
drm_savage_get_physcis_address_t req;
|
||||
int ret;
|
||||
|
||||
req.v_address = (GLuint )pointer;
|
||||
ret = ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_GET_PHYSICS_ADDRESS,&req);
|
||||
|
||||
return req.p_address;
|
||||
}
|
||||
|
||||
/* free the buffer got by savageAllocDMABuffe*/
|
||||
int savageFreeDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req)
|
||||
{
|
||||
GLuint ret;
|
||||
if (req ==NULL)
|
||||
return 0;
|
||||
|
||||
if ((ret=ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_FREE_CONTINUOUS_MEM, req)) <=0)
|
||||
return ret;
|
||||
return 1;
|
||||
|
||||
}
|
||||
#endif
|
||||
72
src/mesa/drivers/dri/savage/savageioctl.h
Normal file
72
src/mesa/drivers/dri/savage/savageioctl.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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"
|
||||
#include "savagedma.h"
|
||||
|
||||
void savageGetGeneralDmaBufferLocked( savageContextPtr mmesa );
|
||||
|
||||
void savageFlushVertices( savageContextPtr mmesa );
|
||||
void savageFlushVerticesLocked( savageContextPtr mmesa );
|
||||
|
||||
void savageFlushGeneralLocked( savageContextPtr imesa );
|
||||
void savageWaitAgeLocked( savageContextPtr imesa, int age );
|
||||
void savageWaitAge( savageContextPtr imesa, int age );
|
||||
|
||||
void savageDmaFinish( savageContextPtr imesa );
|
||||
|
||||
void savageRegetLockQuiescent( savageContextPtr imesa );
|
||||
|
||||
void savageDDInitIoctlFuncs( GLcontext *ctx );
|
||||
|
||||
void savageSwapBuffers( __DRIdrawablePrivate *dPriv );
|
||||
|
||||
int savage_check_copy(int fd);
|
||||
|
||||
extern GLboolean (*savagePagePending)( savageContextPtr imesa );
|
||||
extern void (*savageWaitForFIFO)( savageContextPtr imesa, unsigned count );
|
||||
extern void (*savageWaitIdleEmpty)( savageContextPtr imesa );
|
||||
|
||||
#define PAGE_PENDING(result) do { \
|
||||
result = savagePagePending(imesa); \
|
||||
} while (0)
|
||||
#define WAIT_FOR_FIFO(count) do { \
|
||||
savageWaitForFIFO(imesa, count); \
|
||||
} while (0)
|
||||
#define WAIT_IDLE_EMPTY do { \
|
||||
savageWaitIdleEmpty(imesa); \
|
||||
} while (0)
|
||||
|
||||
#if SAVAGE_CMD_DMA
|
||||
int savageAllocDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req);
|
||||
GLuint savageGetPhyAddress(savageContextPtr imesa,void * pointer);
|
||||
int savageFreeDMABuffer(savageContextPtr, drm_savage_alloc_cont_mem_t*);
|
||||
#endif
|
||||
|
||||
#define FLUSH_BATCH(imesa) savageDMAFlush(imesa)
|
||||
#endif
|
||||
313
src/mesa/drivers/dri/savage/savagespan.c
Normal file
313
src/mesa/drivers/dri/savage/savagespan.c
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
* 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 "mtypes.h"
|
||||
#include "savagedd.h"
|
||||
#include "savagespan.h"
|
||||
#include "savageioctl.h"
|
||||
#include "savage_bci.h"
|
||||
#include "savage_3d_reg.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define DBG 0
|
||||
|
||||
#define LOCAL_VARS \
|
||||
__DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
|
||||
savageScreenPrivate *savageScreen = imesa->savageScreen; \
|
||||
GLuint cpp = savageScreen->cpp; \
|
||||
GLuint pitch = imesa->aperturePitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(imesa->drawMap + \
|
||||
dPriv->x * cpp + \
|
||||
dPriv->y * pitch); \
|
||||
char *read_buf = (char *)(imesa->readMap + \
|
||||
dPriv->x * cpp + \
|
||||
dPriv->y * pitch); \
|
||||
GLuint p = SAVAGE_CONTEXT( ctx )->MonoColor; \
|
||||
(void) read_buf; (void) buf; (void) p
|
||||
|
||||
#define LOCAL_DEPTH_VARS \
|
||||
__DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
|
||||
savageScreenPrivate *savageScreen = imesa->savageScreen; \
|
||||
GLuint zpp = savageScreen->zpp; \
|
||||
GLuint pitch = imesa->aperturePitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(imesa->apertureBase[TARGET_DEPTH] + \
|
||||
dPriv->x * zpp + \
|
||||
dPriv->y * pitch)
|
||||
|
||||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
|
||||
|
||||
#define INIT_MONO_PIXEL(p)
|
||||
|
||||
#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
|
||||
_y >= miny && _y < maxy)
|
||||
|
||||
|
||||
#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
|
||||
if ( _y < miny || _y >= maxy ) { \
|
||||
_n1 = 0, _x1 = x; \
|
||||
} else { \
|
||||
_n1 = _n; \
|
||||
_x1 = _x; \
|
||||
if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
|
||||
if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
|
||||
}
|
||||
|
||||
#define Y_FLIP(_y) (height - _y - 1)
|
||||
|
||||
#define HW_LOCK() savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
|
||||
WAIT_IDLE_EMPTY;\
|
||||
|
||||
#define HW_CLIPLOOP() \
|
||||
do { \
|
||||
__DRIdrawablePrivate *dPriv = imesa->driDrawable; \
|
||||
int _nc = dPriv->numClipRects; \
|
||||
while (_nc--) { \
|
||||
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
|
||||
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
|
||||
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
|
||||
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
|
||||
|
||||
|
||||
#define HW_ENDCLIPLOOP() \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if 0
|
||||
#define HW_UNLOCK() \
|
||||
UNLOCK_HARDWARE(imesa);
|
||||
#endif
|
||||
#define HW_UNLOCK() { }
|
||||
|
||||
|
||||
/* 16 bit, 565 rgb color spanline and pixel functions
|
||||
*/
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = SAVAGEPACKCOLOR565( color[0], color[1], color[2] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
do{ \
|
||||
*(GLushort *)(buf + (_x<<1) + _y*pitch) = ( (((int)r & 0xf8) << 8) |\
|
||||
(((int)g & 0xfc) << 3) | \
|
||||
(((int)b & 0xf8) >> 3)); \
|
||||
}while(0)
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
do{ \
|
||||
*(GLushort *)(buf + (_x<<1) + _y*pitch) = p; \
|
||||
}while(0)
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLushort p = *(GLushort *)(read_buf + (_x<<1) + _y*pitch); \
|
||||
rgba[0] = (((p >> 11) & 0x1f) * 255) >>5; \
|
||||
rgba[1] = (((p >> 5) & 0x3f) * 255) >>6; \
|
||||
rgba[2] = (((p >> 0) & 0x1f) * 255) >>5; \
|
||||
rgba[3] = 255; \
|
||||
} while(0)
|
||||
|
||||
#define TAG(x) savage##x##_565
|
||||
#include "spantmp.h"
|
||||
|
||||
|
||||
/* 32 bit, 8888 ARGB color spanline and pixel functions
|
||||
*/
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = SAVAGEPACKCOLOR8888( color[0], color[1], color[2], color[3] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLuint *)(buf + (_x<<2) + _y*pitch) = ( ((GLuint)a << 24) | \
|
||||
((GLuint)r << 16) | \
|
||||
((GLuint)g << 8) | \
|
||||
((GLuint)b ))
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLuint *)(buf + (_x<<2) + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLuint p = *(GLuint *)(read_buf + (_x<<2) + _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) savage##x##_8888
|
||||
#include "spantmp.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
do{ \
|
||||
*(GLushort *)(buf + (_x<<1) + _y*pitch) = d; \
|
||||
}while(0)
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
do{ \
|
||||
d = *(GLushort *)(buf + (_x<<1) + _y*pitch); \
|
||||
}while(0)
|
||||
|
||||
/* d = 0xffff; */
|
||||
|
||||
#define TAG(x) savage##x##_16
|
||||
#include "depthtmp.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* 8-bit stencil /24-bit depth depthbuffer functions.
|
||||
*/
|
||||
#define WRITE_DEPTH( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + (_x<<2) + _y*pitch); \
|
||||
tmp &= 0xFF000000; \
|
||||
tmp |= d; \
|
||||
*(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + (_x<<2) + _y*pitch) & 0x00FFFFFF;
|
||||
|
||||
/* d = 0x00ffffff; */
|
||||
|
||||
#define TAG(x) savage##x##_8_24
|
||||
#include "depthtmp.h"
|
||||
|
||||
|
||||
#define WRITE_STENCIL( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + (_x<<2) + _y*pitch); \
|
||||
tmp &= 0x00FFFFFF; \
|
||||
tmp |= (((GLuint)d)<<24) & 0xFF000000; \
|
||||
*(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_STENCIL( d, _x, _y ) \
|
||||
d = (GLstencil)((*(GLuint *)(buf + (_x<<2) + _y*pitch) & 0xFF000000) >> 24);
|
||||
|
||||
#define TAG(x) savage##x##_8_24
|
||||
#include "stenciltmp.h"
|
||||
|
||||
|
||||
/*
|
||||
* This function is called to specify which buffer to read and write
|
||||
* for software rasterization (swrast) fallbacks. This doesn't necessarily
|
||||
* correspond to glDrawBuffer() or glReadBuffer() calls.
|
||||
*/
|
||||
static void savageDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
|
||||
GLuint bufferBit)
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
char *map;
|
||||
|
||||
assert( (bufferBit == FRONT_LEFT_BIT) || (bufferBit == BACK_LEFT_BIT) );
|
||||
|
||||
map = (bufferBit == FRONT_LEFT_BIT)
|
||||
? (char*)imesa->apertureBase[TARGET_FRONT]
|
||||
: (char*)imesa->apertureBase[TARGET_BACK];
|
||||
|
||||
imesa->drawMap = map;
|
||||
imesa->readMap = map;
|
||||
|
||||
assert( (buffer == imesa->driDrawable->driverPrivate)
|
||||
|| (buffer == imesa->driReadable->driverPrivate) );
|
||||
|
||||
imesa->mesa_drawable = (buffer == imesa->driDrawable->driverPrivate)
|
||||
? imesa->driDrawable : imesa->driReadable;
|
||||
}
|
||||
|
||||
|
||||
void savageDDInitSpanFuncs( GLcontext *ctx )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
|
||||
|
||||
swdd->SetBuffer = savageDDSetBuffer;
|
||||
|
||||
switch (imesa->savageScreen->cpp)
|
||||
{
|
||||
case 2:
|
||||
swdd->WriteRGBASpan = savageWriteRGBASpan_565;
|
||||
swdd->WriteRGBSpan = savageWriteRGBSpan_565;
|
||||
swdd->WriteMonoRGBASpan = savageWriteMonoRGBASpan_565;
|
||||
swdd->WriteRGBAPixels = savageWriteRGBAPixels_565;
|
||||
swdd->WriteMonoRGBAPixels = savageWriteMonoRGBAPixels_565;
|
||||
swdd->ReadRGBASpan = savageReadRGBASpan_565;
|
||||
swdd->ReadRGBAPixels = savageReadRGBAPixels_565;
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
swdd->WriteRGBASpan = savageWriteRGBASpan_8888;
|
||||
swdd->WriteRGBSpan = savageWriteRGBSpan_8888;
|
||||
swdd->WriteMonoRGBASpan = savageWriteMonoRGBASpan_8888;
|
||||
swdd->WriteRGBAPixels = savageWriteRGBAPixels_8888;
|
||||
swdd->WriteMonoRGBAPixels = savageWriteMonoRGBAPixels_8888;
|
||||
swdd->ReadRGBASpan = savageReadRGBASpan_8888;
|
||||
swdd->ReadRGBAPixels = savageReadRGBAPixels_8888;
|
||||
}
|
||||
|
||||
switch (imesa->savageScreen->zpp)
|
||||
{
|
||||
case 2:
|
||||
swdd->ReadDepthSpan = savageReadDepthSpan_16;
|
||||
swdd->WriteDepthSpan = savageWriteDepthSpan_16;
|
||||
swdd->ReadDepthPixels = savageReadDepthPixels_16;
|
||||
swdd->WriteDepthPixels = savageWriteDepthPixels_16;
|
||||
|
||||
break;
|
||||
case 4:
|
||||
swdd->ReadDepthSpan = savageReadDepthSpan_8_24;
|
||||
swdd->WriteDepthSpan = savageWriteDepthSpan_8_24;
|
||||
swdd->ReadDepthPixels = savageReadDepthPixels_8_24;
|
||||
swdd->WriteDepthPixels = savageWriteDepthPixels_8_24;
|
||||
#if HW_STENCIL
|
||||
swdd->ReadStencilSpan = savageReadStencilSpan_8_24;
|
||||
swdd->WriteStencilSpan = savageWriteStencilSpan_8_24;
|
||||
swdd->ReadStencilPixels = savageReadStencilPixels_8_24;
|
||||
swdd->WriteStencilPixels = savageWriteStencilPixels_8_24;
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
swdd->WriteCI8Span =NULL;
|
||||
swdd->WriteCI32Span =NULL;
|
||||
swdd->WriteMonoCISpan =NULL;
|
||||
swdd->WriteCI32Pixels =NULL;
|
||||
swdd->WriteMonoCIPixels =NULL;
|
||||
swdd->ReadCI32Span =NULL;
|
||||
swdd->ReadCI32Pixels =NULL;
|
||||
|
||||
/* Pixel path fallbacks.
|
||||
*/
|
||||
ctx->Driver.Accum = _swrast_Accum;
|
||||
ctx->Driver.Bitmap = _swrast_Bitmap;
|
||||
ctx->Driver.CopyPixels = _swrast_CopyPixels;
|
||||
ctx->Driver.DrawPixels = _swrast_DrawPixels;
|
||||
ctx->Driver.ReadPixels = _swrast_ReadPixels;
|
||||
}
|
||||
30
src/mesa/drivers/dri/savage/savagespan.h
Normal file
30
src/mesa/drivers/dri/savage/savagespan.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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
|
||||
|
||||
extern void savageDDInitSpanFuncs( GLcontext *ctx );
|
||||
|
||||
#endif
|
||||
2444
src/mesa/drivers/dri/savage/savagestate.c
Normal file
2444
src/mesa/drivers/dri/savage/savagestate.c
Normal file
File diff suppressed because it is too large
Load diff
69
src/mesa/drivers/dri/savage/savagestate.h
Normal file
69
src/mesa/drivers/dri/savage/savagestate.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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"
|
||||
|
||||
extern void savageDDUpdateHwState( GLcontext *ctx );
|
||||
extern void savageDDInitState( savageContextPtr imesa );
|
||||
extern void savageDDInitStateFuncs( GLcontext *ctx );
|
||||
extern void savageDDRenderStart(GLcontext *ctx);
|
||||
extern void savageDDRenderEnd(GLcontext *ctx);
|
||||
extern void savageDDScissor( GLcontext *ctx, GLint x, GLint y,GLsizei w, GLsizei h );
|
||||
|
||||
/*frank 2001/11/13 add macro for sarea state copy*/
|
||||
#define SAVAGE_STATE_COPY(ctx) { \
|
||||
ctx->sarea->setup[0]=ctx->Registers.DrawLocalCtrl.ui; \
|
||||
ctx->sarea->setup[1]=ctx->Registers.TexPalAddr.ui; \
|
||||
ctx->sarea->setup[2]=ctx->Registers.TexCtrl[0].ui; \
|
||||
ctx->sarea->setup[3]=ctx->Registers.TexCtrl[1].ui; \
|
||||
ctx->sarea->setup[4]=ctx->Registers.TexAddr[0].ui; \
|
||||
ctx->sarea->setup[5]=ctx->Registers.TexAddr[1].ui; \
|
||||
ctx->sarea->setup[6]=ctx->Registers.TexBlendCtrl[0].ui; \
|
||||
ctx->sarea->setup[7]=ctx->Registers.TexBlendCtrl[1].ui; \
|
||||
ctx->sarea->setup[8]=ctx->Registers.TexXprClr.ui; \
|
||||
ctx->sarea->setup[9]=ctx->Registers.TexDescr.ui; \
|
||||
ctx->sarea->setup[10]=ctx->Registers.FogTable.ni.ulEntry[0]; \
|
||||
ctx->sarea->setup[11]=ctx->Registers.FogTable.ni.ulEntry[1]; \
|
||||
ctx->sarea->setup[12]=ctx->Registers.FogTable.ni.ulEntry[2]; \
|
||||
ctx->sarea->setup[13]=ctx->Registers.FogTable.ni.ulEntry[3]; \
|
||||
ctx->sarea->setup[14]=ctx->Registers.FogTable.ni.ulEntry[4]; \
|
||||
ctx->sarea->setup[15]=ctx->Registers.FogTable.ni.ulEntry[5]; \
|
||||
ctx->sarea->setup[16]=ctx->Registers.FogTable.ni.ulEntry[6]; \
|
||||
ctx->sarea->setup[17]=ctx->Registers.FogTable.ni.ulEntry[7]; \
|
||||
ctx->sarea->setup[18]=ctx->Registers.FogCtrl.ui; \
|
||||
ctx->sarea->setup[19]=ctx->Registers.StencilCtrl.ui; \
|
||||
ctx->sarea->setup[20]=ctx->Registers.ZBufCtrl.ui; \
|
||||
ctx->sarea->setup[21]=ctx->Registers.ZBufOffset.ui; \
|
||||
ctx->sarea->setup[22]=ctx->Registers.DestCtrl.ui; \
|
||||
ctx->sarea->setup[23]=ctx->Registers.DrawCtrl0.ui; \
|
||||
ctx->sarea->setup[24]=ctx->Registers.DrawCtrl1.ui; \
|
||||
ctx->sarea->setup[25]=ctx->Registers.ZWatermarks.ui; \
|
||||
ctx->sarea->setup[26]=ctx->Registers.DestTexWatermarks.ui; \
|
||||
ctx->sarea->setup[27]=ctx->Registers.TexBlendColor.ui; \
|
||||
}
|
||||
#endif
|
||||
2022
src/mesa/drivers/dri/savage/savagetex.c
Normal file
2022
src/mesa/drivers/dri/savage/savagetex.c
Normal file
File diff suppressed because it is too large
Load diff
117
src/mesa/drivers/dri/savage/savagetex.h
Normal file
117
src/mesa/drivers/dri/savage/savagetex.h
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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 "mtypes.h"
|
||||
#include "mm.h"
|
||||
|
||||
#include "savagecontext.h"
|
||||
#include "savage_3d_reg.h"
|
||||
|
||||
#define VALID_SAVAGE_TEXTURE_OBJECT(tobj) (tobj)
|
||||
|
||||
#define SAVAGE_TEX_MAXLEVELS 11
|
||||
#define MIN_TILE_CHUNK 8
|
||||
#define MIPMAP_CHUNK 4
|
||||
|
||||
|
||||
|
||||
/* 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'
|
||||
*/
|
||||
typedef struct {
|
||||
GLuint sWrapMode;
|
||||
GLuint tWrapMode;
|
||||
GLuint minFilter;
|
||||
GLuint magFilter;
|
||||
GLuint boarderColor;
|
||||
GLuint hwPhysAddress;
|
||||
} savage_texture_parameter_t;
|
||||
|
||||
struct savage_texture_object_t {
|
||||
struct savage_texture_object_t *next, *prev;
|
||||
struct gl_texture_object *globj;
|
||||
GLuint age;
|
||||
|
||||
|
||||
GLuint texelBytes;
|
||||
GLuint totalSize;
|
||||
GLuint bound;
|
||||
GLuint heap;
|
||||
|
||||
PMemBlock MemBlock;
|
||||
char *BufAddr;
|
||||
|
||||
GLuint min_level;
|
||||
GLuint max_level;
|
||||
GLuint dirty_images;
|
||||
|
||||
struct {
|
||||
const struct gl_texture_image *image;
|
||||
GLuint offset; /* into BufAddr */
|
||||
GLuint height;
|
||||
GLuint internalFormat;
|
||||
} image[SAVAGE_TEX_MAXLEVELS];
|
||||
|
||||
/* Support for multitexture.
|
||||
*/
|
||||
GLuint current_unit;
|
||||
savage_texture_parameter_t texParams;
|
||||
};
|
||||
|
||||
#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)
|
||||
|
||||
|
||||
extern void (*savageUpdateTextureState)( GLcontext *ctx );
|
||||
void savageDDInitTextureFuncs( struct dd_function_table *functions );
|
||||
|
||||
void savageDestroyTexObj( savageContextPtr imesa, savageTextureObjectPtr t);
|
||||
int savageUploadTexImages( savageContextPtr imesa, savageTextureObjectPtr t );
|
||||
|
||||
void savageResetGlobalLRU( savageContextPtr imesa , GLuint heap);
|
||||
void savageTexturesGone( savageContextPtr imesa, GLuint heap,
|
||||
GLuint start, GLuint end,
|
||||
GLuint in_use );
|
||||
|
||||
void savagePrintLocalLRU( savageContextPtr imesa ,GLuint heap);
|
||||
void savagePrintGlobalLRU( savageContextPtr imesa ,GLuint heap);
|
||||
|
||||
#endif
|
||||
817
src/mesa/drivers/dri/savage/savagetris.c
Normal file
817
src/mesa/drivers/dri/savage/savagetris.c
Normal file
|
|
@ -0,0 +1,817 @@
|
|||
/* $XFree86$ */ /* -*- 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 <keithw@valinux.com>
|
||||
* Felix Kuehling <fxkuehl@gmx.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "colormac.h"
|
||||
#include "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 "savagevb.h"
|
||||
#include "savageioctl.h"
|
||||
#include "savage_bci.h"
|
||||
|
||||
static void savageRasterPrimitive( GLcontext *ctx, GLuint prim );
|
||||
static void savageRenderPrimitive( GLcontext *ctx, GLenum prim );
|
||||
|
||||
/***********************************************************************
|
||||
* Emit primitives *
|
||||
***********************************************************************/
|
||||
|
||||
static __inline__ GLuint * savage_send_one_vertex(savageContextPtr imesa, savageVertexPtr v, GLuint * vb, GLuint start, GLuint size)
|
||||
{
|
||||
GLuint j;
|
||||
for (j = start ; j < size ; j++)
|
||||
{
|
||||
WRITE_CMD(vb, v->ui[j],GLuint);
|
||||
}
|
||||
return vb;
|
||||
}
|
||||
|
||||
static void __inline__ savage_draw_triangle( savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1,
|
||||
savageVertexPtr v2 )
|
||||
{
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
#if SAVAGEDEBUG
|
||||
GLuint *vb = savageDMAAlloc (imesa, 3 * vertsize + 1 + 8);
|
||||
#else
|
||||
GLuint *vb = savageDMAAlloc (imesa, 4 * vertsize + 1);
|
||||
#endif
|
||||
|
||||
imesa->DrawPrimitiveCmd &=
|
||||
~(SAVAGE_HW_TRIANGLE_TYPE| SAVAGE_HW_TRIANGLE_CONT);
|
||||
WRITE_CMD(vb,SAVAGE_DRAW_PRIMITIVE(3, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
|
||||
|
||||
vb = savage_send_one_vertex(imesa, v0, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v1, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v2, vb, 0, vertsize);
|
||||
|
||||
#if SAVAGEDEBUG
|
||||
{
|
||||
GLuint x0,y0,w,h;
|
||||
x0 = (GLuint)imesa->drawX;
|
||||
y0 = (GLuint)imesa->drawY;
|
||||
w = (GLuint)imesa->driDrawable->w;
|
||||
h = (GLuint)imesa->driDrawable->h;
|
||||
|
||||
(*vb) = 0x4BCC00C0;
|
||||
vb++;
|
||||
(*vb) = imesa->savageScreen->backOffset;
|
||||
vb++;
|
||||
(*vb) = imesa->savageScreen->backBitmapDesc;
|
||||
vb++;
|
||||
(*vb) = (y0<<16)|x0;
|
||||
vb++;
|
||||
(*vb) = 0x0;
|
||||
vb++;
|
||||
(*vb) = (h<<16)|w;
|
||||
vb++;
|
||||
}
|
||||
#endif
|
||||
savageDMACommit (imesa, vb);
|
||||
}
|
||||
|
||||
static __inline__ void savage_draw_point( savageContextPtr imesa,
|
||||
savageVertexPtr tmp )
|
||||
{
|
||||
GLfloat sz = imesa->glCtx->Point._Size * .5;
|
||||
int vertsize = imesa->vertex_size;
|
||||
GLuint *vb = savageDMAAlloc (imesa, 4 * vertsize + 1);
|
||||
const GLfloat x = tmp->v.x;
|
||||
const GLfloat y = tmp->v.y;
|
||||
|
||||
imesa->DrawPrimitiveCmd &=
|
||||
~(SAVAGE_HW_TRIANGLE_TYPE | SAVAGE_HW_TRIANGLE_CONT);
|
||||
imesa->DrawPrimitiveCmd |= SAVAGE_HW_TRIANGLE_FAN;
|
||||
|
||||
WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(4, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
|
||||
|
||||
WRITE_CMD(vb, x - sz, GLfloat);
|
||||
WRITE_CMD(vb, y - sz, GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, tmp, vb, 2, vertsize);
|
||||
|
||||
WRITE_CMD(vb, x + sz, GLfloat);
|
||||
WRITE_CMD(vb, y - sz, GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, tmp, vb, 2, vertsize);
|
||||
|
||||
WRITE_CMD(vb, x + sz, GLfloat);
|
||||
WRITE_CMD(vb, y + sz, GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, tmp, vb, 2, vertsize);
|
||||
|
||||
WRITE_CMD(vb, x - sz, GLfloat);
|
||||
WRITE_CMD(vb, y + sz, GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, tmp, vb, 2, vertsize);
|
||||
|
||||
savageDMACommit (imesa, vb);
|
||||
}
|
||||
|
||||
|
||||
static __inline__ void savage_draw_line( savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1 )
|
||||
{
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
GLuint *vb = savageDMAAlloc (imesa, 4 * vertsize + 1);
|
||||
GLfloat dx, dy, ix, iy;
|
||||
GLfloat width = imesa->glCtx->Line._Width;
|
||||
|
||||
imesa->DrawPrimitiveCmd &=
|
||||
~(SAVAGE_HW_TRIANGLE_TYPE | SAVAGE_HW_TRIANGLE_CONT);
|
||||
imesa->DrawPrimitiveCmd |= SAVAGE_HW_TRIANGLE_FAN;
|
||||
WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(4, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
WRITE_CMD(vb, (v0->v.x - ix), GLfloat);
|
||||
WRITE_CMD(vb, (v0->v.y - iy), GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, v0, vb, 2, vertsize);
|
||||
|
||||
WRITE_CMD(vb, (v1->v.x - ix), GLfloat);
|
||||
WRITE_CMD(vb, (v1->v.y - iy), GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, v1, vb, 2, vertsize);
|
||||
|
||||
WRITE_CMD(vb, (v1->v.x + ix), GLfloat);
|
||||
WRITE_CMD(vb, (v1->v.y + iy), GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, v1, vb, 2, vertsize);
|
||||
|
||||
WRITE_CMD(vb, (v0->v.x + ix), GLfloat);
|
||||
WRITE_CMD(vb, (v0->v.y + iy), GLfloat);
|
||||
vb = savage_send_one_vertex(imesa, v0, vb, 2, vertsize);
|
||||
|
||||
savageDMACommit (imesa, vb);
|
||||
}
|
||||
|
||||
static void __inline__ savage_draw_quad( savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1,
|
||||
savageVertexPtr v2,
|
||||
savageVertexPtr v3 )
|
||||
{
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
GLuint *vb = savageDMAAlloc (imesa, 6 * vertsize + 1);
|
||||
|
||||
imesa->DrawPrimitiveCmd &=
|
||||
~(SAVAGE_HW_TRIANGLE_TYPE | SAVAGE_HW_TRIANGLE_CONT);
|
||||
WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(6, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
|
||||
|
||||
vb = savage_send_one_vertex(imesa, v0, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v1, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v3, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v1, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v2, vb, 0, vertsize);
|
||||
vb = savage_send_one_vertex(imesa, v3, vb, 0, vertsize);
|
||||
|
||||
savageDMACommit (imesa, vb);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* 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 {
|
||||
points_func points;
|
||||
line_func line;
|
||||
triangle_func triangle;
|
||||
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_RGBA 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 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 SAVAGE_COLOR( dst, src ) \
|
||||
do { \
|
||||
dst[0] = src[2]; \
|
||||
dst[1] = src[1]; \
|
||||
dst[2] = src[0]; \
|
||||
dst[3] = src[3]; \
|
||||
} while (0)
|
||||
|
||||
#define SAVAGE_SPEC( dst, src ) \
|
||||
do { \
|
||||
dst[0] = src[2]; \
|
||||
dst[1] = src[1]; \
|
||||
dst[2] = src[0]; \
|
||||
} while (0)
|
||||
|
||||
#define VERT_SET_RGBA( v, c ) SAVAGE_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) SAVAGE_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) \
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
|
||||
GLuint color[n], spec[n]; \
|
||||
GLuint coloroffset = 4/*(rmesa->vertex_size == 4 ? 3 : 4)*/; \
|
||||
GLboolean havespec = 1/*(rmesa->vertex_size == 4 ? 0 : 1)*/; \
|
||||
(void) color; (void) spec; (void) coloroffset; (void) havespec;
|
||||
|
||||
/***********************************************************************
|
||||
* Helpers for rendering unfilled primitives *
|
||||
***********************************************************************/
|
||||
|
||||
#define RASTERIZE(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 )
|
||||
{
|
||||
GLcontext *ctx = imesa->glCtx;
|
||||
SWvertex v[3];
|
||||
savage_translate_vertex( ctx, v0, &v[0] );
|
||||
savage_translate_vertex( ctx, v1, &v[1] );
|
||||
savage_translate_vertex( ctx, v2, &v[2] );
|
||||
_swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
savage_fallback_line( savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1 )
|
||||
{
|
||||
GLcontext *ctx = imesa->glCtx;
|
||||
SWvertex v[2];
|
||||
savage_translate_vertex( ctx, v0, &v[0] );
|
||||
savage_translate_vertex( ctx, v1, &v[1] );
|
||||
_swrast_Line( ctx, &v[0], &v[1] );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
savage_fallback_point( savageContextPtr imesa,
|
||||
savageVertexPtr v0 )
|
||||
{
|
||||
GLcontext *ctx = imesa->glCtx;
|
||||
SWvertex v[1];
|
||||
savage_translate_vertex( 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( GLcontext *ctx, const GLuint *elts,
|
||||
GLuint n )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
/* Render the new vertices as an unclipped polygon.
|
||||
*/
|
||||
{
|
||||
GLuint *tmp = VB->Elts;
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static void savageRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line( ctx, ii, jj );
|
||||
}
|
||||
/*
|
||||
static void savageFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
|
||||
GLuint n )
|
||||
{
|
||||
r128ContextPtr rmesa = R128_CONTEXT( ctx );
|
||||
GLuint vertsize = rmesa->vertex_size;
|
||||
GLuint *vb = r128AllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize );
|
||||
GLubyte *r128verts = (GLubyte *)rmesa->verts;
|
||||
const GLuint shift = rmesa->vertex_stride_shift;
|
||||
const GLuint *start = (const GLuint *)VERT(elts[0]);
|
||||
int i,j;
|
||||
|
||||
rmesa->num_verts += (n-2) * 3;
|
||||
|
||||
for (i = 2 ; i < n ; i++) {
|
||||
COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) start );
|
||||
COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i-1]) );
|
||||
COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i]) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Choose render functions */
|
||||
/**********************************************************************/
|
||||
|
||||
#define _SAVAGE_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \
|
||||
_DD_NEW_LINE_SMOOTH | \
|
||||
_DD_NEW_POINT_SMOOTH | \
|
||||
_DD_NEW_TRI_SMOOTH | \
|
||||
_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
||||
_DD_NEW_TRI_OFFSET) \
|
||||
|
||||
/* 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_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(GLcontext *ctx)
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint index = 0;
|
||||
|
||||
if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
|
||||
imesa->draw_point = savage_draw_point;
|
||||
imesa->draw_line = savage_draw_line;
|
||||
imesa->draw_tri = savage_draw_triangle;
|
||||
|
||||
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 & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
|
||||
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 (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( GLcontext *ctx )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
|
||||
if (imesa->new_state)
|
||||
savageDDUpdateHwState( ctx );
|
||||
|
||||
if (!imesa->Fallback && imesa->new_gl_state) {
|
||||
if (imesa->new_gl_state & _SAVAGE_NEW_VERTEX_STATE)
|
||||
savageChooseVertexState( ctx );
|
||||
|
||||
if (imesa->new_gl_state & _SAVAGE_NEW_RENDER_STATE)
|
||||
savageChooseRenderState( ctx );
|
||||
|
||||
imesa->new_gl_state = 0;
|
||||
}
|
||||
|
||||
_tnl_run_pipeline( ctx );
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* High level hooks for t_vb_render.c */
|
||||
/**********************************************************************/
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
/* 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( GLcontext *ctx, GLuint prim )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
|
||||
FLUSH_BATCH( imesa );
|
||||
|
||||
/* Update culling */
|
||||
if (imesa->raster_primitive != prim)
|
||||
imesa->dirty |= SAVAGE_UPLOAD_CTX;
|
||||
|
||||
imesa->raster_primitive = prim;
|
||||
#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( GLcontext *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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void savageRenderStart( GLcontext *ctx )
|
||||
{
|
||||
/* Check for projective texturing. Make sure all texcoord
|
||||
* pointers point to something. (fix in mesa?)
|
||||
*/
|
||||
savageCheckTexSizes( ctx );
|
||||
|
||||
if (!SAVAGE_CONTEXT(ctx)->Fallback) {
|
||||
/* Update hardware state and get the lock */
|
||||
savageDDRenderStart( ctx );
|
||||
}
|
||||
}
|
||||
|
||||
static void savageRenderFinish( GLcontext *ctx )
|
||||
{
|
||||
/* Release the lock */
|
||||
savageDDRenderEnd( ctx );
|
||||
|
||||
if (SAVAGE_CONTEXT(ctx)->RenderIndex & SAVAGE_FALLBACK_BIT)
|
||||
_swrast_flush( ctx );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Transition to/from hardware rasterization. */
|
||||
/**********************************************************************/
|
||||
|
||||
void savageFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
GLuint oldfallback = imesa->Fallback;
|
||||
|
||||
if (mode) {
|
||||
imesa->Fallback |= bit;
|
||||
if (oldfallback == 0) {
|
||||
/* the first fallback */
|
||||
LOCK_HARDWARE(SAVAGE_CONTEXT(ctx));
|
||||
FLUSH_BATCH( imesa );
|
||||
UNLOCK_HARDWARE(SAVAGE_CONTEXT(ctx));
|
||||
_swsetup_Wakeup( ctx );
|
||||
imesa->RenderIndex = ~0;
|
||||
}
|
||||
}
|
||||
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 = savageBuildVertices;
|
||||
imesa->new_gl_state |= (_SAVAGE_NEW_RENDER_STATE|
|
||||
_SAVAGE_NEW_VERTEX_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Initialization. */
|
||||
/**********************************************************************/
|
||||
|
||||
void savageInitTriFuncs( GLcontext *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 = savageBuildVertices;
|
||||
|
||||
/* r128Fallback( ctx, 0x100000, 1 ); */
|
||||
}
|
||||
49
src/mesa/drivers/dri/savage/savagetris.h
Normal file
49
src/mesa/drivers/dri/savage/savagetris.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.4 2001/01/08 01:07:24 martin Exp $ */
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
|
||||
VA Linux Systems Inc., Fremont, California.
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
license, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
* Felix Kuehling <fxkuehl@gmx.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __R128_TRIS_H__
|
||||
#define __R128_TRIS_H__
|
||||
|
||||
#include "mtypes.h"
|
||||
|
||||
extern void savageInitTriFuncs( GLcontext *ctx );
|
||||
|
||||
|
||||
extern void savageFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
|
||||
#define FALLBACK( ctx, bit, mode ) savageFallback( ctx, bit, mode )
|
||||
|
||||
|
||||
#endif /* __R128_TRIS_H__ */
|
||||
470
src/mesa/drivers/dri/savage/savagevb.c
Normal file
470
src/mesa/drivers/dri/savage/savagevb.c
Normal file
|
|
@ -0,0 +1,470 @@
|
|||
/*
|
||||
* Copyright 2000-2001 VA Linux Systems, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, and/or sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
* Felix Kuehling <fxkuehl@gmx.de>
|
||||
*/
|
||||
/* $XFree86$ */
|
||||
|
||||
#include "savagecontext.h"
|
||||
#include "savagevb.h"
|
||||
#include "savagetris.h"
|
||||
#include "savageioctl.h"
|
||||
#include "savagecontext.h"
|
||||
#include "savage_bci.h"
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "macros.h"
|
||||
#include "colormac.h"
|
||||
|
||||
#include "tnl/t_context.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define SAVAGE_TEX1_BIT 0x1
|
||||
#define SAVAGE_TEX0_BIT 0x2
|
||||
#define SAVAGE_RGBA_BIT 0x4
|
||||
#define SAVAGE_SPEC_BIT 0x8
|
||||
#define SAVAGE_FOG_BIT 0x10
|
||||
#define SAVAGE_XYZW_BIT 0x20
|
||||
#define SAVAGE_PTEX_BIT 0x40
|
||||
#define SAVAGE_MAX_SETUP 0x80
|
||||
|
||||
static struct {
|
||||
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
|
||||
interp_func interp;
|
||||
copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)( GLcontext *ctx );
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_format;
|
||||
} setup_tab[SAVAGE_MAX_SETUP];
|
||||
|
||||
/* savage supports vertices without specular color, but this is not supported
|
||||
* by the vbtmp. have to check if/how tiny vertices work. */
|
||||
#define TINY_VERTEX_FORMAT 0
|
||||
#define NOTEX_VERTEX_FORMAT (SAVAGE_HW_NO_UV0|SAVAGE_HW_NO_UV1)
|
||||
#define TEX0_VERTEX_FORMAT (SAVAGE_HW_NO_UV1)
|
||||
#define TEX1_VERTEX_FORMAT (0)
|
||||
#define PROJ_TEX1_VERTEX_FORMAT 0
|
||||
#define TEX2_VERTEX_FORMAT 0
|
||||
#define TEX3_VERTEX_FORMAT 0
|
||||
#define PROJ_TEX3_VERTEX_FORMAT 0
|
||||
|
||||
#define DO_XYZW (IND & SAVAGE_XYZW_BIT)
|
||||
#define DO_RGBA (IND & SAVAGE_RGBA_BIT)
|
||||
#define DO_SPEC (IND & SAVAGE_SPEC_BIT)
|
||||
#define DO_FOG (IND & SAVAGE_FOG_BIT)
|
||||
#define DO_TEX0 (IND & SAVAGE_TEX0_BIT)
|
||||
#define DO_TEX1 (IND & SAVAGE_TEX1_BIT)
|
||||
#define DO_TEX2 0
|
||||
#define DO_TEX3 0
|
||||
#define DO_PTEX (IND & SAVAGE_PTEX_BIT)
|
||||
|
||||
|
||||
#define VERTEX savageVertex
|
||||
#define LOCALVARS savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
#define GET_VIEWPORT_MAT() imesa->hw_viewport
|
||||
#define GET_TEXSOURCE(n) n
|
||||
#define GET_VERTEX_FORMAT() (imesa->DrawPrimitiveCmd & \
|
||||
(SAVAGE_HW_NO_UV0|SAVAGE_HW_NO_UV1))
|
||||
#define GET_VERTEX_STORE() imesa->verts
|
||||
#define GET_VERTEX_SIZE() (imesa->vertex_size * sizeof(int))
|
||||
|
||||
#define HAVE_HW_VIEWPORT 0
|
||||
#define HAVE_HW_DIVIDE 0
|
||||
#define HAVE_RGBA_COLOR 0
|
||||
#define HAVE_TINY_VERTICES 0
|
||||
#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 = - imesa->drawX - SUBPIXEL_X; \
|
||||
const GLfloat dy = (imesa->driDrawable->h + \
|
||||
imesa->drawY + SUBPIXEL_Y); \
|
||||
const GLfloat sz = 1.0 / imesa->depth_scale
|
||||
|
||||
#define UNVIEWPORT_X(x) x + dx;
|
||||
#define UNVIEWPORT_Y(y) - y + dy;
|
||||
#define UNVIEWPORT_Z(z) z * sz;
|
||||
|
||||
#define PTEX_FALLBACK() (void)imesa, FALLBACK(ctx, SAVAGE_FALLBACK_TEXTURE, 1)
|
||||
|
||||
|
||||
#define INTERP_VERTEX (void)imesa, setup_tab[SAVAGE_CONTEXT(ctx)->SetupIndex].interp
|
||||
#define COPY_PV_VERTEX (void)imesa, setup_tab[SAVAGE_CONTEXT(ctx)->SetupIndex].copy_pv
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Generate pv-copying and translation functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define TAG(x) savage_##x
|
||||
#include "tnl_dd/t_dd_vb.c"
|
||||
|
||||
/***********************************************************************
|
||||
* Generate vertex emit and interp functions *
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT)
|
||||
#define TAG(x) x##_wg
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT)
|
||||
#define TAG(x) x##_wgs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_wgt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_wgt0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
|
||||
#define TAG(x) x##_wgpt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_wgst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_wgst0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
|
||||
#define TAG(x) x##_wgspt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT)
|
||||
#define TAG(x) x##_wgf
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT)
|
||||
#define TAG(x) x##_wgfs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_wgft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_wgft0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfpt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_wgfst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_wgfst0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfspt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_t0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_t0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_FOG_BIT)
|
||||
#define TAG(x) x##_f
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_ft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_ft0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT)
|
||||
#define TAG(x) x##_g
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT)
|
||||
#define TAG(x) x##_gs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_gt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_gt0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_gst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_gst0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT)
|
||||
#define TAG(x) x##_gf
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT)
|
||||
#define TAG(x) x##_gfs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_gft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
|
||||
#define TAG(x) x##_gft0t1
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
|
||||
#define TAG(x) x##_gfst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_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 savagePrintSetupFlags(char *msg, GLuint flags )
|
||||
{
|
||||
fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
|
||||
msg,
|
||||
(int)flags,
|
||||
(flags & SAVAGE_XYZW_BIT) ? " xyzw," : "",
|
||||
(flags & SAVAGE_RGBA_BIT) ? " rgba," : "",
|
||||
(flags & SAVAGE_SPEC_BIT) ? " spec," : "",
|
||||
(flags & SAVAGE_FOG_BIT) ? " fog," : "",
|
||||
(flags & SAVAGE_TEX0_BIT) ? " tex-0," : "",
|
||||
(flags & SAVAGE_TEX1_BIT) ? " tex-1," : "");
|
||||
}
|
||||
|
||||
|
||||
void savageCheckTexSizes( GLcontext *ctx )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
|
||||
/*fprintf(stderr, "%s\n", __FUNCTION__);*/
|
||||
|
||||
if (!setup_tab[imesa->SetupIndex].check_tex_sizes(ctx)) {
|
||||
imesa->SetupIndex |= SAVAGE_PTEX_BIT;
|
||||
imesa->SetupNewInputs = ~0;
|
||||
|
||||
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 savageBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
GLuint stride = imesa->vertex_size * sizeof(int);
|
||||
GLubyte *v = ((GLubyte *)imesa->verts + (start * stride));
|
||||
|
||||
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 |= SAVAGE_RGBA_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR1)
|
||||
ind |= SAVAGE_SPEC_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX0)
|
||||
ind |= SAVAGE_TEX0_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX1)
|
||||
ind |= SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_FOG)
|
||||
ind |= SAVAGE_FOG_BIT;
|
||||
|
||||
if (imesa->SetupIndex & SAVAGE_PTEX_BIT)
|
||||
ind = ~0;
|
||||
|
||||
ind &= imesa->SetupIndex;
|
||||
|
||||
if (ind) {
|
||||
setup_tab[ind].emit( ctx, start, count, v, stride );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void savageChooseVertexState( GLcontext *ctx )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint ind = SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT;
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
||||
ind |= SAVAGE_SPEC_BIT;
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
ind |= SAVAGE_FOG_BIT;
|
||||
|
||||
if (ctx->Texture._EnabledUnits & 0x2) {
|
||||
if (ctx->Texture._EnabledUnits & 0x1) {
|
||||
ind |= SAVAGE_TEX1_BIT|SAVAGE_TEX0_BIT;
|
||||
}
|
||||
else {
|
||||
ind |= SAVAGE_TEX0_BIT;
|
||||
}
|
||||
}
|
||||
else if (ctx->Texture._EnabledUnits & 0x1) {
|
||||
ind |= SAVAGE_TEX0_BIT;
|
||||
}
|
||||
|
||||
imesa->SetupIndex = ind;
|
||||
|
||||
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
|
||||
tnl->Driver.Render.Interp = savage_interp_extras;
|
||||
tnl->Driver.Render.CopyPV = savage_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 != GET_VERTEX_FORMAT()) {
|
||||
imesa->DrawPrimitiveCmd = setup_tab[ind].vertex_format;
|
||||
imesa->vertex_size = setup_tab[ind].vertex_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void savageInitVB( GLcontext *ctx )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
|
||||
|
||||
imesa->verts = (GLubyte *)ALIGN_MALLOC(size * sizeof(savageVertex), 32);
|
||||
|
||||
{
|
||||
static int firsttime = 1;
|
||||
if (firsttime) {
|
||||
init_setup_tab();
|
||||
firsttime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
imesa->DrawPrimitiveCmd = setup_tab[0].vertex_format;
|
||||
imesa->vertex_size = setup_tab[0].vertex_size;
|
||||
|
||||
if (imesa->savageScreen->chipset >= S3_SAVAGE4)
|
||||
imesa->DrawPrimitiveMask = ~0;
|
||||
else
|
||||
imesa->DrawPrimitiveMask = ~SAVAGE_HW_NO_UV1;
|
||||
}
|
||||
|
||||
|
||||
void savageFreeVB( GLcontext *ctx )
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
|
||||
if (imesa->verts) {
|
||||
ALIGN_FREE(imesa->verts);
|
||||
imesa->verts = 0;
|
||||
}
|
||||
}
|
||||
|
||||
62
src/mesa/drivers/dri/savage/savagevb.h
Normal file
62
src/mesa/drivers/dri/savage/savagevb.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.h,v 1.6 2001/04/10 16:07:51 dawes Exp $ */
|
||||
/*
|
||||
* Copyright 2000-2001 VA Linux Systems, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, and/or sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
* Felix Kuehling <fxkuehl@gmx.de>
|
||||
*/
|
||||
|
||||
#ifndef SAVAGEVB_INC
|
||||
#define SAVAGEVB_INC
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "savagecontext.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define _SAVAGE_NEW_VERTEX_STATE (_NEW_TEXTURE | \
|
||||
_DD_NEW_SEPARATE_SPECULAR | \
|
||||
_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
||||
_NEW_FOG)
|
||||
|
||||
|
||||
extern void savageChooseVertexState( GLcontext *ctx );
|
||||
extern void savageCheckTexSizes( GLcontext *ctx );
|
||||
extern void savageBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs );
|
||||
|
||||
extern void savagePrintSetupFlags(char *msg, GLuint flags );
|
||||
|
||||
extern void savageInitVB( GLcontext *ctx );
|
||||
extern void savageFreeVB( GLcontext *ctx );
|
||||
|
||||
extern void savage_translate_vertex(GLcontext *ctx,
|
||||
const savageVertex *src,
|
||||
SWvertex *dst);
|
||||
|
||||
extern void savage_print_vertex( GLcontext *ctx, const savageVertex *v );
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue