mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 06:25:37 +00:00
GPU: Don't truncate clear colour to 15-bit with true colour on
This commit is contained in:
parent
f7f5d45d7a
commit
aa1f3ad8f7
|
@ -667,7 +667,7 @@ void GPU::UpdateDrawingArea() {}
|
||||||
|
|
||||||
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, 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) {}
|
void GPU::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data) {}
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ protected:
|
||||||
virtual void UpdateDisplay();
|
virtual void UpdateDisplay();
|
||||||
virtual void UpdateDrawingArea();
|
virtual void UpdateDrawingArea();
|
||||||
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, 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 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, const u32* command_ptr);
|
virtual void DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32* command_ptr);
|
||||||
|
|
|
@ -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);
|
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.
|
FillVRAM(dst_x, dst_y, width, height, color);
|
||||||
// TODO: Force 8-bit color option.
|
|
||||||
const u16 color16 = RGBA8888ToRGBA5551(color);
|
|
||||||
|
|
||||||
FillVRAM(dst_x, dst_y, width, height, color16);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,7 @@ void GPU_HW_OpenGL::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer)
|
||||||
m_stats.num_vram_reads++;
|
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
|
// scale coordinates
|
||||||
x *= m_resolution_scale;
|
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);
|
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);
|
glClearColor(r, g, b, a);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ protected:
|
||||||
void UpdateDisplay() override;
|
void UpdateDisplay() override;
|
||||||
void UpdateDrawingArea() override;
|
void UpdateDrawingArea() 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, 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 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 FlushRender() override;
|
void FlushRender() override;
|
||||||
|
|
|
@ -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++)
|
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)
|
void GPU_SW::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data)
|
||||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
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, 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 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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue