From 4fe1303e833183319f50107a98b8627f36633c65 Mon Sep 17 00:00:00 2001 From: Daniel Borca Date: Thu, 29 Jan 2004 15:46:02 +0000 Subject: GL_TEXTURE_1D and other stories... --- src/mesa/drivers/glide/fxdd.c | 35 ++++++++++++++++++++-------- src/mesa/drivers/glide/fxddtex.c | 50 +++++++++++++++++++++++++++++++++++----- src/mesa/drivers/glide/fxdrv.h | 14 ++++++++++- src/mesa/drivers/glide/fxsetup.c | 23 +++++++++--------- src/mesa/drivers/glide/fxsetup.h | 8 +++---- src/mesa/drivers/glide/fxtris.c | 2 +- src/mesa/drivers/glide/fxwgl.c | 10 +++++++- 7 files changed, 109 insertions(+), 33 deletions(-) (limited to 'src/mesa/drivers/glide') diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index ef73f79641..448fd043d0 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1501,6 +1501,11 @@ fxDDInitExtensions(GLcontext * ctx) /* core-level extensions */ #if 1 _mesa_enable_extension(ctx, "GL_ARB_vertex_buffer_object"); +#endif + /* not just yet */ +#if 0 + _mesa_enable_extension(ctx, "GL_ARB_fragment_program"); + _mesa_enable_extension(ctx, "GL_ARB_vertex_program"); #endif } @@ -1540,6 +1545,13 @@ fx_check_IsInHardware(GLcontext * ctx) } } + /* [dBorca] + * We could avoid this for certain `sfactor/dfactor' + * I do not think that is even worthwhile to check + * because if someone is using blending they use more + * interesting settings and also it would add more + * state tracking to a lot of the code. + */ if (ctx->Color.ColorLogicOpEnabled && (ctx->Color.LogicOp != GL_COPY)) { return FX_FALLBACK_LOGICOP; } @@ -1558,17 +1570,18 @@ fx_check_IsInHardware(GLcontext * ctx) /* Unsupported texture/multitexture cases */ + /* we can only do 1D/2D textures */ + if (ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) + return FX_FALLBACK_TEXTURE_MAP; + if (fxMesa->haveTwoTMUs) { - /* we can only do 2D textures */ - if (ctx->Texture.Unit[0]._ReallyEnabled & ~TEXTURE_2D_BIT) - return FX_FALLBACK_TEXTURE_1D_3D; - if (ctx->Texture.Unit[1]._ReallyEnabled & ~TEXTURE_2D_BIT) - return FX_FALLBACK_TEXTURE_1D_3D; + if (ctx->Texture.Unit[1]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) + return FX_FALLBACK_TEXTURE_MAP; - if (ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_2D_BIT) { + if (ctx->Texture.Unit[0]._ReallyEnabled) { if (fxMesa->type < GR_SSTTYPE_Voodoo2) if (ctx->Texture.Unit[0].EnvMode == GL_BLEND && - (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_2D_BIT || + (ctx->Texture.Unit[1]._ReallyEnabled || ctx->Texture.Unit[0].EnvColor[0] != 0 || ctx->Texture.Unit[0].EnvColor[1] != 0 || ctx->Texture.Unit[0].EnvColor[2] != 0 || @@ -1579,7 +1592,7 @@ fx_check_IsInHardware(GLcontext * ctx) return FX_FALLBACK_TEXTURE_BORDER; } - if (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_2D_BIT) { + if (ctx->Texture.Unit[1]._ReallyEnabled) { if (fxMesa->type < GR_SSTTYPE_Voodoo2) if (ctx->Texture.Unit[1].EnvMode == GL_BLEND) return FX_FALLBACK_TEXTURE_ENV; @@ -1600,6 +1613,8 @@ fx_check_IsInHardware(GLcontext * ctx) if (ctx->Texture._EnabledUnits == 0x3) { /* Can't use multipass to blend a multitextured triangle - fall * back to software. + * [dBorca] we hit this case only when we try to emulate + * multitexture by multipass! */ if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) { return FX_FALLBACK_TEXTURE_MULTI; @@ -1621,7 +1636,7 @@ fx_check_IsInHardware(GLcontext * ctx) } if (fxMesa->type < GR_SSTTYPE_Voodoo2) - if ((ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_2D_BIT) && + if (ctx->Texture.Unit[0]._ReallyEnabled && (ctx->Texture.Unit[0].EnvMode == GL_BLEND)) { return FX_FALLBACK_TEXTURE_ENV; } @@ -1688,12 +1703,14 @@ fxSetupDDPointers(GLcontext * ctx) ctx->Driver.Finish = fxDDFinish; ctx->Driver.Flush = NULL; ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat; + ctx->Driver.TexImage1D = fxDDTexImage1D; ctx->Driver.TexImage2D = fxDDTexImage2D; ctx->Driver.TexSubImage2D = fxDDTexSubImage2D; ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D; ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D; ctx->Driver.IsCompressedFormat = fxDDIsCompressedFormat; ctx->Driver.CompressedTextureSize = fxDDCompressedTextureSize; + ctx->Driver.TestProxyTexImage = fxDDTestProxyTexImage; ctx->Driver.TexEnv = fxDDTexEnv; ctx->Driver.TexParameter = fxDDTexParam; ctx->Driver.BindTexture = fxDDTexBind; diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index 437d76f0d7..80728fe577 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -141,7 +141,7 @@ fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj) fprintf(stderr, "fxDDTexBind(%d, %x)\n", tObj->Name, (GLuint)tObj->DriverData); } - if (target != GL_TEXTURE_2D) + if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) return; if (!tObj->DriverData) { @@ -196,7 +196,7 @@ fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj, _mesa_lookup_enum_by_nr(param)); } - if (target != GL_TEXTURE_2D) + if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) return; if (!tObj->DriverData) @@ -477,6 +477,9 @@ fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj) fprintf(stderr, "fxDDTexPalette(%d, %x)\n", tObj->Name, (GLuint) tObj->DriverData); } + /* This might be a proxy texture. */ + if (!tObj->Palette.Table) + return; if (!tObj->DriverData) tObj->DriverData = fxAllocTexObjData(fxMesa); ti = fxTMGetTexInfo(tObj); @@ -511,6 +514,7 @@ fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state) else { fxMesa->haveGlobalPaletteTexture = 0; + /* [dBorca] tis beyond my comprehension */ if ((ctx->Texture.Unit[0]._Current == ctx->Texture.Unit[0].Current2D) && (ctx->Texture.Unit[0]._Current != NULL)) { struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current; @@ -635,7 +639,7 @@ static GLboolean fxIsTexSupported(GLenum target, GLint internalFormat, const struct gl_texture_image *image) { - if (target != GL_TEXTURE_2D) + if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) return GL_FALSE; #if 0 @@ -1227,6 +1231,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, return; } } + ti = fxTMGetTexInfo(texObj); if (!texImage->DriverData) { texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel)); @@ -1235,8 +1240,6 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, return; } } - ti = fxTMGetTexInfo(texObj); - mml = FX_MIPMAP_DATA(texImage); fxTexGetInfo(width, height, NULL, NULL, NULL, NULL, @@ -1530,6 +1533,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, return; } } + ti = fxTMGetTexInfo(texObj); if (!texImage->DriverData) { texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel)); @@ -1538,7 +1542,6 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, return; } } - ti = fxTMGetTexInfo(texObj); mml = FX_MIPMAP_DATA(texImage); fxTexGetInfo(width, height, NULL, NULL, NULL, NULL, @@ -1671,6 +1674,41 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target, } +void +fxDDTexImage1D (GLcontext *ctx, GLenum target, GLint level, + GLint internalFormat, GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + fxDDTexImage2D(ctx, target, level, + internalFormat, width, 1, border, + format, type, pixels, + packing, + texObj, + texImage); +} + + +GLboolean +fxDDTestProxyTexImage (GLcontext *ctx, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border) +{ + /* [dBorca] + * TODO - maybe through fxTexValidate() + */ + return _mesa_test_proxy_teximage(ctx, target, + level, internalFormat, + format, type, + width, height, + depth, border); +} + + #else /* FX */ /* diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index d48e3dd3ef..3e7e433f24 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -607,6 +607,18 @@ extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLsizei imageSize, const GLvoid *data, struct gl_texture_object *texObj, struct gl_texture_image *texImage); +extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level, + GLint internalFormat, GLint width, + GLint border, GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); +extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border); extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *); extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *, GLenum, const GLfloat *); @@ -697,7 +709,7 @@ void fxSetupDepthTest (GLcontext *ctx); void fxSetupTexture (GLcontext *ctx); /* Flags for software fallback cases */ -#define FX_FALLBACK_TEXTURE_1D_3D 0x0001 +#define FX_FALLBACK_TEXTURE_MAP 0x0001 #define FX_FALLBACK_DRAW_BUFFER 0x0002 #define FX_FALLBACK_SPECULAR 0x0004 #define FX_FALLBACK_STENCIL 0x0008 diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index cb7c4e2b08..7714e3cf80 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -537,7 +537,7 @@ fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset) GLuint unitsmode; GLint ifmt; tfxTexInfo *ti; - struct gl_texture_object *tObj = ctx->Texture.Unit[textureset].Current2D; + struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current; int tmu; if (TDFX_DEBUG & VERBOSE_DRIVER) { @@ -921,8 +921,8 @@ fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx) struct tdfx_texcombine tex0, tex1; GrCombineLocal_t localc, locala; tfxTexInfo *ti0, *ti1; - struct gl_texture_object *tObj0 = ctx->Texture.Unit[1].Current2D; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[0].Current2D; + struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current; + struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current; GLuint envmode, ifmt, unitsmode; int tmu0 = 0, tmu1 = 1; @@ -1269,15 +1269,15 @@ fxSetupTexture_NoLock(GLcontext * ctx) if (fxMesa->HaveCmbExt) { /* Texture Combine, Color Combine and Alpha Combine. */ - if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT && - ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT && + if ((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && + (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && fxMesa->haveTwoTMUs) { fxSetupTextureDoubleTMUNapalm_NoLock(ctx); } - else if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT) { + else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { fxSetupTextureSingleTMUNapalm_NoLock(ctx, 0); } - else if (ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) { + else if (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { fxSetupTextureSingleTMUNapalm_NoLock(ctx, 1); } else { @@ -1285,15 +1285,15 @@ fxSetupTexture_NoLock(GLcontext * ctx) } } else { /* Texture Combine, Color Combine and Alpha Combine. */ - if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT && - ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT && + if ((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && + (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && fxMesa->haveTwoTMUs) { fxSetupTextureDoubleTMU_NoLock(ctx); } - else if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT) { + else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { fxSetupTextureSingleTMU_NoLock(ctx, 0); } - else if (ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) { + else if (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { fxSetupTextureSingleTMU_NoLock(ctx, 1); } else { @@ -2039,6 +2039,7 @@ fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state) case GL_LINE_STIPPLE: case GL_POINT_SMOOTH: case GL_POLYGON_SMOOTH: + case GL_TEXTURE_1D: case GL_TEXTURE_2D: fxMesa->new_state |= FX_NEW_TEXTURING; break; diff --git a/src/mesa/drivers/glide/fxsetup.h b/src/mesa/drivers/glide/fxsetup.h index 7d76592498..236c983662 100644 --- a/src/mesa/drivers/glide/fxsetup.h +++ b/src/mesa/drivers/glide/fxsetup.h @@ -169,7 +169,7 @@ fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, G GrCombineLocal_t localc, locala; /* fragmentColor/Alpha */ GLint ifmt; tfxTexInfo *ti; - struct gl_texture_object *tObj = texUnit->Current2D; + struct gl_texture_object *tObj = texUnit->_Current; if (TDFX_DEBUG & VERBOSE_DRIVER) { fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock(unit %u, TMU %u, iterated %d)\n", @@ -1106,7 +1106,7 @@ fxSetupTextureSingleTMUNapalm_NoLock(GLcontext * ctx, GLuint textureset) fxMesaContext fxMesa = FX_CONTEXT(ctx); GLuint unitsmode; tfxTexInfo *ti; - struct gl_texture_object *tObj = ctx->Texture.Unit[textureset].Current2D; + struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current; int tmu; if (TDFX_DEBUG & VERBOSE_DRIVER) { @@ -1158,8 +1158,8 @@ fxSetupTextureDoubleTMUNapalm_NoLock(GLcontext * ctx) { fxMesaContext fxMesa = FX_CONTEXT(ctx); tfxTexInfo *ti0, *ti1; - struct gl_texture_object *tObj0 = ctx->Texture.Unit[1].Current2D; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[0].Current2D; + struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current; + struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current; GLuint unitsmode; int tmu0 = 0, tmu1 = 1; diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c index 846fd95f71..c9441673a4 100644 --- a/src/mesa/drivers/glide/fxtris.c +++ b/src/mesa/drivers/glide/fxtris.c @@ -1299,7 +1299,7 @@ static void fxRenderFinish( GLcontext *ctx ) /**********************************************************************/ static char *fallbackStrings[] = { - "1D/3D Texture map", + "3D/Rect/Cube Texture map", "glDrawBuffer(GL_FRONT_AND_BACK)", "Separate specular color", "glEnable/Disable(GL_STENCIL_TEST)", diff --git a/src/mesa/drivers/glide/fxwgl.c b/src/mesa/drivers/glide/fxwgl.c index ae1d913f3b..c17560d724 100644 --- a/src/mesa/drivers/glide/fxwgl.c +++ b/src/mesa/drivers/glide/fxwgl.c @@ -290,6 +290,14 @@ __wglMonitor(HWND hwnd, UINT message, UINT wParam, LONG lParam) return (ret); } +static void wgl_error (long error) +{ +#define WGL_INVALID_PIXELFORMAT ERROR_INVALID_PIXEL_FORMAT + SetLastError(0xC0000000 /* error severity */ + |0x00070000 /* error facility (who we are) */ + |error); +} + GLAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask) { @@ -314,7 +322,7 @@ wglCreateContext(HDC hdc) } if (curPFD == 0) { - SetLastError(0); + wgl_error(WGL_INVALID_PIXELFORMAT); return (NULL); } -- cgit v1.2.3