📄 tdfx_context.h
字号:
/* -*- mode: c; c-basic-offset: 3 -*- * * Copyright 2000 VA Linux Systems Inc., Fremont, California. * * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *//* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h,v 1.5 2002/02/24 21:51:10 dawes Exp $ *//* * New fixes: * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004 * * Original rewrite: * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000 * * Authors: * Gareth Hughes <gareth@valinux.com> * */#ifndef __TDFX_CONTEXT_H__#define __TDFX_CONTEXT_H__#include <sys/time.h>#include "dri_util.h"#ifdef XFree86Server#include "GL/xf86glx.h"#else#include "glheader.h"#endif#if defined(__linux__)#include <signal.h>#endif#include "drm.h"#include "drm_sarea.h"#include "tdfx_glide.h"#include "xmlconfig.h"#include "clip.h"#include "context.h"#include "macros.h"#include "matrix.h"#include "imports.h"#include "mtypes.h"#include "tdfx_screen.h"#define TDFX_TMU0 GR_TMU0#define TDFX_TMU1 GR_TMU1#define TDFX_TMU_SPLIT 98#define TDFX_TMU_BOTH 99#define TDFX_TMU_NONE 100/* Flags for fxMesa->new_state */#define TDFX_NEW_COLOR 0x0001#define TDFX_NEW_ALPHA 0x0002#define TDFX_NEW_DEPTH 0x0004#define TDFX_NEW_FOG 0x0008#define TDFX_NEW_STENCIL 0x0010#define TDFX_NEW_CLIP 0x0020#define TDFX_NEW_VIEWPORT 0x0040#define TDFX_NEW_CULL 0x0080#define TDFX_NEW_GLIDE 0x0100#define TDFX_NEW_TEXTURE 0x0200#define TDFX_NEW_CONTEXT 0x0400#define TDFX_NEW_LINE 0x0800#define TDFX_NEW_RENDER 0x1000#define TDFX_NEW_STIPPLE 0x2000#define TDFX_NEW_TEXTURE_BIND 0x4000 /* experimental *//* Flags for fxMesa->dirty */#define TDFX_UPLOAD_COLOR_COMBINE 0x00000001#define TDFX_UPLOAD_ALPHA_COMBINE 0x00000002#define TDFX_UPLOAD_RENDER_BUFFER 0x00000004#define TDFX_UPLOAD_ALPHA_TEST 0x00000008#define TDFX_UPLOAD_ALPHA_REF 0x00000010#define TDFX_UPLOAD_BLEND_FUNC 0x00000020#define TDFX_UPLOAD_DEPTH_MODE 0x00000040#define TDFX_UPLOAD_DEPTH_BIAS 0x00000080#define TDFX_UPLOAD_DEPTH_FUNC 0x00000100#define TDFX_UPLOAD_DEPTH_MASK 0x00000200#define TDFX_UPLOAD_FOG_MODE 0x00000400#define TDFX_UPLOAD_FOG_COLOR 0x00000800#define TDFX_UPLOAD_FOG_TABLE 0x00001000#define TDFX_UPLOAD_CONSTANT_COLOR 0x00002000#define TDFX_UPLOAD_CLIP 0x00002000#define TDFX_UPLOAD_CULL 0x00004000#define TDFX_UPLOAD_VERTEX_LAYOUT 0x00008000#define TDFX_UPLOAD_COLOR_MASK 0x00010000#define TDFX_UPLOAD_DITHER 0x00040000#define TDFX_UPLOAD_STENCIL 0x00080000#define TDFX_UPLOAD_TEXTURE_SOURCE 0x00100000#define TDFX_UPLOAD_TEXTURE_PARAMS 0x00200000#define TDFX_UPLOAD_TEXTURE_PALETTE 0x00400000#define TDFX_UPLOAD_TEXTURE_ENV 0x00800000#define TDFX_UPLOAD_TEXTURE_IMAGES 0x01000000#define TDFX_UPLOAD_LINE 0x02000000#define TDFX_UPLOAD_STIPPLE 0x04000000/* Flags for software fallback cases *//* See correponding strings in tdfx_tris.c */#define TDFX_FALLBACK_TEXTURE_MAP 0x0001#define TDFX_FALLBACK_DRAW_BUFFER 0x0002#define TDFX_FALLBACK_SPECULAR 0x0004#define TDFX_FALLBACK_STENCIL 0x0008#define TDFX_FALLBACK_RENDER_MODE 0x0010#define TDFX_FALLBACK_LOGICOP 0x0020#define TDFX_FALLBACK_TEXTURE_ENV 0x0040#define TDFX_FALLBACK_TEXTURE_BORDER 0x0080#define TDFX_FALLBACK_COLORMASK 0x0100#define TDFX_FALLBACK_BLEND 0x0200#define TDFX_FALLBACK_LINE_STIPPLE 0x0400#define TDFX_FALLBACK_DISABLE 0x0800/* Different Glide vertex layouts */#define TDFX_LAYOUT_TINY 0#define TDFX_LAYOUT_NOTEX 1#define TDFX_LAYOUT_SINGLE 2#define TDFX_LAYOUT_MULTI 3#define TDFX_LAYOUT_PROJ1 4#define TDFX_LAYOUT_PROJ2 5#define TDFX_NUM_LAYOUTS 6#define TDFX_XY_OFFSET 0#define TDFX_Z_OFFSET 8#define TDFX_Q_OFFSET 12#define TDFX_ARGB_OFFSET 16#define TDFX_FOG_OFFSET 20#define TDFX_ST0_OFFSET 24#define TDFX_ST1_OFFSET 32#define TDFX_Q0_OFFSET 40#define TDFX_Q1_OFFSET 44/* Flags for buffer clears */#define TDFX_FRONT 0x1#define TDFX_BACK 0x2#define TDFX_DEPTH 0x4#define TDFX_STENCIL 0x8/* * Subpixel offsets to adjust Mesa's (true) window coordinates to * Glide coordinates. We need these to ensure precise rasterization. * Otherwise, we'll fail a bunch of conformance tests. */#define TRI_X_OFFSET ( 0.0F)#define TRI_Y_OFFSET ( 0.0F)#define LINE_X_OFFSET ( 0.0F)#define LINE_Y_OFFSET ( 0.125F)#define PNT_X_OFFSET ( 0.375F)#define PNT_Y_OFFSET ( 0.375F)#define TDFX_DEPTH_BIAS_SCALE 128/* Including xf86PciInfo.h causes a bunch of errors */#ifndef PCI_CHIP_BANSHEE#define PCI_CHIP_BANSHEE 0x0003#define PCI_CHIP_VOODOO3 0x0005#define PCI_CHIP_VOODOO4 0x0009#define PCI_CHIP_VOODOO5 0x0009#endif#define TDFX_IS_BANSHEE( fxMesa ) \ ( fxMesa->fxScreen->deviceID == PCI_CHIP_BANSHEE )#define TDFX_IS_VOODOO3( fxMesa ) \ ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO3 )#define TDFX_IS_VOODOO4( fxMesa ) \ ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4 )#define TDFX_IS_VOODOO5( fxMesa ) \ ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5 )#define TDFX_IS_NAPALM( fxMesa ) \ ( (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4) || \ (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5) )#define PACK_BGRA32(R, G, B, A) \ ( (((GLuint) (R)) << 16) | \ (((GLuint) (G)) << 8) | \ (((GLuint) (B)) ) | \ (((GLuint) (A)) << 24) )#define PACK_RGBA32(R, G, B, A) \ ( (((GLuint) (R)) ) | \ (((GLuint) (G)) << 8) | \ (((GLuint) (B)) << 16) | \ (((GLuint) (A)) << 24) )/* * The first two macros are to pack 8 bit color * channel values into a 565 format. */#define PACK_RGB16(R, G, B) \ ((((GLuint) (R) & 0xF8) << 8) | \ (((GLuint) (G) & 0xFC) << 3) | \ (((GLuint) (B) & 0xFF) >> 3))#define PACK_BGR16(R, G, B) \ ((((GLuint) (B) & 0xF8) << 8) | \ (((GLuint) (G) & 0xFC) << 3) | \ (((GLuint) (R) & 0xFF) >> 3))/* * The second two macros pack 8 bit color channel values * into 1555 values. */#define PACK_RGBA16(R, G, B, A) \ (((((GLuint) (A) & 0xFF) > 0) << 15)| \ (((GLuint) (R) & 0xF8) << 7) | \ (((GLuint) (G) & 0xF8) << 2) | \ (((GLuint) (B) & 0xF8) >> 3))#define PACK_BGRA16(R, G, B, A) \ (((((GLuint) (A) & 0xFF) > 0) << 15)| \ (((GLuint) (B) & 0xF8) << 7) | \ (((GLuint) (G) & 0xF8) << 2) | \ (((GLuint) (R) & 0xF8) >> 3))/* Used in calls to grColorMaskv()... */extern const GLboolean false4[4];extern const GLboolean true4[4];typedef struct tdfx_context tdfxContextRec;typedef struct tdfx_context *tdfxContextPtr;typedef struct { volatile int fifoPtr; volatile int fifoRead; volatile int fifoOwner; volatile int ctxOwner; volatile int texOwner;}TDFXSAREAPriv;typedef struct { GLuint swapBuffer; GLuint reqTexUpload; GLuint texUpload; GLuint memTexUpload; GLuint texSwaps;} tdfxStats;/* * Memory range from startAddr to endAddr-1 */typedef struct mem_range { struct mem_range *next; FxU32 startAddr, endAddr;}tdfxMemRange;typedef struct { GLsizei width, height; /* image size */ GLint wScale, hScale; /* scale factors */ GrTextureFormat_t glideFormat; /* Glide image format */}tdfxMipMapLevel;#define TDFX_NUM_TMU 2typedef struct tdfxTexInfo_t{ GLboolean isInTM; GLboolean reloadImages; /* if true, resend images to Glide */ GLuint lastTimeUsed; FxU32 whichTMU; GrTexInfo info; GrAspectRatio_t aspectRatio; tdfxMemRange *tm[TDFX_NUM_TMU]; GLint minLevel, maxLevel; GrTextureFilterMode_t minFilt; GrTextureFilterMode_t magFilt; GrTextureClampMode_t sClamp; GrTextureClampMode_t tClamp; FxBool LODblend; GrMipMapMode_t mmMode; GLfloat sScale, tScale; /* texcoord scale factor */ GrTexTable_t paltype; GuTexPalette palette; GLboolean padded;}tdfxTexInfo;#define TDFX_TEXTURE_DATA(mesaObj) ((tdfxTexInfo *)((mesaObj)->DriverData))#define TDFX_TEXIMAGE_DATA(mesaImg) ((tdfxMipMapLevel *)((mesaImg)->DriverData))/* * This is state which may be shared by several tdfx contexts. * It hangs off of Mesa's gl_shared_state object (ctx->Shared->DriverData). */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -