diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index f3b4459c9..6d0216e54 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -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) {} diff --git a/src/core/gpu.h b/src/core/gpu.h index 367da8fd7..22314b22d 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -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); diff --git a/src/core/gpu_commands.cpp b/src/core/gpu_commands.cpp index 0024a95ce..ee1219c1d 100644 --- a/src/core/gpu_commands.cpp +++ b/src/core/gpu_commands.cpp @@ -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; } diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index c060515a4..d12a3009e 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -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); diff --git a/src/core/gpu_hw_opengl.h b/src/core/gpu_hw_opengl.h index ca392faf7..e4431886c 100644 --- a/src/core/gpu_hw_opengl.h +++ b/src/core/gpu_hw_opengl.h @@ -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; diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index ffcd82765..eb3b6538a 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -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) diff --git a/src/core/gpu_sw.h b/src/core/gpu_sw.h index 0275cc740..78073a18a 100644 --- a/src/core/gpu_sw.h +++ b/src/core/gpu_sw.h @@ -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;