[OpenJDK Rasterizer] Fwd: Re: Fwd: RFR: Marlin renderer #3

Jim Graham james.graham at oracle.com
Thu Jul 30 02:15:56 UTC 2015


With respect to double precision usage, I think that x1,y1,x2,y2 will be 
float and I would be hard pressed to recommend revisiting that.

But, the slope calculation:

final float slope = (x2 - x1) / (y2 - y1);

might compute a value such that:

x2 != x1 + (y2 - y1) * slope

by a couple of bits of mantissa after all of those operations, whereas 
double might get it closer.  Also, we aren't doing that calculation in a 
single step, we are computing it iteratively over many steps, so we 
really have:

for (firstcrossing => lastcrossing) {
     x1,error += bump,bumperror
}

and those values are even more likely to accumulate error over time. 
Perhaps it would be best to compute slope as double and x_intercept as 
double:

final double x1d = x1;
final double y1d = y1;
final double slope = (x2 - x1d) / (y2 - y1d);

...

final double x1_intercept = x1d + (firstcrossing - y1d) * slope;
final long x1_fixed_biased = ((long) scalb(x1_intercept, 32)) + 0x7fffffffL;
store(CURX, (int) (x1_fixed_biased >> 32));
store(ERRX, ((int) x1_fixed_biased) >>> 1);
....
final long slope_fixed = (long) scalb(slope, 32);
store(BUMPX,    (int) (slope_fixed >> 32));
store(BUMPXERR, ((int) slope_fixed) >>> 1);

The question is how much those few double calculations per edge might 
cost us compared to float...

			...jim


More information about the graphics-rasterizer-dev mailing list