diff options
author | Daniel Borca <[email protected]> | 2004-07-05 06:47:17 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2004-07-05 06:47:17 +0000 |
commit | 3e94fd34449210c8b548a2a30f248fb5bd73478b (patch) | |
tree | d067d234e6dbd75799948b915742920e14f983e3 | |
parent | fd003824ad18fd78cbecf32fb5e8e58cf2f9cdba (diff) |
added GL_ARB_point_sprite.
color masking correctly implemented for 15bpp.
small fixes for textures and tri engine.
-rw-r--r-- | src/mesa/drivers/glide/fxdd.c | 24 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxddtex.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxdrv.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxsetup.c | 11 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxtris.c | 116 |
5 files changed, 119 insertions, 44 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 606c7f158f9..a08ad97fde4 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -90,11 +90,11 @@ GLuint FX_rgb_scale_6[64] = { */ static void fxDisableColor (fxMesaContext fxMesa) { - if (fxMesa->colDepth != 16) { - /* 32bpp mode or 15bpp mode */ + if (fxMesa->colDepth == 32) { + /* 32bpp mode */ fxMesa->Glide.grColorMaskExt(FXFALSE, FXFALSE, FXFALSE, FXFALSE); } else { - /* 16 bpp mode */ + /* 15/16 bpp mode */ grColorMask(FXFALSE, FXFALSE); } } @@ -185,7 +185,7 @@ static void fxDDClear( GLcontext *ctx, /* * As per GL spec, color masking should be obeyed when clearing */ - if (ctx->Visual.greenBits != 8 && ctx->Visual.greenBits != 5) { + if (ctx->Visual.greenBits != 8) { /* can only do color masking if running in 24/32bpp on Napalm */ if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] || ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) { @@ -1113,15 +1113,15 @@ fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y, ctx->Pixel.ZoomY != 1.0F || (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| IMAGE_MAP_COLOR_BIT)) || - ctx->Color.AlphaEnabled || + /*ctx->Color.AlphaEnabled ||*/ ctx->Depth.Test || ctx->Fog.Enabled || ctx->Scissor.Enabled || ctx->Stencil.Enabled || - !ctx->Color.ColorMask[0] || + /*!ctx->Color.ColorMask[0] || !ctx->Color.ColorMask[1] || !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || + !ctx->Color.ColorMask[3] ||*/ ctx->Color.ColorLogicOpEnabled || ctx->Texture._EnabledUnits || ctx->Depth.OcclusionTest || @@ -1303,11 +1303,11 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa) fxMesa->unitsState.stencilWriteMask = 0xff; - if (fxMesa->colDepth != 16) { - /* 32bpp mode or 15bpp mode */ + if (fxMesa->colDepth == 32) { + /* 32bpp */ fxMesa->Glide.grColorMaskExt(FXTRUE, FXTRUE, FXTRUE, fxMesa->haveHwAlpha); } else { - /* 16 bpp mode */ + /* 15/16 bpp mode */ grColorMask(FXTRUE, fxMesa->haveHwAlpha); } @@ -1357,6 +1357,7 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa) textureLevels++; } while ((textureSize >>= 0x1) & 0x7ff); ctx->Const.MaxTextureLevels = textureLevels; + ctx->Const.MaxTextureLodBias = /*textureLevels - 1*/8; /* Glide bug */ #if FX_RESCALE_BIG_TEXURES_HACK fxMesa->textureMaxLod = textureLevels - 1; if ((env = getenv("MESA_FX_MAXLOD")) != NULL) { @@ -1448,6 +1449,7 @@ fxDDInitExtensions(GLcontext * ctx) _mesa_enable_extension(ctx, "GL_EXT_secondary_color"); #endif + _mesa_enable_extension(ctx, "GL_ARB_point_sprite"); _mesa_enable_extension(ctx, "GL_EXT_point_parameters"); _mesa_enable_extension(ctx, "GL_EXT_paletted_texture"); _mesa_enable_extension(ctx, "GL_EXT_texture_lod_bias"); @@ -1582,7 +1584,7 @@ fx_check_IsInHardware(GLcontext * ctx) } #endif - if ((fxMesa->colDepth == 16) && + if ((fxMesa->colDepth != 32) && ((ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP]) || (ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]))) { return FX_FALLBACK_COLORMASK; diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index f433c573d47..4c498b59cc1 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -171,8 +171,9 @@ fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname, /* apply any lod biasing right now */ if (pname == GL_TEXTURE_LOD_BIAS_EXT) { GLfloat bias = *param; - CLAMP_SELF(bias, -8.0, 7.75); - + CLAMP_SELF(bias, -ctx->Const.MaxTextureLodBias, + ctx->Const.MaxTextureLodBias - 0.25); + grTexLodBiasValue(GR_TMU0, bias); if (fxMesa->haveTwoTMUs) { @@ -296,6 +297,7 @@ fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj, case GL_MIRRORED_REPEAT: ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT; break; + case GL_CLAMP_TO_BORDER: /* no-no, but don't REPEAT, either */ case GL_CLAMP_TO_EDGE: /* CLAMP discarding border */ case GL_CLAMP: ti->sClamp = GR_TEXTURECLAMP_CLAMP; @@ -314,6 +316,7 @@ fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj, case GL_MIRRORED_REPEAT: ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT; break; + case GL_CLAMP_TO_BORDER: /* no-no, but don't REPEAT, either */ case GL_CLAMP_TO_EDGE: /* CLAMP discarding border */ case GL_CLAMP: ti->tClamp = GR_TEXTURECLAMP_CLAMP; @@ -1591,6 +1594,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, * our data aligned inside a 8:1 rectangle. * 3) just in case if MIN("s", "t") gets overflowed with GL_REPEAT, * we replicate the data over the padded area. + * For now, we take 2) + 3) but texelfetchers will be wrong! */ GLuint srcRowStride = _mesa_compressed_row_stride(internalFormat, width); @@ -1601,7 +1605,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, destRowStride, (mml->height+3) / 4, 1, data, srcRowStride, texImage->Data); - + ti->padded = GL_TRUE; } else { MEMCPY(texImage->Data, data, texImage->CompressedSize); } diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index af4765d7a9b..379851131fa 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -294,6 +294,8 @@ typedef struct tfxTexInfo_t GLboolean fixedPalette; GLboolean validated; + + GLboolean padded; } tfxTexInfo; diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index 0d900d29f45..d486a5eaf11 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -156,10 +156,7 @@ fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj) FX_smallLodLog2(ti->info) = FX_largeLodLog2(ti->info); /* this is necessary because of fxDDCompressedTexImage2D */ - if ((ti->info.format == GR_TEXFMT_ARGB_CMP_FXT1) || - (ti->info.format == GR_TEXFMT_ARGB_CMP_DXT1) || - (ti->info.format == GR_TEXFMT_ARGB_CMP_DXT3) || - (ti->info.format == GR_TEXFMT_ARGB_CMP_DXT5)) { + if (ti->padded) { struct gl_texture_image *texImage = tObj->Image[0][minl]; tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); if (mml->wScale != 1 || mml->hScale != 1) { @@ -1784,15 +1781,15 @@ fxSetupColorMask(GLcontext * ctx) { fxMesaContext fxMesa = FX_CONTEXT(ctx); - if (fxMesa->colDepth != 16) { - /* 32bpp mode or 15bpp mode */ + if (fxMesa->colDepth == 32) { + /* 32bpp mode */ fxMesa->Glide.grColorMaskExt(ctx->Color.ColorMask[RCOMP], ctx->Color.ColorMask[GCOMP], ctx->Color.ColorMask[BCOMP], ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha); } else { - /* 16 bpp mode */ + /* 15/16 bpp mode */ grColorMask(ctx->Color.ColorMask[RCOMP] | ctx->Color.ColorMask[GCOMP] | ctx->Color.ColorMask[BCOMP], diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c index 6620eb678ab..e2b6c45a42a 100644 --- a/src/mesa/drivers/glide/fxtris.c +++ b/src/mesa/drivers/glide/fxtris.c @@ -274,6 +274,63 @@ static void fx_draw_point( fxMesaContext fxMesa, #endif #define __GL_COSF cos #define __GL_SINF sin +static void fx_draw_point_sprite ( fxMesaContext fxMesa, + GrVertex *v0, GLfloat psize ) +{ + const GLcontext *ctx = fxMesa->glCtx; + + GLfloat radius; + GrVertex _v_[4]; + GLuint ts0 = fxMesa->tmu_source[0]; + GLuint ts1 = fxMesa->tmu_source[1]; + GLfloat w = v0->oow; + GLfloat u0scale = fxMesa->s0scale * w; + GLfloat v0scale = fxMesa->t0scale * w; + GLfloat u1scale = fxMesa->s1scale * w; + GLfloat v1scale = fxMesa->t1scale * w; + + radius = psize / 2.; + _v_[0] = *v0; + _v_[1] = *v0; + _v_[2] = *v0; + _v_[3] = *v0; + /* CLIP_LOOP ?!? */ + /* point coverage? */ + /* we don't care about culling here (see fxSetupCull) */ + + _v_[0].x -= radius; + _v_[0].y += radius; + _v_[1].x += radius; + _v_[1].y += radius; + _v_[2].x += radius; + _v_[2].y -= radius; + _v_[3].x -= radius; + _v_[3].y -= radius; + + if (ctx->Point.CoordReplace[ts0]) { + _v_[0].tmuvtx[0].sow = 0; + _v_[0].tmuvtx[0].tow = 0; + _v_[1].tmuvtx[0].sow = u0scale; + _v_[1].tmuvtx[0].tow = 0; + _v_[2].tmuvtx[0].sow = u0scale; + _v_[2].tmuvtx[0].tow = v0scale; + _v_[3].tmuvtx[0].sow = 0; + _v_[3].tmuvtx[0].tow = v0scale; + } + if (ctx->Point.CoordReplace[ts1]) { + _v_[0].tmuvtx[1].sow = 0; + _v_[0].tmuvtx[1].tow = 0; + _v_[1].tmuvtx[1].sow = u1scale; + _v_[1].tmuvtx[1].tow = 0; + _v_[2].tmuvtx[1].sow = u1scale; + _v_[2].tmuvtx[1].tow = v1scale; + _v_[3].tmuvtx[1].sow = 0; + _v_[3].tmuvtx[1].tow = v1scale; + } + + grDrawVertexArrayContiguous(GR_TRIANGLE_FAN, 4, _v_, sizeof(GrVertex)); +} + static void fx_draw_point_wide ( fxMesaContext fxMesa, GrVertex *v0 ) { @@ -285,6 +342,11 @@ static void fx_draw_point_wide ( fxMesaContext fxMesa, const GLcontext *ctx = fxMesa->glCtx; const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN) ? v0->psize : ctx->Point.Size; + if (ctx->Point.PointSprite) { + fx_draw_point_sprite(fxMesa, v0, psize); + return; + } + _v_[0] = v0; _v_[1] = &vtxB; _v_[2] = &vtxC; @@ -355,6 +417,11 @@ static void fx_draw_point_wide_aa ( fxMesaContext fxMesa, const GLcontext *ctx = fxMesa->glCtx; const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN) ? v0->psize : ctx->Point.Size; + if (ctx->Point.PointSprite) { + fx_draw_point_sprite(fxMesa, v0, psize); + return; + } + radius = psize / 2.; n = IROUND(psize * 2); /* radius x 4 */ if (n < 4) n = 4; @@ -905,27 +972,16 @@ static void fx_render_vb_quads( GLcontext *ctx, INIT(GL_QUADS); -#if 1 - /* [dBorca] Hack alert: - * since VTX-0-2 we get here with start = 0, count = 2, - * causing around 4 billion triangles. Revise this after - * a while - */ - if (count < 3) { - return; - } -#endif - - for (i = start ; i < count-3 ; i += 4 ) { + for (i = start + 3 ; i < count ; i += 4 ) { #define VERT(x) (fxVB + (x)) GrVertex *_v_[4]; - _v_[0] = VERT(i+3); - _v_[1] = VERT(i+0); - _v_[2] = VERT(i+1); - _v_[3] = VERT(i+2); + _v_[0] = VERT(i); + _v_[1] = VERT(i-3); + _v_[2] = VERT(i-2); + _v_[3] = VERT(i-1); grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_); - /*grDrawTriangle( VERT(i), VERT(i+1), VERT(i+3) );*/ - /*grDrawTriangle( VERT(i+1), VERT(i+2), VERT(i+3) );*/ + /*grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/ + /*grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/ #undef VERT } } @@ -1092,12 +1148,22 @@ static void fxRenderClippedPoly( GLcontext *ctx, const GLuint *elts, static void fxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n ) { + int i; fxMesaContext fxMesa = FX_CONTEXT( ctx ); GrVertex *vertptr = fxMesa->verts; - const GrVertex *start = VERT(elts[0]); - int i; - for (i = 2 ; i < n ; i++) { - grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) ); + if (n == 3) { + grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) ); + } else if (n <= 32) { + GrVertex *newvptr[32]; + for (i = 0 ; i < n ; i++) { + newvptr[i] = VERT(elts[i]); + } + grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr); + } else { + const GrVertex *start = VERT(elts[0]); + for (i = 2 ; i < n ; i++) { + grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) ); + } } } @@ -1196,7 +1262,7 @@ void fxDDChooseRenderState(GLcontext *ctx) fx_render_tab_verts[0] = fx_render_pw_verts; fx_render_tab_elts[0] = fx_render_pw_elts; } - tnl->Driver.Render.Points = rast_tab[FX_FALLBACK_BIT].points; + tnl->Driver.Render.Points = rast_tab[index|FX_FALLBACK_BIT].points; } else { fx_render_tab_verts[0] = fx_render_vb_points; fx_render_tab_elts[0] = fx_render_points_elts; @@ -1431,6 +1497,10 @@ void fxDDInitTriFuncs( GLcontext *ctx ) } +/* [dBorca] Hack alert: + * doesn't work with blending. + * need to take care of stencil. + */ GLboolean fxMultipass_ColorSum (GLcontext *ctx, GLuint pass) { fxMesaContext fxMesa = FX_CONTEXT(ctx); |