GPU/HW: GPU-based RGBA8->RGB5551 conversion for readbacks
This commit is contained in:
@ -28,6 +28,8 @@ void GPU_HW::Reset()
|
||||
{
|
||||
GPU::Reset();
|
||||
|
||||
m_vram_shadow.fill(0);
|
||||
|
||||
m_batch = {};
|
||||
m_batch_ubo_data = {};
|
||||
m_batch_ubo_dirty = true;
|
||||
@ -181,6 +183,22 @@ void GPU_HW::CalcScissorRect(int* left, int* top, int* right, int* bottom)
|
||||
*bottom = std::max<u32>((m_drawing_area.bottom + 1) * m_resolution_scale, *top + 1);
|
||||
}
|
||||
|
||||
Common::Rectangle<u32> GPU_HW::GetVRAMTransferBounds(u32 x, u32 y, u32 width, u32 height)
|
||||
{
|
||||
Common::Rectangle<u32> out_rc = Common::Rectangle<u32>::FromExtents(x, y, width, height);
|
||||
if (out_rc.right > VRAM_WIDTH)
|
||||
{
|
||||
out_rc.left = 0;
|
||||
out_rc.right = VRAM_WIDTH;
|
||||
}
|
||||
if (out_rc.bottom > VRAM_HEIGHT)
|
||||
{
|
||||
out_rc.top = 0;
|
||||
out_rc.bottom = VRAM_HEIGHT;
|
||||
}
|
||||
return out_rc;
|
||||
}
|
||||
|
||||
GPU_HW::BatchPrimitive GPU_HW::GetPrimitiveForCommand(RenderCommand rc)
|
||||
{
|
||||
if (rc.primitive == Primitive::Line)
|
||||
@ -191,6 +209,22 @@ GPU_HW::BatchPrimitive GPU_HW::GetPrimitiveForCommand(RenderCommand rc)
|
||||
return BatchPrimitive::Triangles;
|
||||
}
|
||||
|
||||
void GPU_HW::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer)
|
||||
{
|
||||
u8* out_ptr = static_cast<u8*>(buffer);
|
||||
|
||||
for (u32 row = 0; row < height; row++)
|
||||
{
|
||||
const u32 row_offset = ((y + row) % VRAM_HEIGHT) * VRAM_WIDTH;
|
||||
for (u32 col = 0; col < width; col++)
|
||||
{
|
||||
const u32 col_offset = row_offset + ((x + col) % VRAM_WIDTH);
|
||||
std::memcpy(out_ptr, &m_vram_shadow[col_offset], sizeof(u16));
|
||||
out_ptr += sizeof(u16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_HW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
|
||||
{
|
||||
m_vram_dirty_rect.Include(Common::Rectangle<u32>::FromExtents(x, y, width, height));
|
||||
|
||||
Reference in New Issue
Block a user