On czwartek, 19 marca 2009 19:27:54 you wrote:
> On Thu, 2009-03-19 at 10:21 -0700, Maciej Cencora wrote:
> > Hi,
> >
> > here's simple patch that allows for building render functions with
> > DO_UNFILLED = 0.
> > I'd appreciate any comments
> >
> > Maciej Cencora
>
> Does this actually make any difference to the compiled code? When
> DO_UNFILLED is true, the compiler should be able to statically tell that
> mode is set to GL_TRIANGLES at the top of the function and never
> altered.
>
> Also, if the change does turn out to be necessary, could you recast it
> in similar style to the rest of the function, ie using
>
> if (DO_UNFILLED) {
> }
>
> rather than
>
> #if DO_UNFILLED
> #endif
>
>
> Keith
currently the code looks like this
if (mode == GL_POINT) {
if (DO_OFFSET && ctx->Polygon.OffsetPoint) {
VERT_Z_ADD(v[0], offset);
VERT_Z_ADD(v[1], offset);
VERT_Z_ADD(v[2], offset);
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide)
{
SETUP_STENCIL(facing);
UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 );
UNSET_STENCIL(facing);
} else {
UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 );
}
} else if (mode == GL_LINE) {
if (DO_OFFSET && ctx->Polygon.OffsetLine) {
VERT_Z_ADD(v[0], offset);
VERT_Z_ADD(v[1], offset);
VERT_Z_ADD(v[2], offset);
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide)
{
SETUP_STENCIL(facing);
UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 );
UNSET_STENCIL(facing);
} else {
UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 );
}
} else {
if (DO_OFFSET && ctx->Polygon.OffsetFill) {
VERT_Z_ADD(v[0], offset);
VERT_Z_ADD(v[1], offset);
VERT_Z_ADD(v[2], offset);
}
if (DO_UNFILLED)
RASTERIZE( GL_TRIANGLES );
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide)
{
SETUP_STENCIL(facing);
TRI( v[0], v[1], v[2] );
UNSET_STENCIL(facing);
} else {
TRI( v[0], v[1], v[2] );
}
}
as you can see there's no clear path when DO_UNFILLED is 0 (UNFILLED_TRI macro
is used without checking DO_UNFILLED value) so it wan't even compile without
this patch.
But looks like there's a problem with my patch. With patched r300 driver
(patch attached) poly/quad unfilled trivial progs are broken (screen shot
attached). Did I forgot to change something in r300_swtcl or is this path
(DO_UNFILLED 0) untested and broken?
Maciej Cencora
diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c
index d463ab3..aee0d27 100644
--- a/src/mesa/drivers/dri/r300/r300_swtcl.c
+++ b/src/mesa/drivers/dri/r300/r300_swtcl.c
@@ -434,8 +434,7 @@ static void r300RenderPrimitive( GLcontext *ctx, GLenum prim );
***********************************************************************/
#define R300_TWOSIDE_BIT 0x01
-#define R300_UNFILLED_BIT 0x02
-#define R300_MAX_TRIFUNC 0x04
+#define R300_MAX_TRIFUNC 0x02
static struct {
tnl_points_func points;
@@ -445,7 +444,7 @@ static struct {
} rast_tab[R300_MAX_TRIFUNC];
#define DO_FALLBACK 0
-#define DO_UNFILLED (IND & R300_UNFILLED_BIT)
+#define DO_UNFILLED 0
#define DO_TWOSIDE (IND & R300_TWOSIDE_BIT)
#define DO_FLAT 0
#define DO_OFFSET 0
@@ -462,8 +461,6 @@ static struct {
#define TAB rast_tab
#define DEPTH_SCALE 1.0
-#define UNFILLED_TRI unfilled_tri
-#define UNFILLED_QUAD unfilled_quad
#define VERT_X(_v) _v->v.x
#define VERT_Y(_v) _v->v.y
#define VERT_Z(_v) _v->v.z
@@ -504,22 +501,11 @@ do { \
#define LOCAL_VARS(n) \
r300ContextPtr rmesa = R300_CONTEXT(ctx); \
- GLuint color[n], spec[n]; \
+ GLuint color[n] = { 0, }, spec[n] = { 0, }; \
GLuint coloroffset = rmesa->swtcl.coloroffset; \
GLuint specoffset = rmesa->swtcl.specoffset; \
(void) color; (void) spec; (void) coloroffset; (void) specoffset;
-/***********************************************************************
- * Helpers for rendering unfilled primitives *
- ***********************************************************************/
-
-#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] )
-#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
-#undef TAG
-#define TAG(x) x
-#include "tnl_dd/t_dd_unfilled.h"
-#undef IND
-
/***********************************************************************
* Generate GL render functions *
@@ -534,22 +520,11 @@ do { \
#define TAG(x) x##_twoside
#include "tnl_dd/t_dd_tritmp.h"
-#define IND (R300_UNFILLED_BIT)
-#define TAG(x) x##_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (R300_TWOSIDE_BIT|R300_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-
static void init_rast_tab( void )
{
init();
init_twoside();
- init_unfilled();
- init_twoside_unfilled();
}
/**********************************************************************/
@@ -602,7 +577,6 @@ static void r300ChooseRenderState( GLcontext *ctx )
GLuint flags = ctx->_TriangleCaps;
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT;
- if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT;
if (index != rmesa->swtcl.RenderIndex) {
tnl->Driver.Render.Points = rast_tab[index].points;
@@ -665,12 +639,7 @@ static void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
r300ContextPtr rmesa = R300_CONTEXT(ctx);
rmesa->swtcl.render_primitive = prim;
- if ((prim == GL_TRIANGLES) && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
- return;
-
r300RasterPrimitive( ctx, reduced_prim[prim] );
- // fprintf(stderr, "%s\n", __FUNCTION__);
-
}
static void r300ResetLineStipple(GLcontext *ctx)
@@ -713,11 +682,6 @@ void r300InitSwtcl(GLcontext *ctx)
_tnl_need_projected_coords( ctx, GL_FALSE );
r300ChooseRenderState(ctx);
-
- _mesa_validate_all_lighting_tables( ctx );
-
- tnl->Driver.NotifyMaterialChange =
- _mesa_validate_all_lighting_tables;
}
void r300DestroySwtcl(GLcontext *ctx)
<<attachment: zrzut ekranu5.png>>
<<attachment: zrzut ekranu6.png>>
------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________ Mesa3d-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
