apply the RASTER_QUAD offset at the loop start so it increments correctly
This commit is contained in:
parent
da9988e670
commit
7f0d179313
33
src/external/rlsw.h
vendored
33
src/external/rlsw.h
vendored
|
|
@ -5752,25 +5752,36 @@ static void SW_RASTER_QUAD(const sw_vertex_t *a, const sw_vertex_t *b,
|
||||||
int dyMin = yLoopMin - yMin;
|
int dyMin = yLoopMin - yMin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Correct our start by how far we clipped outside the framebuffer.
|
||||||
|
cRow[0] += dCdx[0]*dxMin + dCdy[0]*dyMin;
|
||||||
|
cRow[1] += dCdx[1]*dxMin + dCdy[1]*dyMin;
|
||||||
|
cRow[2] += dCdx[2]*dxMin + dCdy[2]*dyMin;
|
||||||
|
cRow[3] += dCdx[3]*dxMin + dCdy[3]*dyMin;
|
||||||
|
#ifdef SW_ENABLE_DEPTH_TEST
|
||||||
|
zRow += dZdy*dyMin + dZdx*dxMin;
|
||||||
|
#ifdef SW_ENABLE_TEXTURE
|
||||||
|
uRow += dUdy*dyMin + dUdx*dxMin;
|
||||||
|
vRow += dVdy*dyMin + dVdx*dxMin;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int y = yLoopMin; y < yLoopMax; y++)
|
for (int y = yLoopMin; y < yLoopMax; y++)
|
||||||
{
|
{
|
||||||
int baseOffset = y*stride + xLoopMin;
|
int baseOffset = y*stride + xLoopMin;
|
||||||
uint8_t *cPtr = cPixels + baseOffset*SW_FRAMEBUFFER_COLOR_SIZE;
|
uint8_t *cPtr = cPixels + baseOffset*SW_FRAMEBUFFER_COLOR_SIZE;
|
||||||
#ifdef SW_ENABLE_DEPTH_TEST
|
#ifdef SW_ENABLE_DEPTH_TEST
|
||||||
uint8_t *dPtr = dPixels + baseOffset*SW_FRAMEBUFFER_DEPTH_SIZE;
|
uint8_t *dPtr = dPixels + baseOffset*SW_FRAMEBUFFER_DEPTH_SIZE;
|
||||||
// Correct our start by how far we clipped outside the framebuffer.
|
// Copy the cursors so we increment them ourselves without destroying the offset maths.
|
||||||
float z = zRow + dZdy*dyMin;
|
float z = zRow;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SW_ENABLE_TEXTURE
|
#ifdef SW_ENABLE_TEXTURE
|
||||||
// Correct our start by how far we clipped outside the framebuffer.
|
float u = uRow;
|
||||||
float u = uRow + dUdy*dyMin;
|
float v = vRow;
|
||||||
float v = vRow + dVdy*dyMin;
|
|
||||||
#endif
|
#endif
|
||||||
float color[4] = {
|
float color[4] = {
|
||||||
cRow[0] + dCdx[0]*dxMin,
|
cRow[0],
|
||||||
cRow[1] + dCdx[1]*dxMin,
|
cRow[1],
|
||||||
cRow[2] + dCdx[2]*dxMin,
|
cRow[2],
|
||||||
cRow[3] + dCdx[3]*dxMin
|
cRow[3]
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int x = xLoopMin; x < xLoopMax; x++)
|
for (int x = xLoopMin; x < xLoopMax; x++)
|
||||||
|
|
@ -5812,6 +5823,7 @@ static void SW_RASTER_QUAD(const sw_vertex_t *a, const sw_vertex_t *b,
|
||||||
#ifdef SW_ENABLE_DEPTH_TEST
|
#ifdef SW_ENABLE_DEPTH_TEST
|
||||||
discard:
|
discard:
|
||||||
#endif
|
#endif
|
||||||
|
// We move one pixel over without touching the original "start offset"
|
||||||
color[0] += dCdx[0];
|
color[0] += dCdx[0];
|
||||||
color[1] += dCdx[1];
|
color[1] += dCdx[1];
|
||||||
color[2] += dCdx[2];
|
color[2] += dCdx[2];
|
||||||
|
|
@ -5834,6 +5846,9 @@ static void SW_RASTER_QUAD(const sw_vertex_t *a, const sw_vertex_t *b,
|
||||||
cPtr += SW_FRAMEBUFFER_COLOR_SIZE;
|
cPtr += SW_FRAMEBUFFER_COLOR_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The for loop is clamped to the right side of the screen.
|
||||||
|
// However, these cursor start vars are still on the left.
|
||||||
|
// That's fine. We just need to advance to the next row.
|
||||||
cRow[0] += dCdy[0];
|
cRow[0] += dCdy[0];
|
||||||
cRow[1] += dCdy[1];
|
cRow[1] += dCdy[1];
|
||||||
cRow[2] += dCdy[2];
|
cRow[2] += dCdy[2];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user