GPU: Don't truncate clear colour to 15-bit with true colour on

This commit is contained in:
Connor McLaughlin 2019-11-03 01:05:37 +10:00
parent f7f5d45d7a
commit aa1f3ad8f7
7 changed files with 14 additions and 13 deletions

View File

@ -667,7 +667,7 @@ void GPU::UpdateDrawingArea() {}
void GPU::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) {}
void GPU::FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color) {}
void GPU::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) {}
void GPU::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) {}

View File

@ -284,7 +284,7 @@ protected:
virtual void UpdateDisplay();
virtual void UpdateDrawingArea();
virtual void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer);
virtual void FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color);
virtual void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color);
virtual void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data);
virtual void CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height);
virtual void DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32* command_ptr);

View File

@ -259,11 +259,7 @@ bool GPU::HandleFillRectangleCommand(const u32*& command_ptr, u32 command_size)
Log_DebugPrintf("Fill VRAM rectangle offset=(%u,%u), size=(%u,%u)", dst_x, dst_y, width, height);
// Drop higher precision when filling. Bit15 is set to 0.
// TODO: Force 8-bit color option.
const u16 color16 = RGBA8888ToRGBA5551(color);
FillVRAM(dst_x, dst_y, width, height, color16);
FillVRAM(dst_x, dst_y, width, height, color);
return true;
}

View File

@ -574,7 +574,7 @@ void GPU_HW_OpenGL::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer)
m_stats.num_vram_reads++;
}
void GPU_HW_OpenGL::FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color)
void GPU_HW_OpenGL::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
{
// scale coordinates
x *= m_resolution_scale;
@ -584,7 +584,11 @@ void GPU_HW_OpenGL::FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color)
glScissor(x, m_vram_texture->GetHeight() - y - height, width, height);
const auto [r, g, b, a] = RGBA8ToFloat(RGBA5551ToRGBA8888(color));
// drop precision unless true colour is enabled
if (!m_true_color)
color = RGBA5551ToRGBA8888(RGBA8888ToRGBA5551(color));
const auto [r, g, b, a] = RGBA8ToFloat(color);
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);

View File

@ -27,7 +27,7 @@ protected:
void UpdateDisplay() override;
void UpdateDrawingArea() override;
void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) override;
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color) override;
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) override;
void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) override;
void CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height) override;
void FlushRender() override;

View File

@ -41,10 +41,11 @@ void GPU_SW::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer)
}
}
void GPU_SW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color)
void GPU_SW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
{
const u16 color16 = RGBA8888ToRGBA5551(color);
for (u32 yoffs = 0; yoffs < height; yoffs++)
std::fill_n(GetPixelPtr(x, y + yoffs), width, color);
std::fill_n(GetPixelPtr(x, y + yoffs), width, color16);
}
void GPU_SW::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data)

View File

@ -37,7 +37,7 @@ protected:
};
void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) override;
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color) override;
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) override;
void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) override;
void CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height) override;