GPU: Force 16-bit precision when filling VRAM, clear mask bit

This commit is contained in:
Connor McLaughlin 2019-09-18 15:54:57 +10:00
parent d8150c996b
commit 23ef1cafbd
4 changed files with 11 additions and 7 deletions

View file

@ -614,7 +614,7 @@ bool GPU::HandleFillRectangleCommand()
if (m_GP0_command.size() < 3) if (m_GP0_command.size() < 3)
return false; return false;
const u32 color = (m_GP0_command[0] & UINT32_C(0x00FFFFFF)) | UINT32_C(0xFF000000); const u32 color = m_GP0_command[0] & UINT32_C(0x00FFFFFF);
const u32 dst_x = m_GP0_command[1] & UINT32_C(0xFFFF); const u32 dst_x = m_GP0_command[1] & UINT32_C(0xFFFF);
const u32 dst_y = m_GP0_command[1] >> 16; const u32 dst_y = m_GP0_command[1] >> 16;
const u32 width = m_GP0_command[2] & UINT32_C(0xFFFF); const u32 width = m_GP0_command[2] & UINT32_C(0xFFFF);
@ -622,7 +622,11 @@ bool GPU::HandleFillRectangleCommand()
Log_DebugPrintf("Fill VRAM rectangle offset=(%u,%u), size=(%u,%u)", dst_x, dst_y, width, height); Log_DebugPrintf("Fill VRAM rectangle offset=(%u,%u), size=(%u,%u)", dst_x, dst_y, width, height);
FillVRAM(dst_x, dst_y, width, height, color); // 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);
return true; return true;
} }
@ -735,7 +739,7 @@ void GPU::UpdateDisplay()
void GPU::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) {} void GPU::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) {}
void GPU::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) {} void GPU::FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color) {}
void GPU::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) {} void GPU::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) {}

View file

@ -166,7 +166,7 @@ protected:
// Rendering in the backend // Rendering in the backend
virtual void UpdateDisplay(); virtual void UpdateDisplay();
virtual void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer); virtual void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer);
virtual void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color); virtual void FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color);
virtual void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data); 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 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); virtual void DispatchRenderCommand(RenderCommand rc, u32 num_vertices);

View file

@ -230,14 +230,14 @@ void GPU_HW_OpenGL::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer)
} }
} }
void GPU_HW_OpenGL::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) void GPU_HW_OpenGL::FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color)
{ {
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer_fbo_id); glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer_fbo_id);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
glScissor(x, VRAM_HEIGHT - y - height, width, height); glScissor(x, VRAM_HEIGHT - y - height, width, height);
const auto [r, g, b, a] = RGBA8ToFloat(color); const auto [r, g, b, a] = RGBA8ToFloat(RGBA5551ToRGBA8888(color));
glClearColor(r, g, b, a); glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }

View file

@ -19,7 +19,7 @@ public:
protected: protected:
void UpdateDisplay() override; void UpdateDisplay() override;
void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) override; void ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) override;
void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) override; void FillVRAM(u32 x, u32 y, u32 width, u32 height, u16 color) override;
void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) 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 CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height) override;
void UpdateTexturePageTexture() override; void UpdateTexturePageTexture() override;