Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fxdrv.h 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 4.0
  4. *
  5. * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. /* Authors:
  25. * David Bucciarelli
  26. * Brian Paul
  27. * Daryll Strauss
  28. * Keith Whitwell
  29. * Daniel Borca
  30. * Hiroshi Morii
  31. */
  32. /* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
  33. #ifndef FXDRV_H
  34. #define FXDRV_H
  35. /* If you comment out this define, a variable takes its place, letting
  36. * you turn debugging on/off from the debugger.
  37. */
  38. #include "glheader.h"
  39. #if defined(__linux__)
  40. #include <signal.h>
  41. #endif
  42. #include "main/context.h"
  43. #include "main/imports.h"
  44. #include "main/macros.h"
  45. #include "main/matrix.h"
  46. #include "main/mtypes.h"
  47. #include "GL/fxmesa.h"
  48. #include "fxglidew.h"
  49. #include "math/m_vector.h"
  50. #define COPY_FLOAT(dst, src) (dst) = (src)
  51. /* Define some shorter names for these things.
  52. */
  53. #define XCOORD GR_VERTEX_X_OFFSET
  54. #define YCOORD GR_VERTEX_Y_OFFSET
  55. #define ZCOORD GR_VERTEX_OOZ_OFFSET
  56. #define OOWCOORD GR_VERTEX_OOW_OFFSET
  57. #define S0COORD GR_VERTEX_SOW_TMU0_OFFSET
  58. #define T0COORD GR_VERTEX_TOW_TMU0_OFFSET
  59. #define S1COORD GR_VERTEX_SOW_TMU1_OFFSET
  60. #define T1COORD GR_VERTEX_TOW_TMU1_OFFSET
  61. #ifdef __i386__
  62. #define FXCOLOR4( c ) (* (int *)c)
  63. #else
  64. #define FXCOLOR4( c ) ( \
  65. ( ((unsigned int)(c[3]))<<24 ) | \
  66. ( ((unsigned int)(c[2]))<<16 ) | \
  67. ( ((unsigned int)(c[1]))<<8 ) | \
  68. ( (unsigned int)(c[0])) )
  69. #endif
  70. #define TDFXPACKCOLOR1555( r, g, b, a ) \
  71. ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
  72. ((a) ? 0x8000 : 0))
  73. #define TDFXPACKCOLOR565( r, g, b ) \
  74. ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
  75. #define TDFXPACKCOLOR8888( r, g, b, a ) \
  76. (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
  77. /* fastpath flags first
  78. */
  79. #define SETUP_TMU0 0x1
  80. #define SETUP_TMU1 0x2
  81. #define SETUP_RGBA 0x4
  82. #define SETUP_SNAP 0x8
  83. #define SETUP_XYZW 0x10
  84. #define SETUP_PTEX 0x20
  85. #define SETUP_PSIZ 0x40
  86. #define SETUP_SPEC 0x80
  87. #define SETUP_FOGC 0x100
  88. #define MAX_SETUP 0x200
  89. #define FX_NUM_TMU 2
  90. #define FX_TMU0 GR_TMU0
  91. #define FX_TMU1 GR_TMU1
  92. #define FX_TMU_SPLIT 98
  93. #define FX_TMU_BOTH 99
  94. #define FX_TMU_NONE 100
  95. /* Used for fxMesa->lastUnitsMode */
  96. #define FX_UM_NONE 0x00000000
  97. #define FX_UM_E0_REPLACE 0x00000001
  98. #define FX_UM_E0_MODULATE 0x00000002
  99. #define FX_UM_E0_DECAL 0x00000004
  100. #define FX_UM_E0_BLEND 0x00000008
  101. #define FX_UM_E0_ADD 0x00000010
  102. #define FX_UM_E1_REPLACE 0x00000020
  103. #define FX_UM_E1_MODULATE 0x00000040
  104. #define FX_UM_E1_DECAL 0x00000080
  105. #define FX_UM_E1_BLEND 0x00000100
  106. #define FX_UM_E1_ADD 0x00000200
  107. #define FX_UM_E_ENVMODE 0x000003ff
  108. #define FX_UM_E0_ALPHA 0x00001000
  109. #define FX_UM_E0_LUMINANCE 0x00002000
  110. #define FX_UM_E0_LUMINANCE_ALPHA 0x00004000
  111. #define FX_UM_E0_INTENSITY 0x00008000
  112. #define FX_UM_E0_RGB 0x00010000
  113. #define FX_UM_E0_RGBA 0x00020000
  114. #define FX_UM_E1_ALPHA 0x00040000
  115. #define FX_UM_E1_LUMINANCE 0x00080000
  116. #define FX_UM_E1_LUMINANCE_ALPHA 0x00100000
  117. #define FX_UM_E1_INTENSITY 0x00200000
  118. #define FX_UM_E1_RGB 0x00400000
  119. #define FX_UM_E1_RGBA 0x00800000
  120. #define FX_UM_E_IFMT 0x00fff000
  121. #define FX_UM_COLOR_ITERATED 0x01000000
  122. #define FX_UM_COLOR_CONSTANT 0x02000000
  123. #define FX_UM_ALPHA_ITERATED 0x04000000
  124. #define FX_UM_ALPHA_CONSTANT 0x08000000
  125. /* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */
  126. struct tdfx_combine {
  127. GrCombineFunction_t Function; /* Combine function */
  128. GrCombineFactor_t Factor; /* Combine scale factor */
  129. GrCombineLocal_t Local; /* Local combine source */
  130. GrCombineOther_t Other; /* Other combine source */
  131. FxBool Invert; /* Combine result inversion flag */
  132. };
  133. /* for Voodoo3's grTexCombine() */
  134. struct tdfx_texcombine {
  135. GrCombineFunction_t FunctionRGB;
  136. GrCombineFactor_t FactorRGB;
  137. GrCombineFunction_t FunctionAlpha;
  138. GrCombineFactor_t FactorAlpha;
  139. FxBool InvertRGB;
  140. FxBool InvertAlpha;
  141. };
  142. /* for Voodoo5's grColorCombineExt() */
  143. struct tdfx_combine_color_ext {
  144. GrCCUColor_t SourceA;
  145. GrCombineMode_t ModeA;
  146. GrCCUColor_t SourceB;
  147. GrCombineMode_t ModeB;
  148. GrCCUColor_t SourceC;
  149. FxBool InvertC;
  150. GrCCUColor_t SourceD;
  151. FxBool InvertD;
  152. FxU32 Shift;
  153. FxBool Invert;
  154. };
  155. /* for Voodoo5's grAlphaCombineExt() */
  156. struct tdfx_combine_alpha_ext {
  157. GrACUColor_t SourceA;
  158. GrCombineMode_t ModeA;
  159. GrACUColor_t SourceB;
  160. GrCombineMode_t ModeB;
  161. GrACUColor_t SourceC;
  162. FxBool InvertC;
  163. GrACUColor_t SourceD;
  164. FxBool InvertD;
  165. FxU32 Shift;
  166. FxBool Invert;
  167. };
  168. /* for Voodoo5's grTexColorCombineExt() */
  169. struct tdfx_color_texenv {
  170. GrTCCUColor_t SourceA;
  171. GrCombineMode_t ModeA;
  172. GrTCCUColor_t SourceB;
  173. GrCombineMode_t ModeB;
  174. GrTCCUColor_t SourceC;
  175. FxBool InvertC;
  176. GrTCCUColor_t SourceD;
  177. FxBool InvertD;
  178. FxU32 Shift;
  179. FxBool Invert;
  180. };
  181. /* for Voodoo5's grTexAlphaCombineExt() */
  182. struct tdfx_alpha_texenv {
  183. GrTACUColor_t SourceA;
  184. GrCombineMode_t ModeA;
  185. GrTACUColor_t SourceB;
  186. GrCombineMode_t ModeB;
  187. GrTACUColor_t SourceC;
  188. FxBool InvertC;
  189. GrTCCUColor_t SourceD;
  190. FxBool InvertD;
  191. FxU32 Shift;
  192. FxBool Invert;
  193. };
  194. /* Voodoo5's texture combine environment */
  195. struct tdfx_texcombine_ext {
  196. struct tdfx_alpha_texenv Alpha;
  197. struct tdfx_color_texenv Color;
  198. GrColor_t EnvColor;
  199. };
  200. /*
  201. Memory range from startAddr to endAddr-1
  202. */
  203. typedef struct MemRange_t
  204. {
  205. struct MemRange_t *next;
  206. FxU32 startAddr, endAddr;
  207. }
  208. MemRange;
  209. typedef struct
  210. {
  211. GLsizei width, height; /* image size */
  212. GLint wScale, hScale; /* image scale factor */
  213. GrTextureFormat_t glideFormat; /* Glide image format */
  214. }
  215. tfxMipMapLevel;
  216. /*
  217. * TDFX-specific texture object data. This hangs off of the
  218. * struct gl_texture_object DriverData pointer.
  219. */
  220. typedef struct tfxTexInfo_t
  221. {
  222. struct tfxTexInfo_t *next;
  223. struct gl_texture_object *tObj;
  224. GLuint lastTimeUsed;
  225. FxU32 whichTMU;
  226. GLboolean isInTM;
  227. MemRange *tm[FX_NUM_TMU];
  228. GLint minLevel, maxLevel;
  229. GLint baseLevelInternalFormat;
  230. GrTexInfo info;
  231. GrTextureFilterMode_t minFilt;
  232. GrTextureFilterMode_t maxFilt;
  233. FxBool LODblend;
  234. GrTextureClampMode_t sClamp;
  235. GrTextureClampMode_t tClamp;
  236. GrMipMapMode_t mmMode;
  237. GLfloat sScale, tScale;
  238. GrTexTable_t paltype;
  239. GuTexPalette palette;
  240. GLboolean fixedPalette;
  241. GLboolean validated;
  242. GLboolean padded;
  243. }
  244. tfxTexInfo;
  245. typedef struct
  246. {
  247. GLuint swapBuffer;
  248. GLuint reqTexUpload;
  249. GLuint texUpload;
  250. GLuint memTexUpload;
  251. }
  252. tfxStats;
  253. typedef struct
  254. {
  255. /* Alpha test */
  256. GLboolean alphaTestEnabled;
  257. GrCmpFnc_t alphaTestFunc;
  258. GLfloat alphaTestRefValue;
  259. /* Blend function */
  260. GLboolean blendEnabled;
  261. GrAlphaBlendFnc_t blendSrcFuncRGB;
  262. GrAlphaBlendFnc_t blendDstFuncRGB;
  263. GrAlphaBlendFnc_t blendSrcFuncAlpha;
  264. GrAlphaBlendFnc_t blendDstFuncAlpha;
  265. GrAlphaBlendOp_t blendEqRGB;
  266. GrAlphaBlendOp_t blendEqAlpha;
  267. /* Depth test */
  268. GLboolean depthTestEnabled;
  269. GLboolean depthMask;
  270. GrCmpFnc_t depthTestFunc;
  271. FxI32 depthBias;
  272. /* Stencil */
  273. GLboolean stencilEnabled;
  274. GrCmpFnc_t stencilFunction; /* Stencil function */
  275. GrStencil_t stencilRefValue; /* Stencil reference value */
  276. GrStencil_t stencilValueMask; /* Value mask */
  277. GrStencil_t stencilWriteMask; /* Write mask */
  278. GrCmpFnc_t stencilFailFunc; /* Stencil fail function */
  279. GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */
  280. GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */
  281. GrStencil_t stencilClear; /* Buffer clear value */
  282. }
  283. tfxUnitsState;
  284. /* Flags for fxMesa->new_state
  285. */
  286. #define FX_NEW_TEXTURING 0x1
  287. #define FX_NEW_BLEND 0x2
  288. #define FX_NEW_ALPHA 0x4
  289. #define FX_NEW_DEPTH 0x8
  290. #define FX_NEW_FOG 0x10
  291. #define FX_NEW_SCISSOR 0x20
  292. #define FX_NEW_COLOR_MASK 0x40
  293. #define FX_NEW_CULL 0x80
  294. #define FX_NEW_STENCIL 0x100
  295. #define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
  296. #define FX_TEXTURE_DATA(texUnit) fxTMGetTexInfo((texUnit)->_Current)
  297. #define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
  298. #define FX_MIPMAP_DATA(img) ((tfxMipMapLevel *) (img)->DriverData)
  299. #define BEGIN_BOARD_LOCK()
  300. #define END_BOARD_LOCK()
  301. #define BEGIN_CLIP_LOOP()
  302. #define END_CLIP_LOOP()
  303. /* Covers the state referenced by IsInHardware:
  304. */
  305. #define _FX_NEW_IS_IN_HARDWARE (_NEW_TEXTURE| \
  306. _NEW_HINT| \
  307. _NEW_STENCIL| \
  308. _NEW_BUFFERS| \
  309. _NEW_COLOR| \
  310. _NEW_LIGHT)
  311. /* Covers the state referenced by fxDDChooseRenderState
  312. */
  313. #define _FX_NEW_RENDERSTATE (_FX_NEW_IS_IN_HARDWARE | \
  314. _DD_NEW_FLATSHADE | \
  315. _DD_NEW_TRI_LIGHT_TWOSIDE| \
  316. _DD_NEW_TRI_OFFSET | \
  317. _DD_NEW_TRI_UNFILLED | \
  318. _DD_NEW_TRI_SMOOTH | \
  319. _DD_NEW_TRI_STIPPLE | \
  320. _DD_NEW_LINE_SMOOTH | \
  321. _DD_NEW_LINE_STIPPLE | \
  322. _DD_NEW_LINE_WIDTH | \
  323. _DD_NEW_POINT_SMOOTH | \
  324. _DD_NEW_POINT_SIZE | \
  325. _NEW_LINE)
  326. /* Covers the state referenced by fxDDChooseSetupFunction.
  327. */
  328. #define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
  329. _NEW_FOG| \
  330. _NEW_TEXTURE| \
  331. _NEW_COLOR) \
  332. /* lookup table for scaling y bit colors up to 8 bits */
  333. extern GLuint FX_rgb_scale_4[16];
  334. extern GLuint FX_rgb_scale_5[32];
  335. extern GLuint FX_rgb_scale_6[64];
  336. typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
  337. typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
  338. typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
  339. struct tfxMesaContext
  340. {
  341. GrTexTable_t glbPalType;
  342. GuTexPalette glbPalette;
  343. GLcontext *glCtx; /* the core Mesa context */
  344. GLvisual *glVis; /* describes the color buffer */
  345. GLframebuffer *glBuffer; /* the ancillary buffers */
  346. GLint board; /* the board used for this context */
  347. GLint width, height; /* size of color buffer */
  348. GrBuffer_t currentFB;
  349. GLboolean bgrOrder;
  350. GrColor_t color;
  351. GrColor_t clearC;
  352. GrAlpha_t clearA;
  353. GLuint constColor;
  354. GrCullMode_t cullMode;
  355. tfxUnitsState unitsState;
  356. tfxUnitsState restoreUnitsState; /* saved during multipass */
  357. GLboolean multipass; /* true when drawing intermediate pass */
  358. GLuint new_state;
  359. GLuint new_gl_state;
  360. /* Texture Memory Manager Data
  361. */
  362. GLuint texBindNumber;
  363. GLint tmuSrc;
  364. GLuint lastUnitsMode;
  365. GLuint freeTexMem[FX_NUM_TMU];
  366. MemRange *tmPool;
  367. MemRange *tmFree[FX_NUM_TMU];
  368. GLenum fogTableMode;
  369. GLfloat fogDensity;
  370. GLfloat fogStart, fogEnd;
  371. GrFog_t *fogTable;
  372. GLint textureAlign;
  373. GLint textureMaxLod;
  374. /* Vertex building and storage:
  375. */
  376. GLuint tmu_source[FX_NUM_TMU];
  377. GLuint SetupIndex;
  378. GLuint stw_hint_state; /* for grHints */
  379. GrVertex *verts;
  380. GLboolean snapVertices; /* needed for older Voodoo hardware */
  381. /* Rasterization:
  382. */
  383. GLuint render_index;
  384. GLuint fallback;
  385. GLenum render_primitive;
  386. GLenum raster_primitive;
  387. /* Current rasterization functions
  388. */
  389. fx_point_func draw_point;
  390. fx_line_func draw_line;
  391. fx_tri_func draw_tri;
  392. /* Keep texture scales somewhere handy:
  393. */
  394. GLfloat s0scale;
  395. GLfloat s1scale;
  396. GLfloat t0scale;
  397. GLfloat t1scale;
  398. GLfloat inv_s0scale;
  399. GLfloat inv_s1scale;
  400. GLfloat inv_t0scale;
  401. GLfloat inv_t1scale;
  402. /* Glide stuff
  403. */
  404. tfxStats stats;
  405. void *state;
  406. /* Options */
  407. GLboolean verbose;
  408. GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
  409. GLboolean haveHwAlpha;
  410. GLboolean haveHwStencil;
  411. GLboolean haveZBuffer;
  412. GLboolean haveDoubleBuffer;
  413. GLboolean haveGlobalPaletteTexture;
  414. GLint swapInterval;
  415. GLint maxPendingSwapBuffers;
  416. GrContext_t glideContext;
  417. int screen_width;
  418. int screen_height;
  419. int clipMinX;
  420. int clipMaxX;
  421. int clipMinY;
  422. int clipMaxY;
  423. int colDepth;
  424. GLboolean fsaa;
  425. /* Glide (per card) capabilities. These get mirrored
  426. * from `glbHWConfig' when creating a new context...
  427. */
  428. GrSstType type;
  429. FxBool HavePalExt; /* PALETTE6666 */
  430. FxBool HavePixExt; /* PIXEXT */
  431. FxBool HaveTexFmt; /* TEXFMT */
  432. FxBool HaveCmbExt; /* COMBINE */
  433. FxBool HaveMirExt; /* TEXMIRROR */
  434. FxBool HaveTexUma; /* TEXUMA */
  435. FxBool HaveTexus2; /* Texus 2 - FXT1 */
  436. struct tdfx_glide Glide;
  437. char rendererString[64];
  438. };
  439. extern void fxSetupFXUnits(GLcontext *);
  440. extern void fxSetupDDPointers(GLcontext *);
  441. /* fxvb.c:
  442. */
  443. extern void fxAllocVB(GLcontext * ctx);
  444. extern void fxFreeVB(GLcontext * ctx);
  445. extern void fxPrintSetupFlags(char *msg, GLuint flags );
  446. extern void fxCheckTexSizes( GLcontext *ctx );
  447. extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
  448. GLuint newinputs );
  449. extern void fxChooseVertexState( GLcontext *ctx );
  450. /* fxtrifuncs:
  451. */
  452. extern void fxDDInitTriFuncs(GLcontext *);
  453. extern void fxDDChooseRenderState(GLcontext * ctx);
  454. extern void fxUpdateDDSpanPointers(GLcontext *);
  455. extern void fxSetupDDSpanPointers(GLcontext *);
  456. extern void fxPrintTextureData(tfxTexInfo * ti);
  457. extern const struct gl_texture_format *
  458. fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
  459. GLenum srcFormat, GLenum srcType );
  460. extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
  461. GLint internalFormat, GLint width, GLint height,
  462. GLint border, GLenum format, GLenum type,
  463. const GLvoid * pixels,
  464. const struct gl_pixelstore_attrib *packing,
  465. struct gl_texture_object *texObj,
  466. struct gl_texture_image *texImage);
  467. extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
  468. GLint xoffset, GLint yoffset,
  469. GLsizei width, GLsizei height,
  470. GLenum format, GLenum type,
  471. const GLvoid * pixels,
  472. const struct gl_pixelstore_attrib *packing,
  473. struct gl_texture_object *texObj,
  474. struct gl_texture_image *texImage);
  475. extern void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target,
  476. GLint level, GLint internalFormat,
  477. GLsizei width, GLsizei height, GLint border,
  478. GLsizei imageSize, const GLvoid *data,
  479. struct gl_texture_object *texObj,
  480. struct gl_texture_image *texImage);
  481. extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target,
  482. GLint level, GLint xoffset,
  483. GLint yoffset, GLsizei width,
  484. GLint height, GLenum format,
  485. GLsizei imageSize, const GLvoid *data,
  486. struct gl_texture_object *texObj,
  487. struct gl_texture_image *texImage);
  488. extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
  489. GLint internalFormat, GLint width,
  490. GLint border, GLenum format, GLenum type,
  491. const GLvoid * pixels,
  492. const struct gl_pixelstore_attrib *packing,
  493. struct gl_texture_object *texObj,
  494. struct gl_texture_image *texImage);
  495. extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
  496. GLint xoffset, GLint width,
  497. GLenum format, GLenum type,
  498. const GLvoid * pixels,
  499. const struct gl_pixelstore_attrib *packing,
  500. struct gl_texture_object *texObj,
  501. struct gl_texture_image *texImage);
  502. extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
  503. GLint level, GLint internalFormat,
  504. GLenum format, GLenum type,
  505. GLint width, GLint height,
  506. GLint depth, GLint border);
  507. extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
  508. extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
  509. GLenum, const GLfloat *);
  510. extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
  511. extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
  512. extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
  513. extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
  514. extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
  515. extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
  516. extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
  517. extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat);
  518. extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum);
  519. extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum);
  520. extern void fxDDDepthMask(GLcontext *, GLboolean);
  521. extern void fxDDDepthFunc(GLcontext *, GLenum);
  522. extern void fxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func, GLint ref, GLuint mask);
  523. extern void fxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask);
  524. extern void fxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail, GLenum zfail, GLenum zpass);
  525. extern void fxDDInitExtensions(GLcontext * ctx);
  526. extern void fxTMInit(fxMesaContext ctx);
  527. extern void fxTMClose(fxMesaContext ctx);
  528. extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
  529. extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
  530. extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
  531. #define fxTMMoveOutTM_NoLock fxTMMoveOutTM
  532. extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
  533. extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *,
  534. GLint);
  535. extern void fxTMReloadSubMipMapLevel(fxMesaContext,
  536. struct gl_texture_object *, GLint, GLint,
  537. GLint);
  538. extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti);
  539. extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */
  540. extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
  541. float *, float *, int *, int *);
  542. extern void fxDDScissor(GLcontext * ctx,
  543. GLint x, GLint y, GLsizei w, GLsizei h);
  544. extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params);
  545. extern void fxDDColorMask(GLcontext * ctx,
  546. GLboolean r, GLboolean g, GLboolean b, GLboolean a);
  547. extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
  548. const GLuint depth[], const GLubyte mask[]);
  549. extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
  550. GLuint depth[]);
  551. extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
  552. const GLint x[], const GLint y[],
  553. const GLuint depth[], const GLubyte mask[]);
  554. extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
  555. const GLint x[], const GLint y[],
  556. GLuint depth[]);
  557. extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
  558. extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
  559. extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
  560. extern void fxPrintRenderState(const char *msg, GLuint state);
  561. extern void fxPrintHintState(const char *msg, GLuint state);
  562. extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
  563. extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
  564. extern void fxSetScissorValues(GLcontext * ctx);
  565. extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
  566. struct gl_texture_object *tObj, GLint where);
  567. extern void fxCheckIsInHardware(GLcontext *ctx);
  568. /* fxsetup:
  569. * semi-private functions
  570. */
  571. void fxSetupCull (GLcontext * ctx);
  572. void fxSetupScissor (GLcontext * ctx);
  573. void fxSetupColorMask (GLcontext * ctx);
  574. void fxSetupBlend (GLcontext *ctx);
  575. void fxSetupDepthTest (GLcontext *ctx);
  576. void fxSetupTexture (GLcontext *ctx);
  577. void fxSetupStencil (GLcontext *ctx);
  578. void fxSetupStencilFace (GLcontext *ctx, GLint face);
  579. /* Flags for software fallback cases */
  580. #define FX_FALLBACK_TEXTURE_MAP 0x0001
  581. #define FX_FALLBACK_DRAW_BUFFER 0x0002
  582. #define FX_FALLBACK_SPECULAR 0x0004
  583. #define FX_FALLBACK_STENCIL 0x0008
  584. #define FX_FALLBACK_RENDER_MODE 0x0010
  585. #define FX_FALLBACK_LOGICOP 0x0020
  586. #define FX_FALLBACK_TEXTURE_ENV 0x0040
  587. #define FX_FALLBACK_TEXTURE_BORDER 0x0080
  588. #define FX_FALLBACK_COLORMASK 0x0100
  589. #define FX_FALLBACK_BLEND 0x0200
  590. #define FX_FALLBACK_TEXTURE_MULTI 0x0400
  591. extern GLuint fx_check_IsInHardware(GLcontext *ctx);
  592. /***
  593. *** CNORM: clamp float to [0,1] and map to float in [0,255]
  594. ***/
  595. #if defined(USE_IEEE) && !defined(DEBUG)
  596. #define IEEE_0996 0x3f7f0000 /* 0.996 or so */
  597. #define CNORM(N, F) \
  598. do { \
  599. fi_type __tmp; \
  600. __tmp.f = (F); \
  601. if (__tmp.i < 0) \
  602. N = 0; \
  603. else if (__tmp.i >= IEEE_0996) \
  604. N = 255.0f; \
  605. else { \
  606. N = (F) * 255.0f; \
  607. } \
  608. } while (0)
  609. #else
  610. #define CNORM(n, f) \
  611. n = (CLAMP((f), 0.0F, 1.0F) * 255.0F)
  612. #endif
  613. /* run-time debugging */
  614. #ifndef FX_DEBUG
  615. #define FX_DEBUG 0
  616. #endif
  617. #if FX_DEBUG
  618. extern int TDFX_DEBUG;
  619. #else
  620. #define TDFX_DEBUG 0
  621. #endif
  622. /* dirty hacks */
  623. #define FX_RESCALE_BIG_TEXURES_HACK 1
  624. #define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
  625. #endif