mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 14:55:42 +01:00
renderer_opengl: move out FSR shader source construction
This commit is contained in:
parent
60ee29aac3
commit
b78900e956
@ -66,14 +66,6 @@ BlitScreen::BlitScreen(RasterizerOpenGL& rasterizer_,
|
|||||||
: rasterizer(rasterizer_), device_memory(device_memory_), state_tracker(state_tracker_),
|
: rasterizer(rasterizer_), device_memory(device_memory_), state_tracker(state_tracker_),
|
||||||
program_manager(program_manager_), device(device_) {
|
program_manager(program_manager_), device(device_) {
|
||||||
// Create shader programs
|
// 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_vertex = CreateProgram(HostShaders::OPENGL_PRESENT_VERT, GL_VERTEX_SHADER);
|
||||||
present_bilinear_fragment = CreateProgram(HostShaders::OPENGL_PRESENT_FRAG, GL_FRAGMENT_SHADER);
|
present_bilinear_fragment = CreateProgram(HostShaders::OPENGL_PRESENT_FRAG, GL_FRAGMENT_SHADER);
|
||||||
present_bicubic_fragment = CreateProgram(HostShaders::PRESENT_BICUBIC_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),
|
CreateProgram(fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG),
|
||||||
GL_FRAGMENT_SHADER);
|
GL_FRAGMENT_SHADER);
|
||||||
|
|
||||||
std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG};
|
fsr = std::make_unique<FSR>();
|
||||||
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);
|
|
||||||
|
|
||||||
// Generate presentation sampler
|
// Generate presentation sampler
|
||||||
present_sampler.Create();
|
present_sampler.Create();
|
||||||
|
@ -3,20 +3,36 @@
|
|||||||
|
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "video_core/fsr.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_manager.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_util.h"
|
#include "video_core/renderer_opengl/gl_shader_util.h"
|
||||||
#include "video_core/renderer_opengl/present/fsr.h"
|
#include "video_core/renderer_opengl/present/fsr.h"
|
||||||
|
#include "video_core/renderer_opengl/present/util.h"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
using namespace FSR;
|
using namespace FSR;
|
||||||
|
|
||||||
using FsrConstants = std::array<u32, 4 * 4>;
|
using FsrConstants = std::array<u32, 4 * 4>;
|
||||||
|
|
||||||
FSR::FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source,
|
FSR::FSR() {
|
||||||
std::string_view fsr_rcas_source)
|
std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG};
|
||||||
: fsr_vertex{CreateProgram(fsr_vertex_source, GL_VERTEX_SHADER)},
|
ReplaceInclude(fsr_source, "ffx_a.h", HostShaders::FFX_A_H);
|
||||||
fsr_easu_frag{CreateProgram(fsr_easu_source, GL_FRAGMENT_SHADER)},
|
ReplaceInclude(fsr_source, "ffx_fsr1.h", HostShaders::FFX_FSR1_H);
|
||||||
fsr_rcas_frag{CreateProgram(fsr_rcas_source, GL_FRAGMENT_SHADER)} {
|
|
||||||
|
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, 0, 1.0f, 1.0f);
|
||||||
glProgramUniform2f(fsr_vertex.handle, 1, 0.0f, 0.0f);
|
glProgramUniform2f(fsr_vertex.handle, 1, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,7 @@ class ProgramManager;
|
|||||||
|
|
||||||
class FSR {
|
class FSR {
|
||||||
public:
|
public:
|
||||||
explicit FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source,
|
explicit FSR();
|
||||||
std::string_view fsr_rcas_source);
|
|
||||||
~FSR();
|
~FSR();
|
||||||
|
|
||||||
void Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen,
|
void Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen,
|
||||||
|
Loading…
Reference in New Issue
Block a user