📄 tdfx_tex.c
字号:
break; } ti->reloadImages = GL_TRUE; RevalidateTexture(ctx, tObj); fxMesa->new_state |= TDFX_NEW_TEXTURE; break; case GL_TEXTURE_MAG_FILTER: switch (param) { case GL_NEAREST: ti->magFilt = GR_TEXTUREFILTER_POINT_SAMPLED; break; case GL_LINEAR: ti->magFilt = GR_TEXTUREFILTER_BILINEAR; break; default: break; } fxMesa->new_state |= TDFX_NEW_TEXTURE; break; case GL_TEXTURE_WRAP_S: switch (param) { case GL_CLAMP_TO_BORDER: case GL_CLAMP_TO_EDGE: case GL_CLAMP: ti->sClamp = GR_TEXTURECLAMP_CLAMP; break; case GL_REPEAT: ti->sClamp = GR_TEXTURECLAMP_WRAP; break; case GL_MIRRORED_REPEAT: ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT; break; default: break; } fxMesa->new_state |= TDFX_NEW_TEXTURE; break; case GL_TEXTURE_WRAP_T: switch (param) { case GL_CLAMP_TO_BORDER: case GL_CLAMP_TO_EDGE: case GL_CLAMP: ti->tClamp = GR_TEXTURECLAMP_CLAMP; break; case GL_REPEAT: ti->tClamp = GR_TEXTURECLAMP_WRAP; break; case GL_MIRRORED_REPEAT: ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT; break; default: break; } fxMesa->new_state |= TDFX_NEW_TEXTURE; break; case GL_TEXTURE_BORDER_COLOR: /* TO DO */ break; case GL_TEXTURE_MIN_LOD: /* TO DO */ break; case GL_TEXTURE_MAX_LOD: /* TO DO */ break; case GL_TEXTURE_BASE_LEVEL: RevalidateTexture(ctx, tObj); break; case GL_TEXTURE_MAX_LEVEL: RevalidateTexture(ctx, tObj); break; default: break; }}/* * Called via glDeleteTextures to delete a texture object. * Here, we delete the Glide data associated with the texture. */static voidtdfxDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj){ if (ctx && ctx->DriverCtx) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxTMFreeTexture(fxMesa, tObj); fxMesa->new_state |= TDFX_NEW_TEXTURE; /* Free mipmap images and the texture object itself */ _mesa_delete_texture_object(ctx, tObj); }}/* * Return true if texture is resident, false otherwise. */static GLbooleantdfxIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj){ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); return (GLboolean) (ti && ti->isInTM);}/* * Convert a gl_color_table texture palette to Glide's format. */static GrTexTable_tconvertPalette(FxU32 data[256], const struct gl_color_table *table){ const GLubyte *tableUB = table->TableUB; GLint width = table->Size; FxU32 r, g, b, a; GLint i; switch (table->_BaseFormat) { case GL_INTENSITY: for (i = 0; i < width; i++) { r = tableUB[i]; g = tableUB[i]; b = tableUB[i]; a = tableUB[i]; data[i] = (a << 24) | (r << 16) | (g << 8) | b; } return GR_TEXTABLE_PALETTE_6666_EXT; case GL_LUMINANCE: for (i = 0; i < width; i++) { r = tableUB[i]; g = tableUB[i]; b = tableUB[i]; a = 255; data[i] = (a << 24) | (r << 16) | (g << 8) | b; } return GR_TEXTABLE_PALETTE; case GL_ALPHA: for (i = 0; i < width; i++) { r = g = b = 255; a = tableUB[i]; data[i] = (a << 24) | (r << 16) | (g << 8) | b; } return GR_TEXTABLE_PALETTE_6666_EXT; case GL_LUMINANCE_ALPHA: for (i = 0; i < width; i++) { r = g = b = tableUB[i * 2 + 0]; a = tableUB[i * 2 + 1]; data[i] = (a << 24) | (r << 16) | (g << 8) | b; } return GR_TEXTABLE_PALETTE_6666_EXT; case GL_RGB: for (i = 0; i < width; i++) { r = tableUB[i * 3 + 0]; g = tableUB[i * 3 + 1]; b = tableUB[i * 3 + 2]; a = 255; data[i] = (a << 24) | (r << 16) | (g << 8) | b; } return GR_TEXTABLE_PALETTE; case GL_RGBA: for (i = 0; i < width; i++) { r = tableUB[i * 4 + 0]; g = tableUB[i * 4 + 1]; b = tableUB[i * 4 + 2]; a = tableUB[i * 4 + 3]; data[i] = (a << 24) | (r << 16) | (g << 8) | b; } return GR_TEXTABLE_PALETTE_6666_EXT; default: /* XXX fixme: how can this happen? */ _mesa_error(NULL, GL_INVALID_ENUM, "convertPalette: table->Format == %s", _mesa_lookup_enum_by_nr(table->Format)); return GR_TEXTABLE_PALETTE; }}static voidtdfxUpdateTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); if (tObj) { /* per-texture palette */ tdfxTexInfo *ti; /* This might be a proxy texture. */ if (!tObj->Palette.TableUB) return; if (!tObj->DriverData) tObj->DriverData = fxAllocTexObjData(fxMesa); ti = TDFX_TEXTURE_DATA(tObj); assert(ti); ti->paltype = convertPalette(ti->palette.data, &tObj->Palette); /*tdfxTexInvalidate(ctx, tObj);*/ } else { /* global texture palette */ fxMesa->TexPalette.Type = convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette); fxMesa->TexPalette.Data = &(fxMesa->glbPalette.data); fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; } fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX too heavy-handed */}/**********************************************************************//**** NEW TEXTURE IMAGE FUNCTIONS ****//**********************************************************************/#if 000static FxBool TexusFatalError = FXFALSE;static FxBool TexusError = FXFALSE;#define TX_DITHER_NONE 0x00000000static voidfxTexusError(const char *string, FxBool fatal){ _mesa_problem(NULL, string); /* * Just propagate the fatal value up. */ TexusError = FXTRUE; TexusFatalError = fatal;}#endifstatic const struct gl_texture_format *tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat, GLenum srcFormat, GLenum srcType ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); const GLboolean allow32bpt = TDFX_IS_NAPALM(fxMesa); switch (internalFormat) { case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: case GL_COMPRESSED_ALPHA: return &_mesa_texformat_a8; case 1: case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: case GL_COMPRESSED_LUMINANCE: return &_mesa_texformat_l8; case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: case GL_LUMINANCE6_ALPHA2: case GL_LUMINANCE8_ALPHA8: case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: return &_mesa_texformat_al88; case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: case GL_COMPRESSED_INTENSITY: return &_mesa_texformat_i8; case GL_R3_G3_B2: case GL_RGB4: case GL_RGB5: return &_mesa_texformat_rgb565; case GL_COMPRESSED_RGB: /* intentional fall-through */ case 3: case GL_RGB: if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) { return &_mesa_texformat_rgb565; } /* intentional fall through */ case GL_RGB8: case GL_RGB10: case GL_RGB12: case GL_RGB16: return (allow32bpt) ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565; case GL_RGBA2: case GL_RGBA4: return &_mesa_texformat_argb4444; case GL_COMPRESSED_RGBA: /* intentional fall-through */ case 4: case GL_RGBA: if ( srcFormat == GL_BGRA ) { if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) { return &_mesa_texformat_argb8888; } else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { return &_mesa_texformat_argb4444; } else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { return &_mesa_texformat_argb1555; } } /* intentional fall through */ case GL_RGBA8: case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: return allow32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; case GL_RGB5_A1: return &_mesa_texformat_argb1555; case GL_COLOR_INDEX: case GL_COLOR_INDEX1_EXT: case GL_COLOR_INDEX2_EXT: case GL_COLOR_INDEX4_EXT: case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: return &_mesa_texformat_ci8; /* GL_EXT_texture_compression_s3tc */ /* GL_S3_s3tc */ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_RGB_S3TC: case GL_RGB4_S3TC: return &_mesa_texformat_rgb_dxt1; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return &_mesa_texformat_rgba_dxt1; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_RGBA_S3TC: case GL_RGBA4_S3TC: return &_mesa_texformat_rgba_dxt3; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return &_mesa_texformat_rgba_dxt5; /* GL_3DFX_texture_compression_FXT1 */ case GL_COMPRESSED_RGB_FXT1_3DFX: return &_mesa_texformat_rgb_fxt1; case GL_COMPRESSED_RGBA_FXT1_3DFX: return &_mesa_texformat_rgba_fxt1; default: _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat"); return NULL; }}/* * Return the Glide format for the given mesa texture format. */static GrTextureFormat_tfxGlideFormat(GLint mesaFormat){ switch (mesaFormat) { case MESA_FORMAT_I8: return GR_TEXFMT_ALPHA_8; case MESA_FORMAT_A8: return GR_TEXFMT_ALPHA_8; case MESA_FORMAT_L8: return GR_TEXFMT_INTENSITY_8; case MESA_FORMAT_CI8: return GR_TEXFMT_P_8; case MESA_FORMAT_AL88: return GR_TEXFMT_ALPHA_INTENSITY_88; case MESA_FORMAT_RGB565: return GR_TEXFMT_RGB_565; case MESA_FORMAT_ARGB4444: return GR_TEXFMT_ARGB_4444; case MESA_FORMAT_ARGB1555: return GR_TEXFMT_ARGB_1555; case MESA_FORMAT_ARGB8888: return GR_TEXFMT_ARGB_8888; case MESA_FORMAT_RGB_FXT1: case MESA_FORMAT_RGBA_FXT1: return GR_TEXFMT_ARGB_CMP_FXT1; case MESA_FORMAT_RGB_DXT1: case MESA_FORMAT_RGBA_DXT1: return GR_TEXFMT_ARGB_CMP_DXT1; case MESA_FORMAT_RGBA_DXT3: return GR_TEXFMT_ARGB_CMP_DXT3; case MESA_FORMAT_RGBA_DXT5: return GR_TEXFMT_ARGB_CMP_DXT5; default: _mesa_problem(NULL, "Unexpected format in fxGlideFormat"); return 0; }}/* Texel-fetch functions for software texturing and glGetTexImage(). * We should have been able to use some "standard" fetch functions (which * may get defined in texutil.c) but we have to account for scaled texture * images on tdfx hardware (the 8:1 aspect ratio limit). * Hence, we need special functions here. */extern voidfxt1_decode_1 (const void *texture, int width, int i, int j, unsigned char *rgba);static voidfetch_intensity8(const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan * rgba){ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); const GLubyte *texel; i = i * mml->wScale; j = j * mml->hScale; texel = ((GLubyte *) texImage->Data) + j * mml->width + i; rgba[RCOMP] = *texel; rgba[GCOMP] = *texel; rgba[BCOMP] = *texel; rgba[ACOMP] = *texel;}static voidfetch_luminance8(const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan * rgba){ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); const GLubyte *texel; i = i * mml->wScale; j = j * mml->hScale; texel = ((GLubyte *) texImage->Data) + j * mml->width + i; rgba[RCOMP] = *texel; rgba[GCOMP] = *texel; rgba[BCOMP] = *texel; rgba[ACOMP] = 255;}static voidfetch_alpha8(const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan * rgba){ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); const GLubyte *texel; i = i * mml->wScale; j = j * mml->hScale; texel = ((GLubyte *) texImage->Data) + j * mml->width + i; rgba[RCOMP] = 255; rgba[GCOMP] = 255; rgba[BCOMP] = 255; rgba[ACOMP] = *texel;}static voidfetch_index8(const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan * indexOut){ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); const GLubyte *texel; i = i * mml->wScale; j = j * mml->hScale; texel = ((GLubyte *) texImage->Data) + j * mml->width + i; *indexOut = *texel;}static voidfetch_luminance8_alpha8(const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan * rgba){ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -