softgpu: Remove offset from screenpos.

This simplifies tighter calculations, and reduces the common magnitudes
we'll be dealing with.
This commit is contained in:
Unknown W. Brackets committed 2022-02-19 20:38:44 -08:00
1 parent 7f505c0c23
commit a66377fdf1
7 files changed
+33 -40

No files matched your search

+8 -6
View File
@@ -125,7 +125,9 @@ static ScreenCoords ClipToScreenInternal(Vec3f scaled, const ClipCoords &coords,
// 16 = 0xFFFF / 4095.9375
// Round up at 0.625 to the nearest subpixel.
return ScreenCoords(scaled.x * 16.0f + 0.375f, scaled.y * 16.0f + 0.375f, scaled.z);
int x = (int)(scaled.x * 16.0f + 0.375f - gstate.getOffsetX16());
int y = (int)(scaled.y * 16.0f + 0.375f - gstate.getOffsetY16());
return ScreenCoords(x, y, scaled.z);
}
static inline ScreenCoords ClipToScreenInternal(const ClipCoords &coords, bool *outside_range_flag) {
@@ -159,8 +161,8 @@ ScreenCoords TransformUnit::ClipToScreen(const ClipCoords &coords) {
ScreenCoords TransformUnit::DrawingToScreen(const DrawingCoords &coords, u16 z) {
ScreenCoords ret;
ret.x = (u32)coords.x * 16 + gstate.getOffsetX16();
ret.y = (u32)coords.y * 16 + gstate.getOffsetY16();
ret.x = (u32)coords.x * 16;
ret.y = (u32)coords.y * 16;
ret.z = z;
return ret;
}
@@ -427,8 +429,8 @@ VertexData TransformUnit::ReadVertex(VertexReader &vreader, const TransformState
if (state.enableLighting)
Lighting::Process(vertex, worldpos, worldnormal, state.lightingState);
} else {
vertex.screenpos.x = (int)(pos[0] * 16) + state.screenOffsetX;
vertex.screenpos.y = (int)(pos[1] * 16) + state.screenOffsetY;
vertex.screenpos.x = (int)(pos[0] * 16);
vertex.screenpos.y = (int)(pos[1] * 16);
vertex.screenpos.z = pos[2];
vertex.clippos.w = 1.f;
vertex.fogdepth = 1.f;
@@ -891,7 +893,7 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVert
float clipPos[4];
Vec3ByMatrix44(clipPos, vert.pos.AsArray(), worldviewproj);
ScreenCoords screenPos = ClipToScreen(clipPos);
DrawingCoords drawPos = ScreenToDrawing(screenPos, gstate.getOffsetX16(), gstate.getOffsetY16());
DrawingCoords drawPos = ScreenToDrawing(screenPos);
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0] * (float)gstate.getTextureWidth(0);