summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorGravatar Liam2024-01-15 00:36:54 -0500
committerGravatar Liam2024-01-31 11:27:20 -0500
commitb78900e9567a4c98c44ef06b5088ccb507464d66 (patch)
treec76648527eca46bae5ece511cea0b51a60f6444d /src/video_core/renderer_opengl
parentrenderer_opengl: split out FXAA (diff)
downloadyuzu-b78900e9567a4c98c44ef06b5088ccb507464d66.tar.gz
yuzu-b78900e9567a4c98c44ef06b5088ccb507464d66.tar.xz
yuzu-b78900e9567a4c98c44ef06b5088ccb507464d66.zip
renderer_opengl: move out FSR shader source construction
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_blit_screen.cpp20
-rw-r--r--src/video_core/renderer_opengl/present/fsr.cpp26
-rw-r--r--src/video_core/renderer_opengl/present/fsr.h3
3 files changed, 23 insertions, 26 deletions
diff --git a/src/video_core/renderer_opengl/gl_blit_screen.cpp b/src/video_core/renderer_opengl/gl_blit_screen.cpp
index 44f6a0922..4e9d80d10 100644
--- a/src/video_core/renderer_opengl/gl_blit_screen.cpp
+++ b/src/video_core/renderer_opengl/gl_blit_screen.cpp
@@ -66,14 +66,6 @@ BlitScreen::BlitScreen(RasterizerOpenGL& rasterizer_,
66 : rasterizer(rasterizer_), device_memory(device_memory_), state_tracker(state_tracker_), 66 : rasterizer(rasterizer_), device_memory(device_memory_), state_tracker(state_tracker_),
67 program_manager(program_manager_), device(device_) { 67 program_manager(program_manager_), device(device_) {
68 // Create shader programs 68 // Create shader programs
69 const auto replace_include = [](std::string& shader_source, std::string_view include_name,
70 std::string_view include_content) {
71 const std::string include_string = fmt::format("#include \"{}\"", include_name);
72 const std::size_t pos = shader_source.find(include_string);
73 ASSERT(pos != std::string::npos);
74 shader_source.replace(pos, include_string.size(), include_content);
75 };
76
77 present_vertex = CreateProgram(HostShaders::OPENGL_PRESENT_VERT, GL_VERTEX_SHADER); 69 present_vertex = CreateProgram(HostShaders::OPENGL_PRESENT_VERT, GL_VERTEX_SHADER);
78 present_bilinear_fragment = CreateProgram(HostShaders::OPENGL_PRESENT_FRAG, GL_FRAGMENT_SHADER); 70 present_bilinear_fragment = CreateProgram(HostShaders::OPENGL_PRESENT_FRAG, GL_FRAGMENT_SHADER);
79 present_bicubic_fragment = CreateProgram(HostShaders::PRESENT_BICUBIC_FRAG, GL_FRAGMENT_SHADER); 71 present_bicubic_fragment = CreateProgram(HostShaders::PRESENT_BICUBIC_FRAG, GL_FRAGMENT_SHADER);
@@ -83,17 +75,7 @@ BlitScreen::BlitScreen(RasterizerOpenGL& rasterizer_,
83 CreateProgram(fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG), 75 CreateProgram(fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG),
84 GL_FRAGMENT_SHADER); 76 GL_FRAGMENT_SHADER);
85 77
86 std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG}; 78 fsr = std::make_unique<FSR>();
87 replace_include(fsr_source, "ffx_a.h", HostShaders::FFX_A_H);
88 replace_include(fsr_source, "ffx_fsr1.h", HostShaders::FFX_FSR1_H);
89
90 std::string fsr_easu_frag_source{HostShaders::OPENGL_FIDELITYFX_FSR_EASU_FRAG};
91 std::string fsr_rcas_frag_source{HostShaders::OPENGL_FIDELITYFX_FSR_RCAS_FRAG};
92 replace_include(fsr_easu_frag_source, "opengl_fidelityfx_fsr.frag", fsr_source);
93 replace_include(fsr_rcas_frag_source, "opengl_fidelityfx_fsr.frag", fsr_source);
94
95 fsr = std::make_unique<FSR>(HostShaders::FULL_SCREEN_TRIANGLE_VERT, fsr_easu_frag_source,
96 fsr_rcas_frag_source);
97 79
98 // Generate presentation sampler 80 // Generate presentation sampler
99 present_sampler.Create(); 81 present_sampler.Create();
diff --git a/src/video_core/renderer_opengl/present/fsr.cpp b/src/video_core/renderer_opengl/present/fsr.cpp
index e5945b80b..a5540bb0c 100644
--- a/src/video_core/renderer_opengl/present/fsr.cpp
+++ b/src/video_core/renderer_opengl/present/fsr.cpp
@@ -3,20 +3,36 @@
3 3
4#include "common/settings.h" 4#include "common/settings.h"
5#include "video_core/fsr.h" 5#include "video_core/fsr.h"
6#include "video_core/host_shaders/ffx_a_h.h"
7#include "video_core/host_shaders/ffx_fsr1_h.h"
8#include "video_core/host_shaders/full_screen_triangle_vert.h"
9#include "video_core/host_shaders/opengl_fidelityfx_fsr_easu_frag.h"
10#include "video_core/host_shaders/opengl_fidelityfx_fsr_frag.h"
11#include "video_core/host_shaders/opengl_fidelityfx_fsr_rcas_frag.h"
6#include "video_core/renderer_opengl/gl_shader_manager.h" 12#include "video_core/renderer_opengl/gl_shader_manager.h"
7#include "video_core/renderer_opengl/gl_shader_util.h" 13#include "video_core/renderer_opengl/gl_shader_util.h"
8#include "video_core/renderer_opengl/present/fsr.h" 14#include "video_core/renderer_opengl/present/fsr.h"
15#include "video_core/renderer_opengl/present/util.h"
9 16
10namespace OpenGL { 17namespace OpenGL {
11using namespace FSR; 18using namespace FSR;
12 19
13using FsrConstants = std::array<u32, 4 * 4>; 20using FsrConstants = std::array<u32, 4 * 4>;
14 21
15FSR::FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source, 22FSR::FSR() {
16 std::string_view fsr_rcas_source) 23 std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG};
17 : fsr_vertex{CreateProgram(fsr_vertex_source, GL_VERTEX_SHADER)}, 24 ReplaceInclude(fsr_source, "ffx_a.h", HostShaders::FFX_A_H);
18 fsr_easu_frag{CreateProgram(fsr_easu_source, GL_FRAGMENT_SHADER)}, 25 ReplaceInclude(fsr_source, "ffx_fsr1.h", HostShaders::FFX_FSR1_H);
19 fsr_rcas_frag{CreateProgram(fsr_rcas_source, GL_FRAGMENT_SHADER)} { 26
27 std::string fsr_easu_source{HostShaders::OPENGL_FIDELITYFX_FSR_EASU_FRAG};
28 std::string fsr_rcas_source{HostShaders::OPENGL_FIDELITYFX_FSR_RCAS_FRAG};
29 ReplaceInclude(fsr_easu_source, "opengl_fidelityfx_fsr.frag", fsr_source);
30 ReplaceInclude(fsr_rcas_source, "opengl_fidelityfx_fsr.frag", fsr_source);
31
32 fsr_vertex = CreateProgram(HostShaders::FULL_SCREEN_TRIANGLE_VERT, GL_VERTEX_SHADER);
33 fsr_easu_frag = CreateProgram(fsr_easu_source, GL_FRAGMENT_SHADER);
34 fsr_rcas_frag = CreateProgram(fsr_rcas_source, GL_FRAGMENT_SHADER);
35
20 glProgramUniform2f(fsr_vertex.handle, 0, 1.0f, 1.0f); 36 glProgramUniform2f(fsr_vertex.handle, 0, 1.0f, 1.0f);
21 glProgramUniform2f(fsr_vertex.handle, 1, 0.0f, 0.0f); 37 glProgramUniform2f(fsr_vertex.handle, 1, 0.0f, 0.0f);
22} 38}
diff --git a/src/video_core/renderer_opengl/present/fsr.h b/src/video_core/renderer_opengl/present/fsr.h
index a5092e396..fa57c6f00 100644
--- a/src/video_core/renderer_opengl/present/fsr.h
+++ b/src/video_core/renderer_opengl/present/fsr.h
@@ -16,8 +16,7 @@ class ProgramManager;
16 16
17class FSR { 17class FSR {
18public: 18public:
19 explicit FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source, 19 explicit FSR();
20 std::string_view fsr_rcas_source);
21 ~FSR(); 20 ~FSR();
22 21
23 void Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen, 22 void Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen,