GPU: Fix incorrect sign extension of positions
Fixes missing objects in Skullmonkeys (again).
This commit is contained in:
parent
a46d304d79
commit
fe25f005c2
|
@ -119,7 +119,7 @@ struct BitField
|
|||
}
|
||||
else if constexpr (std::is_signed_v<DataType>)
|
||||
{
|
||||
constexpr int shift = 8 * sizeof(DataType) - BitCount + 1;
|
||||
constexpr int shift = 8 * sizeof(DataType) - BitCount;
|
||||
return (static_cast<DataType>(data >> BitIndex) << shift) >> shift;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -303,12 +303,12 @@ protected:
|
|||
{
|
||||
u32 bits;
|
||||
|
||||
BitField<u32, s32, 0, 12> x;
|
||||
BitField<u32, s32, 16, 12> y;
|
||||
BitField<u32, s32, 0, 11> x;
|
||||
BitField<u32, s32, 16, 11> 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
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue