diff options
Diffstat (limited to 'src/video_core/renderer_opengl')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_blit_screen.cpp | 20 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/present/fsr.cpp | 26 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/present/fsr.h | 3 |
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 | ||
| 10 | namespace OpenGL { | 17 | namespace OpenGL { |
| 11 | using namespace FSR; | 18 | using namespace FSR; |
| 12 | 19 | ||
| 13 | using FsrConstants = std::array<u32, 4 * 4>; | 20 | using FsrConstants = std::array<u32, 4 * 4>; |
| 14 | 21 | ||
| 15 | FSR::FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source, | 22 | FSR::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 | ||
| 17 | class FSR { | 17 | class FSR { |
| 18 | public: | 18 | public: |
| 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, |