summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/CMakeLists.txt2
-rw-r--r--src/video_core/host_shaders/fxaa.vert4
-rw-r--r--src/video_core/renderer_opengl/gl_blit_screen.cpp22
-rw-r--r--src/video_core/renderer_opengl/gl_blit_screen.h6
-rw-r--r--src/video_core/renderer_opengl/present/fxaa.cpp40
-rw-r--r--src/video_core/renderer_opengl/present/fxaa.h27
-rw-r--r--src/video_core/renderer_vulkan/present/fxaa.cpp2
7 files changed, 79 insertions, 24 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 524e2cae8..9879c3ad7 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -118,6 +118,8 @@ add_library(video_core STATIC
renderer_null/renderer_null.h
renderer_opengl/present/fsr.cpp
renderer_opengl/present/fsr.h
+ renderer_opengl/present/fxaa.cpp
+ renderer_opengl/present/fxaa.h
renderer_opengl/present/smaa.cpp
renderer_opengl/present/smaa.h
renderer_opengl/present/util.h
diff --git a/src/video_core/host_shaders/fxaa.vert b/src/video_core/host_shaders/fxaa.vert
index c2717d90d..223ab785e 100644
--- a/src/video_core/host_shaders/fxaa.vert
+++ b/src/video_core/host_shaders/fxaa.vert
@@ -7,8 +7,8 @@ out gl_PerVertex {
vec4 gl_Position;
};
-const vec2 vertices[4] =
- vec2[4](vec2(-1.0, 1.0), vec2(1.0, 1.0), vec2(-1.0, -1.0), vec2(1.0, -1.0));
+const vec2 vertices[3] =
+ vec2[3](vec2(-1,-1), vec2(3,-1), vec2(-1, 3));
layout (location = 0) out vec4 posPos;
diff --git a/src/video_core/renderer_opengl/gl_blit_screen.cpp b/src/video_core/renderer_opengl/gl_blit_screen.cpp
index cc343f171..44f6a0922 100644
--- a/src/video_core/renderer_opengl/gl_blit_screen.cpp
+++ b/src/video_core/renderer_opengl/gl_blit_screen.cpp
@@ -5,8 +5,6 @@
#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/fxaa_frag.h"
-#include "video_core/host_shaders/fxaa_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"
@@ -22,6 +20,7 @@
#include "video_core/renderer_opengl/gl_shader_util.h"
#include "video_core/renderer_opengl/gl_state_tracker.h"
#include "video_core/renderer_opengl/present/fsr.h"
+#include "video_core/renderer_opengl/present/fxaa.h"
#include "video_core/renderer_opengl/present/smaa.h"
#include "video_core/textures/decoders.h"
@@ -67,9 +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
- fxaa_vertex = CreateProgram(HostShaders::FXAA_VERT, GL_VERTEX_SHADER);
- fxaa_fragment = CreateProgram(HostShaders::FXAA_FRAG, GL_FRAGMENT_SHADER);
-
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);
@@ -131,8 +127,6 @@ BlitScreen::BlitScreen(RasterizerOpenGL& rasterizer_,
glClearTexImage(framebuffer_texture.resource.handle, 0, GL_RGBA, GL_UNSIGNED_BYTE,
framebuffer_data);
- aa_framebuffer.Create();
-
// Enable unified vertex attributes and query vertex buffer address when the driver supports it
if (device.HasVertexBufferUnifiedMemory()) {
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
@@ -244,13 +238,10 @@ void BlitScreen::ConfigureFramebufferTexture(const Tegra::FramebufferConfig& fra
framebuffer_texture.resource.Create(GL_TEXTURE_2D);
glTextureStorage2D(framebuffer_texture.resource.handle, 1, internal_format,
framebuffer_texture.width, framebuffer_texture.height);
- aa_texture.Release();
- aa_texture.Create(GL_TEXTURE_2D);
- glTextureStorage2D(aa_texture.handle, 1, GL_RGBA16F,
- Settings::values.resolution_info.ScaleUp(framebuffer_texture.width),
- Settings::values.resolution_info.ScaleUp(framebuffer_texture.height));
- glNamedFramebufferTexture(aa_framebuffer.handle, GL_COLOR_ATTACHMENT0, aa_texture.handle, 0);
+ fxaa = std::make_unique<FXAA>(
+ Settings::values.resolution_info.ScaleUp(framebuffer_texture.width),
+ Settings::values.resolution_info.ScaleUp(framebuffer_texture.height));
smaa = std::make_unique<SMAA>(
Settings::values.resolution_info.ScaleUp(framebuffer_texture.width),
Settings::values.resolution_info.ScaleUp(framebuffer_texture.height));
@@ -323,10 +314,7 @@ void BlitScreen::DrawScreen(const Tegra::FramebufferConfig& framebuffer,
switch (anti_aliasing) {
case Settings::AntiAliasing::Fxaa: {
- program_manager.BindPresentPrograms(fxaa_vertex.handle, fxaa_fragment.handle);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, aa_framebuffer.handle);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- glBindTextureUnit(0, aa_texture.handle);
+ glBindTextureUnit(0, fxaa->Draw(program_manager, info.display_texture));
} break;
case Settings::AntiAliasing::Smaa: {
glBindTextureUnit(0, smaa->Draw(program_manager, info.display_texture));
diff --git a/src/video_core/renderer_opengl/gl_blit_screen.h b/src/video_core/renderer_opengl/gl_blit_screen.h
index 945c7226a..2cb9a5015 100644
--- a/src/video_core/renderer_opengl/gl_blit_screen.h
+++ b/src/video_core/renderer_opengl/gl_blit_screen.h
@@ -22,6 +22,7 @@ namespace OpenGL {
class Device;
class FSR;
+class FXAA;
class ProgramManager;
class RasterizerOpenGL;
class SMAA;
@@ -77,8 +78,6 @@ private:
OGLSampler present_sampler;
OGLSampler present_sampler_nn;
OGLBuffer vertex_buffer;
- OGLProgram fxaa_vertex;
- OGLProgram fxaa_fragment;
OGLProgram present_vertex;
OGLProgram present_bilinear_fragment;
OGLProgram present_bicubic_fragment;
@@ -87,10 +86,9 @@ private:
/// Display information for Switch screen
TextureInfo framebuffer_texture;
- OGLTexture aa_texture;
- OGLFramebuffer aa_framebuffer;
std::unique_ptr<FSR> fsr;
+ std::unique_ptr<FXAA> fxaa;
std::unique_ptr<SMAA> smaa;
/// OpenGL framebuffer data
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
diff --git a/src/video_core/renderer_vulkan/present/fxaa.cpp b/src/video_core/renderer_vulkan/present/fxaa.cpp
index 6f87ddebb..6c772ada3 100644
--- a/src/video_core/renderer_vulkan/present/fxaa.cpp
+++ b/src/video_core/renderer_vulkan/present/fxaa.cpp
@@ -133,7 +133,7 @@ VkImageView FXAA::Draw(Scheduler& scheduler, size_t image_index, VkImage source_
BeginRenderPass(cmdbuf, renderpass, framebuffer, extent);
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set, {});
- cmdbuf.Draw(4, 1, 0, 0);
+ cmdbuf.Draw(3, 1, 0, 0);
cmdbuf.EndRenderPass();
TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
});