From fe25f005c25b7a2289de4cfa02f19090f1576935 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 11 Oct 2020 11:57:32 +1000 Subject: [PATCH] GPU: Fix incorrect sign extension of positions Fixes missing objects in Skullmonkeys (again). --- src/common/bitfield.h | 2 +- src/core/gpu.h | 6 +++--- src/core/gpu_sw.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/bitfield.h b/src/common/bitfield.h index 1c803c9a4..fe1449fe6 100644 --- a/src/common/bitfield.h +++ b/src/common/bitfield.h @@ -119,7 +119,7 @@ struct BitField } else if constexpr (std::is_signed_v) { - constexpr int shift = 8 * sizeof(DataType) - BitCount + 1; + constexpr int shift = 8 * sizeof(DataType) - BitCount; return (static_cast(data >> BitIndex) << shift) >> shift; } else diff --git a/src/core/gpu.h b/src/core/gpu.h index 5822576a7..ee217670e 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -303,12 +303,12 @@ protected: { u32 bits; - BitField x; - BitField y; + BitField x; + BitField y; }; // Sprites/rectangles should be clipped to 12 bits before drawing. - static constexpr s32 TruncateVertexPosition(s32 x) { return SignExtendN<12, s32>(x); } + static constexpr s32 TruncateVertexPosition(s32 x) { return SignExtendN<11, s32>(x); } struct NativeVertex { diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index ff3114994..e60efee1a 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -236,8 +236,8 @@ void GPU_SW::DispatchRenderCommand() vert.b = Truncate8(color_rgb >> 16); const VertexPosition vp{FifoPop()}; - vert.x = TruncateVertexPosition(m_drawing_offset.x + vp.x); - vert.y = TruncateVertexPosition(m_drawing_offset.y + vp.y); + vert.x = m_drawing_offset.x + vp.x; + vert.y = m_drawing_offset.y + vp.y; if (textured) {