Merge branch 'postprocessing'

This commit is contained in:
Connor McLaughlin
2020-09-13 12:14:21 +10:00
54 changed files with 2894 additions and 612 deletions

View File

@ -10,11 +10,16 @@
#include "common/gl/context.h"
#include "common/gl/program.h"
#include "common/gl/stream_buffer.h"
#include "common/gl/texture.h"
#include "common/window_info.h"
#include "core/host_display.h"
#include <memory>
#ifndef LIBRETRO
#include "postprocessing_chain.h"
#endif
namespace FrontendCommon {
class OpenGLHostDisplay : public HostDisplay
@ -41,6 +46,8 @@ public:
virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;
virtual void DestroyRenderSurface() override;
virtual bool SetPostProcessingChain(const std::string_view& config) override;
std::unique_ptr<HostDisplayTexture> CreateTexture(u32 width, u32 height, const void* initial_data,
u32 initial_data_stride, bool dynamic) override;
void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* texture_data,
@ -71,6 +78,20 @@ protected:
s32 texture_view_height, bool linear_filter);
void RenderSoftwareCursor(s32 left, s32 bottom, s32 width, s32 height, HostDisplayTexture* texture_handle);
#ifndef LIBRETRO
struct PostProcessingStage
{
GL::Program program;
GL::Texture output_texture;
u32 uniforms_size;
};
bool CheckPostProcessingRenderTargets(u32 target_width, u32 target_height);
void ApplyPostProcessingChain(GLuint final_target, s32 final_left, s32 final_top, s32 final_width, s32 final_height,
void* texture_handle, u32 texture_width, s32 texture_height, s32 texture_view_x,
s32 texture_view_y, s32 texture_view_width, s32 texture_view_height);
#endif
std::unique_ptr<GL::Context> m_gl_context;
GL::Program m_display_program;
@ -78,6 +99,14 @@ protected:
GLuint m_display_vao = 0;
GLuint m_display_nearest_sampler = 0;
GLuint m_display_linear_sampler = 0;
GLuint m_uniform_buffer_alignment = 1;
#ifndef LIBRETRO
PostProcessingChain m_post_processing_chain;
GL::Texture m_post_processing_input_texture;
std::unique_ptr<GL::StreamBuffer> m_post_processing_ubo;
std::vector<PostProcessingStage> m_post_processing_stages;
#endif
};
} // namespace FrontendCommon