renderer_opengl: move out FSR shader source construction

This commit is contained in:
Liam 2024-01-15 00:36:54 -05:00
parent 60ee29aac3
commit b78900e956
3 changed files with 23 additions and 26 deletions

View File

@ -66,14 +66,6 @@ BlitScreen::BlitScreen(RasterizerOpenGL& rasterizer_,
: rasterizer(rasterizer_), device_memory(device_memory_), state_tracker(state_tracker_),
program_manager(program_manager_), device(device_) {
// Create shader programs
const auto replace_include = [](std::string& shader_source, std::string_view include_name,
std::string_view include_content) {
const std::string include_string = fmt::format("#include \"{}\"", include_name);
const std::size_t pos = shader_source.find(include_string);
ASSERT(pos != std::string::npos);
shader_source.replace(pos, include_string.size(), include_content);
};
present_vertex = CreateProgram(HostShaders::OPENGL_PRESENT_VERT, GL_VERTEX_SHADER);
present_bilinear_fragment = CreateProgram(HostShaders::OPENGL_PRESENT_FRAG, GL_FRAGMENT_SHADER);
present_bicubic_fragment = CreateProgram(HostShaders::PRESENT_BICUBIC_FRAG, GL_FRAGMENT_SHADER);
@ -83,17 +75,7 @@ BlitScreen::BlitScreen(RasterizerOpenGL& rasterizer_,
CreateProgram(fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG),
GL_FRAGMENT_SHADER);
std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG};
replace_include(fsr_source, "ffx_a.h", HostShaders::FFX_A_H);
replace_include(fsr_source, "ffx_fsr1.h", HostShaders::FFX_FSR1_H);
std::string fsr_easu_frag_source{HostShaders::OPENGL_FIDELITYFX_FSR_EASU_FRAG};
std::string fsr_rcas_frag_source{HostShaders::OPENGL_FIDELITYFX_FSR_RCAS_FRAG};
replace_include(fsr_easu_frag_source, "opengl_fidelityfx_fsr.frag", fsr_source);
replace_include(fsr_rcas_frag_source, "opengl_fidelityfx_fsr.frag", fsr_source);
fsr = std::make_unique<FSR>(HostShaders::FULL_SCREEN_TRIANGLE_VERT, fsr_easu_frag_source,
fsr_rcas_frag_source);
fsr = std::make_unique<FSR>();
// Generate presentation sampler
present_sampler.Create();

View File

@ -3,20 +3,36 @@
#include "common/settings.h"
#include "video_core/fsr.h"
#include "video_core/host_shaders/ffx_a_h.h"
#include "video_core/host_shaders/ffx_fsr1_h.h"
#include "video_core/host_shaders/full_screen_triangle_vert.h"
#include "video_core/host_shaders/opengl_fidelityfx_fsr_easu_frag.h"
#include "video_core/host_shaders/opengl_fidelityfx_fsr_frag.h"
#include "video_core/host_shaders/opengl_fidelityfx_fsr_rcas_frag.h"
#include "video_core/renderer_opengl/gl_shader_manager.h"
#include "video_core/renderer_opengl/gl_shader_util.h"
#include "video_core/renderer_opengl/present/fsr.h"
#include "video_core/renderer_opengl/present/util.h"
namespace OpenGL {
using namespace FSR;
using FsrConstants = std::array<u32, 4 * 4>;
FSR::FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source,
std::string_view fsr_rcas_source)
: fsr_vertex{CreateProgram(fsr_vertex_source, GL_VERTEX_SHADER)},
fsr_easu_frag{CreateProgram(fsr_easu_source, GL_FRAGMENT_SHADER)},
fsr_rcas_frag{CreateProgram(fsr_rcas_source, GL_FRAGMENT_SHADER)} {
FSR::FSR() {
std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG};
ReplaceInclude(fsr_source, "ffx_a.h", HostShaders::FFX_A_H);
ReplaceInclude(fsr_source, "ffx_fsr1.h", HostShaders::FFX_FSR1_H);
std::string fsr_easu_source{HostShaders::OPENGL_FIDELITYFX_FSR_EASU_FRAG};
std::string fsr_rcas_source{HostShaders::OPENGL_FIDELITYFX_FSR_RCAS_FRAG};
ReplaceInclude(fsr_easu_source, "opengl_fidelityfx_fsr.frag", fsr_source);
ReplaceInclude(fsr_rcas_source, "opengl_fidelityfx_fsr.frag", fsr_source);
fsr_vertex = CreateProgram(HostShaders::FULL_SCREEN_TRIANGLE_VERT, GL_VERTEX_SHADER);
fsr_easu_frag = CreateProgram(fsr_easu_source, GL_FRAGMENT_SHADER);
fsr_rcas_frag = CreateProgram(fsr_rcas_source, GL_FRAGMENT_SHADER);
glProgramUniform2f(fsr_vertex.handle, 0, 1.0f, 1.0f);
glProgramUniform2f(fsr_vertex.handle, 1, 0.0f, 0.0f);
}

View File

@ -16,8 +16,7 @@ class ProgramManager;
class FSR {
public:
explicit FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source,
std::string_view fsr_rcas_source);
explicit FSR();
~FSR();
void Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen,