summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian@i915.localnet.net>2007-07-11 16:01:22 -0600
committerBrian <brian@i915.localnet.net>2007-07-11 16:01:22 -0600
commit813e493ca799fd11c243cb5823b1e6dc8d868734 (patch)
tree20ca017ba0372268445d354c07c23f493e978a56
parentae108bfaae54f0562ea80336753fa1c7a1040b20 (diff)
Fix a few polygon offset errors.
1. edge vectors were miscomputed in do_offset_tri() 2. units and scale assignments were transposed in update_clip_state(). 3. intel->polygon_offset_scale is the MRD, apply it to offset_units, not the scale factor.
-rw-r--r--src/mesa/clip/clip_pipe_offset.c22
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_context.c4
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_state_clip.c12
3 files changed, 15 insertions, 23 deletions
diff --git a/src/mesa/clip/clip_pipe_offset.c b/src/mesa/clip/clip_pipe_offset.c
index 35b4e5c079..7129248f7b 100644
--- a/src/mesa/clip/clip_pipe_offset.c
+++ b/src/mesa/clip/clip_pipe_offset.c
@@ -64,6 +64,7 @@ static void offset_begin( struct clip_pipe_stage *stage )
else
offset->hw_data_offset = 0;
+ /* note that MRD should have already been applied to the units value */
offset->units = stage->pipe->draw->state.offset_units;
offset->scale = stage->pipe->draw->state.offset_scale;
@@ -79,31 +80,26 @@ static void do_offset_tri( struct clip_pipe_stage *stage,
{
struct offset_stage *offset = offset_stage(stage);
GLuint hw_data_offset = offset->hw_data_offset;
-
+
GLfloat inv_det = 1.0 / header->det;
GLfloat *v0 = (GLfloat *)&(header->v[0]->data[hw_data_offset]);
GLfloat *v1 = (GLfloat *)&(header->v[1]->data[hw_data_offset]);
GLfloat *v2 = (GLfloat *)&(header->v[2]->data[hw_data_offset]);
- GLfloat ex = v0[0] - v2[2];
- GLfloat fx = v1[0] - v2[2];
- GLfloat ey = v0[1] - v2[2];
- GLfloat fy = v1[1] - v2[2];
+ GLfloat ex = v0[0] - v2[0];
+ GLfloat ey = v0[1] - v2[1];
GLfloat ez = v0[2] - v2[2];
+ GLfloat fx = v1[0] - v2[0];
+ GLfloat fy = v1[1] - v2[1];
GLfloat fz = v1[2] - v2[2];
GLfloat a = ey*fz - ez*fy;
GLfloat b = ez*fx - ex*fz;
- GLfloat ac = a * inv_det;
- GLfloat bc = b * inv_det;
- GLfloat zoffset;
-
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
-
- zoffset = offset->units + MAX2( ac, bc ) * offset->scale;
+ GLfloat dzdx = FABSF(a * inv_det);
+ GLfloat dzdy = FABSF(b * inv_det);
+ GLfloat zoffset = offset->units + MAX2( dzdx, dzdy ) * offset->scale;
v0[2] += zoffset;
v1[2] += zoffset;
diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c
index 5a0f5f70ec..e852a430e8 100644
--- a/src/mesa/drivers/dri/i915tex/intel_context.c
+++ b/src/mesa/drivers/dri/i915tex/intel_context.c
@@ -485,7 +485,9 @@ intelInitContext(struct intel_context *intel,
/* XXX FBO: recalculate on bind */
switch (mesaVis->depthBits) {
- case 0: /* what to do in this case? */
+ case 0:
+ intel->polygon_offset_scale = 0.0;
+ break;
case 16:
intel->polygon_offset_scale = 1.0 / 0xffff;
break;
diff --git a/src/mesa/drivers/dri/i915tex/intel_state_clip.c b/src/mesa/drivers/dri/i915tex/intel_state_clip.c
index c91e6654aa..fde54f8f13 100644
--- a/src/mesa/drivers/dri/i915tex/intel_state_clip.c
+++ b/src/mesa/drivers/dri/i915tex/intel_state_clip.c
@@ -137,24 +137,18 @@ static void update_clip_state( struct intel_context *intel )
if (state.fill_cw != FILL_TRI)
state.offset_cw = get_offset_flag( state.fill_cw,
intel->state.Polygon );
-
if (state.fill_ccw != FILL_TRI)
state.offset_ccw = get_offset_flag( state.fill_ccw,
intel->state.Polygon );
-
/* _NEW_BUFFERS, _NEW_POLYGON
*/
if (state.fill_cw != FILL_TRI ||
state.fill_ccw != FILL_TRI)
{
- GLfloat mrd = (intel->state.DrawBuffer ?
- intel->state.DrawBuffer->_MRD :
- 1.0);
-
- state.offset_units = intel->state.Polygon->OffsetFactor * mrd;
- state.offset_scale = (intel->state.Polygon->OffsetUnits * mrd *
- intel->polygon_offset_scale);
+ GLfloat mrd = intel->polygon_offset_scale;
+ state.offset_scale = intel->state.Polygon->OffsetFactor;
+ state.offset_units = intel->state.Polygon->OffsetUnits * mrd;
}