GPU: Use BitField sign extending for position

This commit is contained in:
Connor McLaughlin 2019-10-04 23:21:20 +10:00
parent e7d68ba304
commit 27bc65fc2a
3 changed files with 9 additions and 20 deletions

View File

@ -477,8 +477,8 @@ void GPU::WriteGP0(u32 value)
case 0xE5: // Set drawing offset
{
m_drawing_offset.x = S11ToS32(param & UINT32_C(0x7FF));
m_drawing_offset.y = S11ToS32((param >> 11) & UINT32_C(0x7FF));
m_drawing_offset.x = SignExtendN<11, u32>(param & UINT32_C(0x7FF));
m_drawing_offset.y = SignExtendN<11, u32>((param >> 11) & UINT32_C(0x7FF));
Log_DebugPrintf("Set drawing offset (%d, %d)", m_drawing_offset.x, m_drawing_offset.y);
}
break;

View File

@ -61,14 +61,6 @@ public:
void Execute(TickCount ticks);
protected:
static constexpr s32 S11ToS32(u32 value)
{
if (value & (UINT16_C(1) << 10))
return static_cast<s32>(UINT32_C(0xFFFFF800) | value);
else
return value;
}
// Helper/format conversion functions.
static constexpr u32 RGBA5551ToRGBA8888(u16 color)
{
@ -164,11 +156,8 @@ protected:
{
u32 bits;
BitField<u32, u32, 0, 11> x_s11;
BitField<u32, u32, 16, 11> y_s11;
s32 x() const { return S11ToS32(x_s11); }
s32 y() const { return S11ToS32(y_s11); }
BitField<u32, s32, 0, 11> x;
BitField<u32, s32, 16, 11> y;
};
struct DebugOptions

View File

@ -41,8 +41,8 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices)
hw_vert.color = (shaded && i > 0) ? (m_GP0_command[buffer_pos++] & UINT32_C(0x00FFFFFF)) : first_color;
const VertexPosition vp{m_GP0_command[buffer_pos++]};
hw_vert.x = vp.x();
hw_vert.y = vp.y();
hw_vert.x = vp.x;
hw_vert.y = vp.y;
hw_vert.texpage = texpage;
if (textured)
@ -73,8 +73,8 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices)
const bool textured = rc.texture_enable;
const u32 color = rc.color_for_first_vertex;
const VertexPosition vp{m_GP0_command[buffer_pos++]};
const s32 pos_left = vp.x();
const s32 pos_top = vp.y();
const s32 pos_left = vp.x;
const s32 pos_top = vp.y;
const auto [tex_left, tex_top] =
HWVertex::DecodeTexcoord(rc.texture_enable ? Truncate16(m_GP0_command[buffer_pos++]) : 0);
s32 rectangle_width;
@ -128,7 +128,7 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices)
{
const u32 color = (shaded && i > 0) ? (m_GP0_command[buffer_pos++] & UINT32_C(0x00FFFFFF)) : first_color;
const VertexPosition vp{m_GP0_command[buffer_pos++]};
m_batch.vertices.push_back(HWVertex{vp.x(), vp.y(), color});
m_batch.vertices.push_back(HWVertex{vp.x.GetValue(), vp.y.GetValue(), color});
}
}
break;