softpipe: calculate determinant for all triangles, don't rely on draw module to do it
This commit is contained in:
@@ -71,7 +71,6 @@ do_tri(struct draw_stage *stage, struct prim_header *prim)
|
||||
struct setup_stage *setup = setup_stage( stage );
|
||||
|
||||
setup_tri( setup->setup,
|
||||
prim->det,
|
||||
prim->v[0]->data,
|
||||
prim->v[1]->data,
|
||||
prim->v[2]->data );
|
||||
|
||||
@@ -119,25 +119,6 @@ sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recalculate prim's determinant. This is needed as we don't have
|
||||
* get this information through the vbuf_render interface & we must
|
||||
* calculate it here.
|
||||
*/
|
||||
static float
|
||||
calc_det( const float (*v0)[4],
|
||||
const float (*v1)[4],
|
||||
const float (*v2)[4] )
|
||||
{
|
||||
/* edge vectors e = v0 - v2, f = v1 - v2 */
|
||||
const float ex = v0[0][0] - v2[0][0];
|
||||
const float ey = v0[0][1] - v2[0][1];
|
||||
const float fx = v1[0][0] - v2[0][0];
|
||||
const float fy = v1[0][1] - v2[0][1];
|
||||
|
||||
/* det = cross(e,f).z */
|
||||
return ex * fy - ey * fx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
@@ -169,7 +150,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices)
|
||||
indices[i+j] * vertex_size);
|
||||
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2]);
|
||||
@@ -254,7 +234,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i + 1);
|
||||
v[2] = VERTEX(i + 2);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -267,7 +246,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i - 1);
|
||||
v[2] = VERTEX(i);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -280,7 +258,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i - 1);
|
||||
v[2] = VERTEX(i);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -293,7 +270,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i + 1);
|
||||
v[2] = VERTEX(i + 2);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -302,7 +278,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i + 2);
|
||||
v[2] = VERTEX(i + 3);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -315,7 +290,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i);
|
||||
v[2] = VERTEX(i + 1);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -324,7 +298,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i + 1);
|
||||
v[2] = VERTEX(i - 1);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
@@ -337,7 +310,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
|
||||
v[1] = VERTEX(i - 1);
|
||||
v[2] = VERTEX(i);
|
||||
setup_tri( setup_ctx,
|
||||
calc_det(v[0], v[1], v[2]),
|
||||
v[0],
|
||||
v[1],
|
||||
v[2] );
|
||||
|
||||
@@ -695,15 +695,37 @@ static void subtriangle( struct setup_context *setup,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recalculate prim's determinant. This is needed as we don't have
|
||||
* get this information through the vbuf_render interface & we must
|
||||
* calculate it here.
|
||||
*/
|
||||
static float
|
||||
calc_det( const float (*v0)[4],
|
||||
const float (*v1)[4],
|
||||
const float (*v2)[4] )
|
||||
{
|
||||
/* edge vectors e = v0 - v2, f = v1 - v2 */
|
||||
const float ex = v0[0][0] - v2[0][0];
|
||||
const float ey = v0[0][1] - v2[0][1];
|
||||
const float fx = v1[0][0] - v2[0][0];
|
||||
const float fy = v1[0][1] - v2[0][1];
|
||||
|
||||
/* det = cross(e,f).z */
|
||||
return ex * fy - ey * fx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do setup for triangle rasterization, then render the triangle.
|
||||
*/
|
||||
void setup_tri( struct setup_context *setup,
|
||||
float det,
|
||||
const float (*v0)[4],
|
||||
const float (*v1)[4],
|
||||
const float (*v2)[4] )
|
||||
{
|
||||
float det = calc_det(v0, v1, v2);
|
||||
|
||||
/*
|
||||
debug_printf("%s\n", __FUNCTION__ );
|
||||
*/
|
||||
@@ -713,6 +735,8 @@ void setup_tri( struct setup_context *setup,
|
||||
setup->numFragsWritten = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (cull_tri( setup, det ))
|
||||
return;
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
struct setup_context;
|
||||
struct softpipe_context;
|
||||
|
||||
void setup_tri( struct setup_context *setup,
|
||||
float det,
|
||||
const float (*v0)[4],
|
||||
const float (*v1)[4],
|
||||
const float (*v2)[4] );
|
||||
void
|
||||
setup_tri( struct setup_context *setup,
|
||||
const float (*v0)[4],
|
||||
const float (*v1)[4],
|
||||
const float (*v2)[4] );
|
||||
|
||||
void
|
||||
setup_line(struct setup_context *setup,
|
||||
|
||||
Reference in New Issue
Block a user