Revert "GPU: Clamp coordinates to 11 bits after applying drawing offset"

This reverts commit 5302f83818.

This is not the correct fix, and breaks other games.
This commit is contained in:
Connor McLaughlin 2020-04-04 19:31:08 +10:00
parent 7ace31d05f
commit 3cfead36c4
3 changed files with 14 additions and 19 deletions

View File

@ -251,15 +251,10 @@ protected:
{ {
u32 bits; u32 bits;
BitField<u32, s32, 0, 11> x; BitField<u32, s32, 0, 12> x;
BitField<u32, s32, 16, 11> y; BitField<u32, s32, 16, 12> y;
}; };
// Vertices have to be clamped to 11 bits before rendering. Normally this would happen as part of the scanline,
// but in the hardware renderers we'll do it at the vertex. FF8 is a good test case here, once you go too far left
// in the first scene of Galbadia Missile Base, the screen will flicker.
ALWAYS_INLINE static s32 VertexPositionToVRAMCoordinate(s32 x) { return SignExtendN<11, s32>(x); }
union VRAMPixel union VRAMPixel
{ {
u16 bits; u16 bits;

View File

@ -61,8 +61,8 @@ protected:
ALWAYS_INLINE void Set(s32 x_, s32 y_, u32 color_, u32 texpage_, u16 u_, u16 v_) ALWAYS_INLINE void Set(s32 x_, s32 y_, u32 color_, u32 texpage_, u16 u_, u16 v_)
{ {
x = VertexPositionToVRAMCoordinate(x_); x = x_;
y = VertexPositionToVRAMCoordinate(y_); y = y_;
color = color_; color = color_;
texpage = texpage_; texpage = texpage_;
u = u_; u = u_;

View File

@ -322,12 +322,12 @@ void GPU_SW::DrawTriangle(const SWVertex* v0, const SWVertex* v1, const SWVertex
if (IsClockwiseWinding(v0, v1, v2)) if (IsClockwiseWinding(v0, v1, v2))
std::swap(v1, v2); std::swap(v1, v2);
const s32 px0 = VertexPositionToVRAMCoordinate(v0->x + m_drawing_offset.x); const s32 px0 = v0->x + m_drawing_offset.x;
const s32 py0 = VertexPositionToVRAMCoordinate(v0->y + m_drawing_offset.y); const s32 py0 = v0->y + m_drawing_offset.y;
const s32 px1 = VertexPositionToVRAMCoordinate(v1->x + m_drawing_offset.x); const s32 px1 = v1->x + m_drawing_offset.x;
const s32 py1 = VertexPositionToVRAMCoordinate(v1->y + m_drawing_offset.y); const s32 py1 = v1->y + m_drawing_offset.y;
const s32 px2 = VertexPositionToVRAMCoordinate(v2->x + m_drawing_offset.x); const s32 px2 = v2->x + m_drawing_offset.x;
const s32 py2 = VertexPositionToVRAMCoordinate(v2->y + m_drawing_offset.y); const s32 py2 = v2->y + m_drawing_offset.y;
// Barycentric coordinates at minX/minY corner // Barycentric coordinates at minX/minY corner
const s32 ws = orient2d(px0, py0, px1, py1, px2, py2); const s32 ws = orient2d(px0, py0, px1, py1, px2, py2);
@ -444,7 +444,7 @@ void GPU_SW::DrawRectangle(s32 origin_x, s32 origin_y, u32 width, u32 height, u8
for (u32 offset_y = 0; offset_y < height; offset_y++) for (u32 offset_y = 0; offset_y < height; offset_y++)
{ {
const s32 y = VertexPositionToVRAMCoordinate(origin_y + static_cast<s32>(offset_y)); const s32 y = origin_y + static_cast<s32>(offset_y);
if (y < static_cast<s32>(m_drawing_area.top) || y > static_cast<s32>(m_drawing_area.bottom)) if (y < static_cast<s32>(m_drawing_area.top) || y > static_cast<s32>(m_drawing_area.bottom))
continue; continue;
@ -452,7 +452,7 @@ void GPU_SW::DrawRectangle(s32 origin_x, s32 origin_y, u32 width, u32 height, u8
for (u32 offset_x = 0; offset_x < width; offset_x++) for (u32 offset_x = 0; offset_x < width; offset_x++)
{ {
const s32 x = VertexPositionToVRAMCoordinate(origin_x + static_cast<s32>(offset_x)); const s32 x = origin_x + static_cast<s32>(offset_x);
if (x < static_cast<s32>(m_drawing_area.left) || x > static_cast<s32>(m_drawing_area.right)) if (x < static_cast<s32>(m_drawing_area.left) || x > static_cast<s32>(m_drawing_area.right))
continue; continue;
@ -668,8 +668,8 @@ void GPU_SW::DrawLine(const SWVertex* p0, const SWVertex* p1)
for (s32 i = 0; i <= k; i++) for (s32 i = 0; i <= k; i++)
{ {
const s32 x = VertexPositionToVRAMCoordinate(m_drawing_offset.x + FixedToIntCoord(current_x)); const s32 x = m_drawing_offset.x + FixedToIntCoord(current_x);
const s32 y = VertexPositionToVRAMCoordinate(m_drawing_offset.y + FixedToIntCoord(current_y)); const s32 y = m_drawing_offset.y + FixedToIntCoord(current_y);
const u8 r = shading_enable ? FixedColorToInt(current_r) : p0->color_r; const u8 r = shading_enable ? FixedColorToInt(current_r) : p0->color_r;
const u8 g = shading_enable ? FixedColorToInt(current_g) : p0->color_g; const u8 g = shading_enable ? FixedColorToInt(current_g) : p0->color_g;