diff options
author | Daniel Borca <[email protected]> | 2003-10-29 14:40:43 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2003-10-29 14:40:43 +0000 |
commit | 63a5ca08f3bdaee975c9b059caf15ffd3ddd8d38 (patch) | |
tree | da2360538c52cd5b16a6edb60388d97026c30103 /src/mesa/drivers/glide/fxg.c | |
parent | 40bd9d0b190e11d39350d1b08d2c2b28e3040bca (diff) |
changes to accomodate texture compression
Diffstat (limited to 'src/mesa/drivers/glide/fxg.c')
-rw-r--r-- | src/mesa/drivers/glide/fxg.c | 192 |
1 files changed, 185 insertions, 7 deletions
diff --git a/src/mesa/drivers/glide/fxg.c b/src/mesa/drivers/glide/fxg.c index bb162c5808c..1ead397fddb 100644 --- a/src/mesa/drivers/glide/fxg.c +++ b/src/mesa/drivers/glide/fxg.c @@ -40,17 +40,25 @@ #define DEBUG_TRAP_internal #include "fxg.h" +/* texus.h */ +FX_ENTRY int FX_CALL txBitsPerPixel (GrTextureFormat_t format); +FX_ENTRY void FX_CALL txImgQuantize (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither); +FX_ENTRY void FX_CALL txMipQuantize (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp); +FX_ENTRY void FX_CALL txPalToNcc (GuNccTable *ncc_table, const FxU32 *pal); +FX_ENTRY void FX_CALL txErrorSetCallback (TxErrorCallbackFnc_t fnc, TxErrorCallbackFnc_t *old_fnc); +/* texus.h */ + /****************************************************************************\ * logging * \****************************************************************************/ #if DEBUG_TRAP -#define TRAP_LOG trap_printf +#define TRAP_LOG trp_printf #ifdef __GNUC__ __attribute__ ((format(printf, 1, 2))) #endif /* __GNUC__ */ -int trap_printf (const char *format, ...) +int trp_printf (const char *format, ...) { va_list arg; int n; @@ -234,8 +242,10 @@ const char *TRP_BLEND (GrAlphaBlendFnc_t func) TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SRC_COLOR); /*TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_DST_COLOR); ==GR_BLEND_ONE_MINUS_SRC_COLOR*/ TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_DST_ALPHA); - TRAP_CASE_STRING(GR_BLEND_RESERVED_8); - TRAP_CASE_STRING(GR_BLEND_RESERVED_9); + TRAP_CASE_STRING(GR_BLEND_SAME_COLOR_EXT); + /*TRAP_CASE_STRING(GR_BLEND_RESERVED_8); ==GR_BLEND_SAME_COLOR_EXT*/ + TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SAME_COLOR_EXT); + /*TRAP_CASE_STRING(GR_BLEND_RESERVED_9); ==GR_BLEND_ONE_MINUS_SAME_COLOR_EXT*/ TRAP_CASE_STRING(GR_BLEND_RESERVED_A); TRAP_CASE_STRING(GR_BLEND_RESERVED_B); TRAP_CASE_STRING(GR_BLEND_RESERVED_C); @@ -243,8 +253,6 @@ const char *TRP_BLEND (GrAlphaBlendFnc_t func) TRAP_CASE_STRING(GR_BLEND_RESERVED_E); TRAP_CASE_STRING(GR_BLEND_ALPHA_SATURATE); /*TRAP_CASE_STRING(GR_BLEND_PREFOG_COLOR); ==GR_BLEND_ALPHA_SATURATE*/ - TRAP_CASE_STRING(GR_BLEND_SAME_COLOR_EXT); - TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SAME_COLOR_EXT); TRAP_NODEFAULT; } } @@ -785,6 +793,25 @@ const char *TRP_TMU (GrChipID_t tmu) } } +const char *TRP_TXDITHER (FxU32 dither) +{ + switch (dither) { + TRAP_CASE_STRING(TX_DITHER_NONE); + TRAP_CASE_STRING(TX_DITHER_4x4); + TRAP_CASE_STRING(TX_DITHER_ERR); + TRAP_NODEFAULT; + } +} + +const char *TRP_TXCOMPRESS (FxU32 compress) +{ + switch (compress) { + TRAP_CASE_STRING(TX_COMPRESSION_STATISTICAL); + TRAP_CASE_STRING(TX_COMPRESSION_HEURISTIC); + TRAP_NODEFAULT; + } +} + /****************************************************************************\ @@ -801,6 +828,11 @@ void (FX_CALL *real_grChromaRangeExt) (GrColor_t color, GrColor_t range, GrChrom void (FX_CALL *real_grTexChromaModeExt) (GrChipID_t tmu, GrChromakeyMode_t mode); void (FX_CALL *real_grTexChromaRangeExt) (GrChipID_t tmu, GrColor_t min, GrColor_t max, GrTexChromakeyMode_t mode); +/* pointcast */ +void (FX_CALL *real_grTexDownloadTableExt) (GrChipID_t tmu, GrTexTable_t type, void *data); +void (FX_CALL *real_grTexDownloadTablePartialExt) (GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end); +void (FX_CALL *real_grTexNCCTableExt) (GrChipID_t tmu, GrNCCTable_t table); + /* tbext */ void (FX_CALL *real_grTextureBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask); void (FX_CALL *real_grTextureAuxBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask); @@ -1859,6 +1891,41 @@ void FX_CALL trap_grTexChromaRangeExt (GrChipID_t tmu, #undef FN_NAME } + /* pointcast */ +void FX_CALL trap_grTexDownloadTableExt (GrChipID_t tmu, + GrTexTable_t type, + void *data) +{ +#define FN_NAME "grTexDownloadTableExt" + TRAP_LOG("%s(%s, %s, %p)\n", FN_NAME, TRP_TMU(tmu), TRP_TABLE(type), data); + assert(real_grTexDownloadTableExt); + (*real_grTexDownloadTableExt)(tmu, type, data); +#undef FN_NAME +} + +void FX_CALL trap_grTexDownloadTablePartialExt (GrChipID_t tmu, + GrTexTable_t type, + void *data, + int start, + int end) +{ +#define FN_NAME "grTexDownloadTablePartialExt" + TRAP_LOG("%s(%s, %s, %p, %d, %d)\n", FN_NAME, TRP_TMU(tmu), TRP_TABLE(type), data, start, end); + assert(real_grTexDownloadTablePartialExt); + (*real_grTexDownloadTablePartialExt)(tmu, type, data, start, end); +#undef FN_NAME +} + +void FX_CALL trap_grTexNCCTableExt (GrChipID_t tmu, + GrNCCTable_t table) +{ +#define FN_NAME "grTexNCCTableExt" + TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_NCC(table)); + assert(real_grTexNCCTableExt); + (*real_grTexNCCTableExt)(tmu, table); +#undef FN_NAME +} + /* tbext */ void FX_CALL trap_grTextureBufferExt (GrChipID_t tmu, FxU32 startAddress, @@ -2089,19 +2156,105 @@ void FX_CALL trap_grTBufferWriteMaskExt (FxU32 tmask) (*real_grTBufferWriteMaskExt)(tmask); #undef FN_NAME } + +/* +** texus functions +*/ +int FX_CALL trap_txBitsPerPixel (GrTextureFormat_t format) +{ +#define FN_NAME "txBitsPerPixel" + int rv; + TRAP_LOG("%s(%s)\n", FN_NAME, TRP_TEXFMT(format)); + rv = txBitsPerPixel(format); + TRAP_LOG(GOT "%d\n", rv); + return rv; +#undef FN_NAME +} + +void FX_CALL trap_txImgQuantize (char *dst, + char *src, + int w, + int h, + FxU32 format, + FxU32 dither) +{ +#define FN_NAME "txImgQuantize" + TRAP_LOG("%s(%p, %p, %d, %d, %s, %s)\n", FN_NAME, dst, src, w, h, TRP_TEXFMT(format), TRP_TXDITHER(dither)); + txImgQuantize(dst, src, w, h, format, dither); +#undef FN_NAME +} + +void FX_CALL trap_txMipQuantize (TxMip *pxMip, + TxMip *txMip, + int fmt, + FxU32 d, + FxU32 comp) +{ +#define FN_NAME "txMipQuantize" + TRAP_LOG("%s(%p, %p, %s, %s, %s)\n", FN_NAME, (void *)pxMip, (void *)txMip, TRP_TEXFMT(fmt), TRP_TXDITHER(d), TRP_TXCOMPRESS(comp)); + txMipQuantize(pxMip, txMip, fmt, d, comp); +#undef FN_NAME +} + +void FX_CALL trap_txPalToNcc (GuNccTable *ncc_table, + const FxU32 *pal) +{ +#define FN_NAME "txPalToNcc" + TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)ncc_table, (void *)pal); + txPalToNcc(ncc_table, pal); +#undef FN_NAME +} + +void FX_CALL trap_txErrorSetCallback (TxErrorCallbackFnc_t fnc, + TxErrorCallbackFnc_t *old_fnc) +{ +#define FN_NAME "txErrorSetCallback" + TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)fnc, (void *)old_fnc); + txErrorSetCallback(fnc, old_fnc); +#undef FN_NAME +} #endif /****************************************************************************\ +* housekeeping (fake pointers) +\****************************************************************************/ +void FX_CALL fake_grTexDownloadTableExt (GrChipID_t tmu, + GrTexTable_t type, + void *data) +{ + grTexDownloadTable(type, data); +} + +void FX_CALL fake_grTexDownloadTablePartialExt (GrChipID_t tmu, + GrTexTable_t type, + void *data, + int start, + int end) +{ + grTexDownloadTablePartial(type, data, start, end); +} + +void FX_CALL fake_grTexNCCTableExt (GrChipID_t tmu, + GrNCCTable_t table) +{ + grTexNCCTable(table); +} + + + +/****************************************************************************\ * interface \****************************************************************************/ void tdfx_hook_glide (struct tdfx_glide *Glide) { #if DEBUG_TRAP #define GET_EXT_ADDR(name) *(GrProc *)&real_##name = grGetProcAddress(#name), Glide->name = trap_##name +#define GET_TXS_ADDR(name) Glide->name = trap_##name #else /* DEBUG_TRAP */ #define GET_EXT_ADDR(name) *(GrProc *)&Glide->name = grGetProcAddress(#name) +#define GET_TXS_ADDR(name) Glide->name = name #endif /* DEBUG_TRAP */ /* @@ -2113,6 +2266,10 @@ void tdfx_hook_glide (struct tdfx_glide *Glide) GET_EXT_ADDR(grChromaRangeExt); GET_EXT_ADDR(grTexChromaModeExt); GET_EXT_ADDR(grTexChromaRangeExt); + /* pointcast */ + GET_EXT_ADDR(grTexDownloadTableExt); + GET_EXT_ADDR(grTexDownloadTablePartialExt); + GET_EXT_ADDR(grTexNCCTableExt); /* tbext */ GET_EXT_ADDR(grTextureBufferExt); GET_EXT_ADDR(grTextureAuxBufferExt); @@ -2133,8 +2290,29 @@ void tdfx_hook_glide (struct tdfx_glide *Glide) GET_EXT_ADDR(grAlphaBlendFunctionExt); GET_EXT_ADDR(grTBufferWriteMaskExt); + /* + ** texus + */ + GET_TXS_ADDR(txBitsPerPixel); + GET_TXS_ADDR(txImgQuantize); + GET_TXS_ADDR(txMipQuantize); + GET_TXS_ADDR(txPalToNcc); + GET_TXS_ADDR(txErrorSetCallback); + + /* housekeeping: make sure the pointcast always point to something valid */ + if (grGetProcAddress("grTexDownloadTableExt") == NULL) { +#if DEBUG_TRAP + real_grTexDownloadTableExt = fake_grTexDownloadTableExt; + real_grTexDownloadTablePartialExt = fake_grTexDownloadTablePartialExt; + real_grTexNCCTableExt = fake_grTexNCCTableExt; +#else + Glide->grTexDownloadTableExt = fake_grTexDownloadTableExt; + Glide->grTexDownloadTablePartialExt = fake_grTexDownloadTablePartialExt; + Glide->grTexNCCTableExt = fake_grTexNCCTableExt; +#endif + } + #undef GET_EXT_ADDR } - #endif /* FX */ |