summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/present
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_opengl/present')
-rw-r--r--src/video_core/renderer_opengl/present/fxaa.cpp40
-rw-r--r--src/video_core/renderer_opengl/present/fxaa.h27
2 files changed, 67 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/present/fxaa.cpp b/src/video_core/renderer_opengl/present/fxaa.cpp
new file mode 100644
index 000000000..9425c42fa
--- /dev/null
+++ b/src/video_core/renderer_opengl/present/fxaa.cpp
@@ -0,0 +1,40 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "video_core/host_shaders/fxaa_frag.h"
+#include "video_core/host_shaders/fxaa_vert.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/fxaa.h"
+#include "video_core/renderer_opengl/present/util.h"
+
+namespace OpenGL {
+
+FXAA::FXAA(u32 width, u32 height) {
+ vert_shader = CreateProgram(HostShaders::FXAA_VERT, GL_VERTEX_SHADER);
+ frag_shader = CreateProgram(HostShaders::FXAA_FRAG, GL_FRAGMENT_SHADER);
+
+ sampler = CreateBilinearSampler();
+
+ framebuffer.Create();
+
+ texture.Create(GL_TEXTURE_2D);
+ glTextureStorage2D(texture.handle, 1, GL_RGBA16F, width, height);
+ glNamedFramebufferTexture(framebuffer.handle, GL_COLOR_ATTACHMENT0, texture.handle, 0);
+}
+
+FXAA::~FXAA() = default;
+
+GLuint FXAA::Draw(ProgramManager& program_manager, GLuint input_texture) {
+ glFrontFace(GL_CCW);
+
+ program_manager.BindPresentPrograms(vert_shader.handle, frag_shader.handle);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer.handle);
+ glBindTextureUnit(0, input_texture);
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+ glFrontFace(GL_CW);
+
+ return texture.handle;
+}
+
+} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/present/fxaa.h b/src/video_core/renderer_opengl/present/fxaa.h
new file mode 100644
index 000000000..b898198f1
--- /dev/null
+++ b/src/video_core/renderer_opengl/present/fxaa.h
@@ -0,0 +1,27 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "video_core/renderer_opengl/gl_resource_manager.h"
+
+namespace OpenGL {
+
+class ProgramManager;
+
+class FXAA {
+public:
+ explicit FXAA(u32 width, u32 height);
+ ~FXAA();
+
+ GLuint Draw(ProgramManager& program_manager, GLuint input_texture);
+
+private:
+ OGLProgram vert_shader;
+ OGLProgram frag_shader;
+ OGLSampler sampler;
+ OGLFramebuffer framebuffer;
+ OGLTexture texture;
+};
+
+} // namespace OpenGL