Home | History | Annotate | Line # | Download | only in src
      1 /*
      2  * Copyright 2006 Thomas Hellstrom. All Rights Reserved.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sub license,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the
     12  * next paragraph) shall be included in all copies or substantial portions
     13  * of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     21  * DEALINGS IN THE SOFTWARE.
     22  */
     23 
     24 #ifndef VIA_3D_H
     25 #define VIA_3D_H
     26 
     27 #include "xorg-server.h"
     28 #include "xf86.h"
     29 #include "via_dmabuffer.h"
     30 
     31 #define VIA_NUM_TEXUNITS 2
     32 
     33 typedef enum
     34 {
     35     via_single,
     36     via_clamp,
     37     via_repeat,
     38     via_mirror,
     39     via_warp
     40 } ViaTextureModes;
     41 
     42 typedef enum
     43 {
     44     via_src,
     45     via_src_onepix_mask,
     46     via_src_onepix_comp_mask,
     47     via_mask,
     48     via_comp_mask
     49 } ViaTexBlendingModes;
     50 
     51 typedef struct _ViaTextureUnit
     52 {
     53     CARD32 textureLevel0Offset;
     54     CARD32 textureLevel0Pitch;
     55     CARD32 textureLevel0Exp;
     56     CARD32 textureLevel0WExp;
     57     CARD32 textureLevel0HExp;
     58     CARD32 textureFormat;
     59     CARD32 textureModesT;
     60     CARD32 textureModesS;
     61     CARD32 texCsat;
     62     CARD32 texRCa;
     63     CARD32 texAsat;
     64     CARD32 texRAa;
     65     Bool agpTexture;
     66     Bool textureDirty;
     67     Bool texBColDirty;
     68     Bool npot;
     69 } ViaTextureUnit;
     70 
     71 typedef struct _Via3DState
     72 {
     73     Bool destDirty;
     74     Bool blendDirty;
     75     Bool enableDirty;
     76     Bool drawingDirty;
     77     CARD32 rop;
     78     CARD32 planeMask;
     79     CARD32 solidColor;
     80     CARD32 solidAlpha;
     81     CARD32 destOffset;
     82     CARD32 destPitch;
     83     CARD32 destFormat;
     84     int destDepth;
     85     int numTextures;
     86     Bool blend;
     87     CARD32 blendCol0;
     88     CARD32 blendCol1;
     89     CARD32 blendAl0;
     90     CARD32 blendAl1;
     91     Bool writeAlpha;
     92     Bool writeColor;
     93     Bool useDestAlpha;
     94     ViaTextureUnit tex[VIA_NUM_TEXUNITS];
     95     void (*setDestination) (struct _Via3DState * v3d, CARD32 offset,
     96 	CARD32 pitch, int format);
     97     void (*setDrawing) (struct _Via3DState * v3d, int rop,
     98 	CARD32 planeMask, CARD32 solidColor, CARD32 solidAlpha);
     99     void (*setFlags) (struct _Via3DState * v3d, int numTextures,
    100 	Bool writeAlpha, Bool writeColor, Bool blend);
    101         Bool(*setTexture) (struct _Via3DState * v3d, int tex, CARD32 offset,
    102 	CARD32 pitch, Bool nPot, CARD32 width, CARD32 height, int format,
    103 	ViaTextureModes sMode, ViaTextureModes tMode,
    104 	ViaTexBlendingModes blendingMode, Bool agpTexture);
    105     void (*setTexBlendCol) (struct _Via3DState * v3d, int tex, Bool component,
    106 	CARD32 color);
    107     void (*setCompositeOperator) (struct _Via3DState * v3d, CARD8 op);
    108         Bool(*opSupported) (CARD8 op);
    109     void (*emitQuad) (struct _Via3DState * v3d, ViaCommandBuffer * cb,
    110 	int dstX, int dstY, int src0X, int src0Y, int src1X, int src1Y, int w,
    111 	int h);
    112     void (*emitState) (struct _Via3DState * v3d, ViaCommandBuffer * cb,
    113 	Bool forceUpload);
    114     void (*emitClipRect) (struct _Via3DState * v3d, ViaCommandBuffer * cb,
    115 	int x, int y, int w, int h);
    116         Bool(*dstSupported) (int format);
    117         Bool(*texSupported) (int format);
    118 } Via3DState;
    119 
    120 void viaInit3DState(Via3DState * v3d);
    121 
    122 #endif
    123