From: Brian P. <br...@va...> - 2000-11-13 21:08:32
|
Keith (and all DRI developers), I've found a problem in the handling of the ctx->IndirectTriangles bitfield in our drivers. The problem was exposed by the dinoshade demo using the tdfx driver in 16bpp mode. Specifically, when software stenciling was used polygon offset was no longer working. In gl_update_state() there's some code that basically goes like this: ctx->IndirectTriangles = ctx->TriangleCaps & ~ctx->Driver.TriangleCaps; ctx->IndirectTriangles |= DD_SW_RASTERIZE; [...] ctx->Driver.UpdateState(ctx); In tdfxDDUpdateState() if we determine that we can use h/w rendering (i.e. no fallbacks) we then do this: ctx->IndirectTriangles &= ~DD_SW_RASTERIZE; ctx->IndirectTriangles |= fxMesa->IndirectTriangles; Otherwise, ctx->IndirectTriangles remains unchanged. That's wrong. See, a bit later when we're in gl_set_render_vb_function() we examine ctx->IndirectTriangles to see if any DD_SW_SETUP bits are set. That's where we'll determine if polygon offset, culling or two-sided lighting is enabled. But DD_TRI_OFFSET was cleared from ctx->IndirectTriangles in that first assignment in gl_update_state() because it's set in ctx->Driver.TriangleCaps. It turns out that if we're using software rendering, that we have to do ctx->IndirectTriangles |= ctx->TriangleCaps. It's a simple fix in tdfxDDUpdateState(). Looking at the other drivers it appears that they all need this fix. Before: if ( !fxMesa->Fallback ) { ctx->IndirectTriangles &= ~DD_SW_RASTERIZE; ctx->IndirectTriangles |= fxMesa->IndirectTriangles; ctx->Driver.PointsFunc = fxMesa->PointsFunc; ctx->Driver.LineFunc = fxMesa->LineFunc; ctx->Driver.TriangleFunc = fxMesa->TriangleFunc; ctx->Driver.QuadFunc = fxMesa->QuadFunc; ctx->Driver.RenderVBRawTab = fxMesa->RenderVBRawTab; } After: if ( !fxMesa->Fallback ) { ctx->IndirectTriangles &= ~DD_SW_RASTERIZE; ctx->IndirectTriangles |= fxMesa->IndirectTriangles; ctx->Driver.PointsFunc = fxMesa->PointsFunc; ctx->Driver.LineFunc = fxMesa->LineFunc; ctx->Driver.TriangleFunc = fxMesa->TriangleFunc; ctx->Driver.QuadFunc = fxMesa->QuadFunc; ctx->Driver.RenderVBRawTab = fxMesa->RenderVBRawTab; } else { ctx->IndirectTriangles |= ctx->TriangleCaps; } Do you agree with this solution, Keith? -Brian |