mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-17 03:15:39 +00:00
GPU: Add force true color setting
This commit is contained in:
parent
fc09b722ea
commit
c9feb7ea07
|
@ -26,7 +26,7 @@ bool GPU::Initialize(System* system, DMA* dma, InterruptController* interrupt_co
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::UpdateResolutionScale()
|
void GPU::UpdateSettings()
|
||||||
{
|
{
|
||||||
m_resolution_scale = std::clamp<u32>(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale);
|
m_resolution_scale = std::clamp<u32>(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
// Resolution scaling.
|
// Resolution scaling.
|
||||||
u32 GetResolutionScale() const { return m_resolution_scale; }
|
u32 GetResolutionScale() const { return m_resolution_scale; }
|
||||||
u32 GetMaxResolutionScale() const { return m_max_resolution_scale; }
|
u32 GetMaxResolutionScale() const { return m_max_resolution_scale; }
|
||||||
virtual void UpdateResolutionScale();
|
virtual void UpdateSettings();
|
||||||
|
|
||||||
// Ticks for hblank/vblank.
|
// Ticks for hblank/vblank.
|
||||||
void Execute(TickCount ticks);
|
void Execute(TickCount ticks);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "gpu_hw.h"
|
#include "gpu_hw.h"
|
||||||
#include "YBaseLib/Assert.h"
|
#include "YBaseLib/Assert.h"
|
||||||
#include "YBaseLib/Log.h"
|
#include "YBaseLib/Log.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "system.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
Log_SetChannel(GPU_HW);
|
Log_SetChannel(GPU_HW);
|
||||||
|
|
||||||
|
@ -15,6 +17,13 @@ void GPU_HW::Reset()
|
||||||
m_batch = {};
|
m_batch = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPU_HW::UpdateSettings()
|
||||||
|
{
|
||||||
|
GPU::UpdateSettings();
|
||||||
|
|
||||||
|
m_true_color = m_system->GetSettings().gpu_true_color;
|
||||||
|
}
|
||||||
|
|
||||||
void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command_ptr)
|
void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command_ptr)
|
||||||
{
|
{
|
||||||
const u32 texpage =
|
const u32 texpage =
|
||||||
|
@ -259,6 +268,7 @@ std::string GPU_HW::GenerateFragmentShader(HWBatchRenderMode transparency, Textu
|
||||||
DefineMacro(ss, "PALETTE_8_BIT", actual_texture_mode == GPU::TextureMode::Palette8Bit);
|
DefineMacro(ss, "PALETTE_8_BIT", actual_texture_mode == GPU::TextureMode::Palette8Bit);
|
||||||
DefineMacro(ss, "RAW_TEXTURE", raw_texture);
|
DefineMacro(ss, "RAW_TEXTURE", raw_texture);
|
||||||
DefineMacro(ss, "DITHERING", dithering);
|
DefineMacro(ss, "DITHERING", dithering);
|
||||||
|
DefineMacro(ss, "TRUE_COLOR", m_true_color);
|
||||||
|
|
||||||
ss << "const int[16] s_dither_values = int[16]( ";
|
ss << "const int[16] s_dither_values = int[16]( ";
|
||||||
for (u32 i = 0; i < 16; i++)
|
for (u32 i = 0; i < 16; i++)
|
||||||
|
@ -384,7 +394,9 @@ void main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Clip to 15-bit range
|
// Clip to 15-bit range
|
||||||
|
#if !TRUE_COLOR
|
||||||
icolor = TruncateTo15Bit(icolor);
|
icolor = TruncateTo15Bit(icolor);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
vec3 color = vec3(icolor) / vec3(255.0, 255.0, 255.0);
|
vec3 color = vec3(icolor) / vec3(255.0, 255.0, 255.0);
|
||||||
|
@ -585,7 +597,7 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32
|
||||||
const TransparencyMode transparency_mode =
|
const TransparencyMode transparency_mode =
|
||||||
rc.transparency_enable ? m_render_state.transparency_mode : TransparencyMode::Disabled;
|
rc.transparency_enable ? m_render_state.transparency_mode : TransparencyMode::Disabled;
|
||||||
const HWPrimitive rc_primitive = GetPrimitiveForCommand(rc);
|
const HWPrimitive rc_primitive = GetPrimitiveForCommand(rc);
|
||||||
const bool dithering_enable = rc.IsDitheringEnabled() ? m_GPUSTAT.dither_enable : false;
|
const bool dithering_enable = (!m_true_color && rc.IsDitheringEnabled()) ? m_GPUSTAT.dither_enable : false;
|
||||||
if (!IsFlushed())
|
if (!IsFlushed())
|
||||||
{
|
{
|
||||||
const u32 max_added_vertices = num_vertices + 2;
|
const u32 max_added_vertices = num_vertices + 2;
|
||||||
|
|
|
@ -12,6 +12,7 @@ public:
|
||||||
virtual ~GPU_HW();
|
virtual ~GPU_HW();
|
||||||
|
|
||||||
virtual void Reset() override;
|
virtual void Reset() override;
|
||||||
|
virtual void UpdateSettings() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum class HWPrimitive : u8
|
enum class HWPrimitive : u8
|
||||||
|
@ -107,6 +108,7 @@ protected:
|
||||||
std::string GenerateDisplayFragmentShader(bool depth_24bit, bool interlaced);
|
std::string GenerateDisplayFragmentShader(bool depth_24bit, bool interlaced);
|
||||||
|
|
||||||
HWRenderBatch m_batch = {};
|
HWRenderBatch m_batch = {};
|
||||||
|
bool m_true_color = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HWPrimitive GetPrimitiveForCommand(RenderCommand rc);
|
static HWPrimitive GetPrimitiveForCommand(RenderCommand rc);
|
||||||
|
|
|
@ -65,9 +65,9 @@ void GPU_HW_OpenGL::RestoreGraphicsAPIState()
|
||||||
glBindVertexArray(m_vao_id);
|
glBindVertexArray(m_vao_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_HW_OpenGL::UpdateResolutionScale()
|
void GPU_HW_OpenGL::UpdateSettings()
|
||||||
{
|
{
|
||||||
GPU_HW::UpdateResolutionScale();
|
GPU_HW::UpdateSettings();
|
||||||
|
|
||||||
CreateFramebuffer();
|
CreateFramebuffer();
|
||||||
CompilePrograms();
|
CompilePrograms();
|
||||||
|
@ -322,8 +322,8 @@ bool GPU_HW_OpenGL::CompileProgram(GL::Program& prog, HWBatchRenderMode render_m
|
||||||
|
|
||||||
void GPU_HW_OpenGL::SetDrawState(HWBatchRenderMode render_mode)
|
void GPU_HW_OpenGL::SetDrawState(HWBatchRenderMode render_mode)
|
||||||
{
|
{
|
||||||
const GL::Program& prog =
|
const GL::Program& prog = m_render_programs[static_cast<u8>(render_mode)][static_cast<u8>(m_batch.texture_mode)]
|
||||||
m_render_programs[static_cast<u32>(render_mode)][static_cast<u32>(m_batch.texture_mode)][m_batch.dithering];
|
[BoolToUInt8(m_batch.dithering)];
|
||||||
prog.Bind();
|
prog.Bind();
|
||||||
|
|
||||||
prog.Uniform2i(0, m_drawing_offset.x, m_drawing_offset.y);
|
prog.Uniform2i(0, m_drawing_offset.x, m_drawing_offset.y);
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
|
|
||||||
void ResetGraphicsAPIState() override;
|
void ResetGraphicsAPIState() override;
|
||||||
void RestoreGraphicsAPIState() override;
|
void RestoreGraphicsAPIState() override;
|
||||||
void UpdateResolutionScale() override;
|
void UpdateSettings() override;
|
||||||
|
|
||||||
void DrawRendererStatsWindow() override;
|
void DrawRendererStatsWindow() override;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct Settings
|
||||||
u32 gpu_resolution_scale = 1;
|
u32 gpu_resolution_scale = 1;
|
||||||
u32 max_gpu_resolution_scale = 1;
|
u32 max_gpu_resolution_scale = 1;
|
||||||
bool gpu_vsync = true;
|
bool gpu_vsync = true;
|
||||||
|
bool gpu_true_color = false;
|
||||||
bool display_linear_filtering = true;
|
bool display_linear_filtering = true;
|
||||||
|
|
||||||
struct DebugSettings
|
struct DebugSettings
|
||||||
|
|
|
@ -862,7 +862,7 @@ void SDLInterface::DrawMainMenuBar()
|
||||||
nullptr, current_internal_resolution == scale))
|
nullptr, current_internal_resolution == scale))
|
||||||
{
|
{
|
||||||
m_system->GetSettings().gpu_resolution_scale = scale;
|
m_system->GetSettings().gpu_resolution_scale = scale;
|
||||||
m_system->GetGPU()->UpdateResolutionScale();
|
m_system->GetGPU()->UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,10 +872,13 @@ void SDLInterface::DrawMainMenuBar()
|
||||||
if (ImGui::MenuItem("VSync", nullptr, &m_system->GetSettings().gpu_vsync))
|
if (ImGui::MenuItem("VSync", nullptr, &m_system->GetSettings().gpu_vsync))
|
||||||
UpdateAudioVisualSync();
|
UpdateAudioVisualSync();
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("True (24-Bit) Color", nullptr, &m_system->GetSettings().gpu_true_color))
|
||||||
|
m_system->GetGPU()->UpdateSettings();
|
||||||
|
|
||||||
if (ImGui::MenuItem("Display Linear Filtering", nullptr, &m_system->GetSettings().display_linear_filtering))
|
if (ImGui::MenuItem("Display Linear Filtering", nullptr, &m_system->GetSettings().display_linear_filtering))
|
||||||
{
|
{
|
||||||
// this has to update the display texture for now..
|
// this has to update the display texture for now..
|
||||||
m_system->GetGPU()->UpdateResolutionScale();
|
m_system->GetGPU()->UpdateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
|
@ -1300,7 +1303,7 @@ void SDLInterface::DoModifyInternalResolution(s32 increment)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
settings.gpu_resolution_scale = new_resolution_scale;
|
settings.gpu_resolution_scale = new_resolution_scale;
|
||||||
m_system->GetGPU()->UpdateResolutionScale();
|
m_system->GetGPU()->UpdateSettings();
|
||||||
|
|
||||||
AddOSDMessage(TinyString::FromFormat("Resolution scale set to %ux (%ux%u)", settings.gpu_resolution_scale,
|
AddOSDMessage(TinyString::FromFormat("Resolution scale set to %ux (%ux%u)", settings.gpu_resolution_scale,
|
||||||
GPU::VRAM_WIDTH * settings.gpu_resolution_scale,
|
GPU::VRAM_WIDTH * settings.gpu_resolution_scale,
|
||||||
|
|
Loading…
Reference in a new issue