FrontendCommon: Add a post processing implementation

This commit is contained in:
Connor McLaughlin
2020-09-13 01:19:57 +10:00
parent 5804778339
commit 2819715260
25 changed files with 1828 additions and 22 deletions

View File

@ -99,6 +99,7 @@ void GPU_HW_OpenGL::ResetGraphicsAPIState()
if (m_resolution_scale > 1 && !m_supports_geometry_shaders)
glLineWidth(1.0f);
glBindVertexArray(0);
m_uniform_stream_buffer->Unbind();
}
void GPU_HW_OpenGL::RestoreGraphicsAPIState()
@ -114,6 +115,7 @@ void GPU_HW_OpenGL::RestoreGraphicsAPIState()
if (m_resolution_scale > 1 && !m_supports_geometry_shaders)
glLineWidth(static_cast<float>(m_resolution_scale));
glBindVertexArray(m_vao_id);
m_uniform_stream_buffer->Bind();
SetScissorFromDrawingArea();
m_batch_ubo_dirty = true;

View File

@ -69,6 +69,8 @@ public:
virtual bool CreateResources() = 0;
virtual void DestroyResources() = 0;
virtual bool SetPostProcessingChain(const std::string_view& config) = 0;
/// Call when the window size changes externally to recreate any resources.
virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) = 0;

View File

@ -396,6 +396,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("Display", "ShowResolution", false);
si.SetBoolValue("Display", "Fullscreen", false);
si.SetBoolValue("Display", "VSync", true);
si.SetStringValue("Display", "PostProcessChain", "");
si.SetBoolValue("CDROM", "ReadThread", true);
si.SetBoolValue("CDROM", "RegionCheck", true);

View File

@ -133,6 +133,7 @@ void Settings::Load(SettingsInterface& si)
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
display_show_resolution = si.GetBoolValue("Display", "ShowResolution", false);
video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
display_post_process_chain = si.GetStringValue("Display", "PostProcessChain", "");
cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true);
cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", true);
@ -242,6 +243,10 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
si.SetBoolValue("Display", "ShowResolution", display_show_speed);
si.SetBoolValue("Display", "VSync", video_sync_enabled);
if (display_post_process_chain.empty())
si.DeleteValue("Display", "PostProcessChain");
else
si.SetStringValue("Display", "PostProcessChain", display_post_process_chain.c_str());
si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread);
si.SetBoolValue("CDROM", "RegionCheck", cdrom_region_check);

View File

@ -84,6 +84,7 @@ struct Settings
GPURenderer gpu_renderer = GPURenderer::Software;
std::string gpu_adapter;
std::string display_post_process_chain;
u32 gpu_resolution_scale = 1;
bool gpu_use_debug_device = false;
bool gpu_true_color = true;

View File

@ -169,8 +169,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
ss << "\n";
}
void ShaderGen::DeclareUniformBuffer(std::stringstream& ss, const std::initializer_list<const char*>& members,
bool push_constant_on_vulkan)
void ShaderGen::WriteUniformBufferDeclaration(std::stringstream& ss, bool push_constant_on_vulkan)
{
if (IsVulkan())
{
@ -190,6 +189,12 @@ void ShaderGen::DeclareUniformBuffer(std::stringstream& ss, const std::initializ
{
ss << "cbuffer UBOBlock : register(b0)\n";
}
}
void ShaderGen::DeclareUniformBuffer(std::stringstream& ss, const std::initializer_list<const char*>& members,
bool push_constant_on_vulkan)
{
WriteUniformBufferDeclaration(ss, push_constant_on_vulkan);
ss << "{\n";
for (const char* member : members)

View File

@ -22,6 +22,7 @@ protected:
void SetGLSLVersionString();
void DefineMacro(std::stringstream& ss, const char* name, bool enabled);
void WriteHeader(std::stringstream& ss);
void WriteUniformBufferDeclaration(std::stringstream& ss, bool push_constant_on_vulkan);
void DeclareUniformBuffer(std::stringstream& ss, const std::initializer_list<const char*>& members,
bool push_constant_on_vulkan);
void DeclareTexture(std::stringstream& ss, const char* name, u32 index);