diff options
| author | 2023-01-27 19:28:35 -0500 | |
|---|---|---|
| committer | 2023-01-27 19:28:35 -0500 | |
| commit | 6fa86989f10ef9f87701147e4b4b426f309edac4 (patch) | |
| tree | e4b3c203e4a2349ec8f72e5f5d162eab2a1d9ecd | |
| parent | Merge pull request #9666 from liamwhite/wait-for-me (diff) | |
| parent | video_core/opengl: Add FSR upscaling filter to the OpenGL renderer (diff) | |
| download | yuzu-6fa86989f10ef9f87701147e4b4b426f309edac4.tar.gz yuzu-6fa86989f10ef9f87701147e4b4b426f309edac4.tar.xz yuzu-6fa86989f10ef9f87701147e4b4b426f309edac4.zip | |
Merge pull request #9539 from Wollnashorn/opengl-fsr
video_core/opengl: Added FSR upscaling filter to the OpenGL renderer
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/video_core/fsr.cpp | 148 | ||||
| -rw-r--r-- | src/video_core/fsr.h | 19 | ||||
| -rw-r--r-- | src/video_core/host_shaders/CMakeLists.txt | 30 | ||||
| -rw-r--r-- | src/video_core/host_shaders/opengl_fidelityfx_fsr.frag | 108 | ||||
| -rw-r--r-- | src/video_core/host_shaders/opengl_fidelityfx_fsr_easu.frag | 9 | ||||
| -rw-r--r-- | src/video_core/host_shaders/opengl_fidelityfx_fsr_rcas.frag | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_fsr.cpp | 101 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_fsr.h | 43 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 90 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_fsr.cpp | 144 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.ui | 2 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 9 |
14 files changed, 547 insertions, 172 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index b474eb363..4742bcbe9 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -52,6 +52,8 @@ add_library(video_core STATIC | |||
| 52 | engines/puller.cpp | 52 | engines/puller.cpp |
| 53 | engines/puller.h | 53 | engines/puller.h |
| 54 | framebuffer_config.h | 54 | framebuffer_config.h |
| 55 | fsr.cpp | ||
| 56 | fsr.h | ||
| 55 | host1x/codecs/codec.cpp | 57 | host1x/codecs/codec.cpp |
| 56 | host1x/codecs/codec.h | 58 | host1x/codecs/codec.h |
| 57 | host1x/codecs/h264.cpp | 59 | host1x/codecs/h264.cpp |
| @@ -110,6 +112,8 @@ add_library(video_core STATIC | |||
| 110 | renderer_opengl/gl_device.h | 112 | renderer_opengl/gl_device.h |
| 111 | renderer_opengl/gl_fence_manager.cpp | 113 | renderer_opengl/gl_fence_manager.cpp |
| 112 | renderer_opengl/gl_fence_manager.h | 114 | renderer_opengl/gl_fence_manager.h |
| 115 | renderer_opengl/gl_fsr.cpp | ||
| 116 | renderer_opengl/gl_fsr.h | ||
| 113 | renderer_opengl/gl_graphics_pipeline.cpp | 117 | renderer_opengl/gl_graphics_pipeline.cpp |
| 114 | renderer_opengl/gl_graphics_pipeline.h | 118 | renderer_opengl/gl_graphics_pipeline.h |
| 115 | renderer_opengl/gl_rasterizer.cpp | 119 | renderer_opengl/gl_rasterizer.cpp |
diff --git a/src/video_core/fsr.cpp b/src/video_core/fsr.cpp new file mode 100644 index 000000000..5653c64fc --- /dev/null +++ b/src/video_core/fsr.cpp | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <cmath> | ||
| 5 | #include "video_core/fsr.h" | ||
| 6 | |||
| 7 | namespace FSR { | ||
| 8 | namespace { | ||
| 9 | // Reimplementations of the constant generating functions in ffx_fsr1.h | ||
| 10 | // GCC generated a lot of warnings when using the official header. | ||
| 11 | u32 AU1_AH1_AF1(f32 f) { | ||
| 12 | static constexpr u32 base[512]{ | ||
| 13 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 14 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 15 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 16 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 17 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 18 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 19 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 20 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 21 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 22 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, | ||
| 23 | 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x0c00, 0x1000, 0x1400, 0x1800, 0x1c00, 0x2000, | ||
| 24 | 0x2400, 0x2800, 0x2c00, 0x3000, 0x3400, 0x3800, 0x3c00, 0x4000, 0x4400, 0x4800, 0x4c00, | ||
| 25 | 0x5000, 0x5400, 0x5800, 0x5c00, 0x6000, 0x6400, 0x6800, 0x6c00, 0x7000, 0x7400, 0x7800, | ||
| 26 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 27 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 28 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 29 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 30 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 31 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 32 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 33 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 34 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 35 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 36 | 0x7bff, 0x7bff, 0x7bff, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 37 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 38 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 39 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 40 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 41 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 42 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 43 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 44 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 45 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001, 0x8002, 0x8004, 0x8008, | ||
| 46 | 0x8010, 0x8020, 0x8040, 0x8080, 0x8100, 0x8200, 0x8400, 0x8800, 0x8c00, 0x9000, 0x9400, | ||
| 47 | 0x9800, 0x9c00, 0xa000, 0xa400, 0xa800, 0xac00, 0xb000, 0xb400, 0xb800, 0xbc00, 0xc000, | ||
| 48 | 0xc400, 0xc800, 0xcc00, 0xd000, 0xd400, 0xd800, 0xdc00, 0xe000, 0xe400, 0xe800, 0xec00, | ||
| 49 | 0xf000, 0xf400, 0xf800, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 50 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 51 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 52 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 53 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 54 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 55 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 56 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 57 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 58 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 59 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 60 | }; | ||
| 61 | static constexpr s8 shift[512]{ | ||
| 62 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 63 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 64 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 65 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 66 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 67 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 68 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, 0x16, | ||
| 69 | 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 70 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 71 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 72 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 73 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 74 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 75 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 76 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 77 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 78 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 79 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 80 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 81 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 82 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 83 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 84 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 85 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, | ||
| 86 | 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 87 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 88 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 89 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 90 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 91 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 92 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 93 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 94 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 95 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 96 | 0x18, 0x18, | ||
| 97 | }; | ||
| 98 | const u32 u = Common::BitCast<u32>(f); | ||
| 99 | const u32 i = u >> 23; | ||
| 100 | return base[i] + ((u & 0x7fffff) >> shift[i]); | ||
| 101 | } | ||
| 102 | |||
| 103 | u32 AU1_AH2_AF2(f32 a[2]) { | ||
| 104 | return AU1_AH1_AF1(a[0]) + (AU1_AH1_AF1(a[1]) << 16); | ||
| 105 | } | ||
| 106 | |||
| 107 | void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], f32 inputViewportInPixelsX, | ||
| 108 | f32 inputViewportInPixelsY, f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, | ||
| 109 | f32 outputSizeInPixelsX, f32 outputSizeInPixelsY) { | ||
| 110 | con0[0] = Common::BitCast<u32>(inputViewportInPixelsX / outputSizeInPixelsX); | ||
| 111 | con0[1] = Common::BitCast<u32>(inputViewportInPixelsY / outputSizeInPixelsY); | ||
| 112 | con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f); | ||
| 113 | con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f); | ||
| 114 | con1[0] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); | ||
| 115 | con1[1] = Common::BitCast<u32>(1.0f / inputSizeInPixelsY); | ||
| 116 | con1[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); | ||
| 117 | con1[3] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsY); | ||
| 118 | con2[0] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsX); | ||
| 119 | con2[1] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY); | ||
| 120 | con2[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); | ||
| 121 | con2[3] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY); | ||
| 122 | con3[0] = Common::BitCast<u32>(0.0f / inputSizeInPixelsX); | ||
| 123 | con3[1] = Common::BitCast<u32>(4.0f / inputSizeInPixelsY); | ||
| 124 | con3[2] = con3[3] = 0; | ||
| 125 | } | ||
| 126 | } // Anonymous namespace | ||
| 127 | |||
| 128 | void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], | ||
| 129 | f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, | ||
| 130 | f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX, | ||
| 131 | f32 outputSizeInPixelsY, f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) { | ||
| 132 | FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, | ||
| 133 | inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); | ||
| 134 | con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f + | ||
| 135 | inputOffsetInPixelsX); | ||
| 136 | con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f + | ||
| 137 | inputOffsetInPixelsY); | ||
| 138 | } | ||
| 139 | |||
| 140 | void FsrRcasCon(u32* con, f32 sharpness) { | ||
| 141 | sharpness = std::exp2f(-sharpness); | ||
| 142 | f32 hSharp[2]{sharpness, sharpness}; | ||
| 143 | con[0] = Common::BitCast<u32>(sharpness); | ||
| 144 | con[1] = AU1_AH2_AF2(hSharp); | ||
| 145 | con[2] = 0; | ||
| 146 | con[3] = 0; | ||
| 147 | } | ||
| 148 | } // namespace FSR | ||
diff --git a/src/video_core/fsr.h b/src/video_core/fsr.h new file mode 100644 index 000000000..db0d4ec6f --- /dev/null +++ b/src/video_core/fsr.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/bit_cast.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace FSR { | ||
| 10 | // Reimplementations of the constant generating functions in ffx_fsr1.h | ||
| 11 | // GCC generated a lot of warnings when using the official header. | ||
| 12 | void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], | ||
| 13 | f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, | ||
| 14 | f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX, | ||
| 15 | f32 outputSizeInPixelsY, f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY); | ||
| 16 | |||
| 17 | void FsrRcasCon(u32* con, f32 sharpness); | ||
| 18 | |||
| 19 | } // namespace FSR | ||
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index e968ae220..dad7b07d4 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt | |||
| @@ -3,12 +3,16 @@ | |||
| 3 | 3 | ||
| 4 | set(FIDELITYFX_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/externals/FidelityFX-FSR/ffx-fsr) | 4 | set(FIDELITYFX_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/externals/FidelityFX-FSR/ffx-fsr) |
| 5 | 5 | ||
| 6 | set(GLSL_INCLUDES | 6 | set(FIDELITYFX_FILES |
| 7 | fidelityfx_fsr.comp | ||
| 8 | ${FIDELITYFX_INCLUDE_DIR}/ffx_a.h | 7 | ${FIDELITYFX_INCLUDE_DIR}/ffx_a.h |
| 9 | ${FIDELITYFX_INCLUDE_DIR}/ffx_fsr1.h | 8 | ${FIDELITYFX_INCLUDE_DIR}/ffx_fsr1.h |
| 10 | ) | 9 | ) |
| 11 | 10 | ||
| 11 | set(GLSL_INCLUDES | ||
| 12 | fidelityfx_fsr.comp | ||
| 13 | ${FIDELITYFX_FILES} | ||
| 14 | ) | ||
| 15 | |||
| 12 | set(SHADER_FILES | 16 | set(SHADER_FILES |
| 13 | astc_decoder.comp | 17 | astc_decoder.comp |
| 14 | blit_color_float.frag | 18 | blit_color_float.frag |
| @@ -24,6 +28,9 @@ set(SHADER_FILES | |||
| 24 | fxaa.vert | 28 | fxaa.vert |
| 25 | opengl_convert_s8d24.comp | 29 | opengl_convert_s8d24.comp |
| 26 | opengl_copy_bc4.comp | 30 | opengl_copy_bc4.comp |
| 31 | opengl_fidelityfx_fsr.frag | ||
| 32 | opengl_fidelityfx_fsr_easu.frag | ||
| 33 | opengl_fidelityfx_fsr_rcas.frag | ||
| 27 | opengl_present.frag | 34 | opengl_present.frag |
| 28 | opengl_present.vert | 35 | opengl_present.vert |
| 29 | opengl_present_scaleforce.frag | 36 | opengl_present_scaleforce.frag |
| @@ -118,6 +125,25 @@ foreach(FILENAME IN ITEMS ${SHADER_FILES}) | |||
| 118 | endif() | 125 | endif() |
| 119 | endforeach() | 126 | endforeach() |
| 120 | 127 | ||
| 128 | foreach(FILEPATH IN ITEMS ${FIDELITYFX_FILES}) | ||
| 129 | get_filename_component(FILENAME ${FILEPATH} NAME) | ||
| 130 | string(REPLACE "." "_" HEADER_NAME ${FILENAME}) | ||
| 131 | set(SOURCE_FILE ${FILEPATH}) | ||
| 132 | set(SOURCE_HEADER_FILE ${SHADER_DIR}/${HEADER_NAME}.h) | ||
| 133 | add_custom_command( | ||
| 134 | OUTPUT | ||
| 135 | ${SOURCE_HEADER_FILE} | ||
| 136 | COMMAND | ||
| 137 | ${CMAKE_COMMAND} -P ${HEADER_GENERATOR} ${SOURCE_FILE} ${SOURCE_HEADER_FILE} ${INPUT_FILE} | ||
| 138 | MAIN_DEPENDENCY | ||
| 139 | ${SOURCE_FILE} | ||
| 140 | DEPENDS | ||
| 141 | ${INPUT_FILE} | ||
| 142 | # HEADER_GENERATOR should be included here but msbuild seems to assume it's always modified | ||
| 143 | ) | ||
| 144 | set(SHADER_HEADERS ${SHADER_HEADERS} ${SOURCE_HEADER_FILE}) | ||
| 145 | endforeach() | ||
| 146 | |||
| 121 | set(SHADER_SOURCES ${SHADER_FILES}) | 147 | set(SHADER_SOURCES ${SHADER_FILES}) |
| 122 | list(APPEND SHADER_SOURCES ${GLSL_INCLUDES}) | 148 | list(APPEND SHADER_SOURCES ${GLSL_INCLUDES}) |
| 123 | 149 | ||
diff --git a/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag b/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag new file mode 100644 index 000000000..16d22f58e --- /dev/null +++ b/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | //!#version 460 core | ||
| 5 | #extension GL_ARB_separate_shader_objects : enable | ||
| 6 | #extension GL_ARB_shading_language_420pack : enable | ||
| 7 | |||
| 8 | #extension GL_AMD_gpu_shader_half_float : enable | ||
| 9 | #extension GL_NV_gpu_shader5 : enable | ||
| 10 | |||
| 11 | // FidelityFX Super Resolution Sample | ||
| 12 | // | ||
| 13 | // Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. | ||
| 14 | // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 15 | // of this software and associated documentation files(the "Software"), to deal | ||
| 16 | // in the Software without restriction, including without limitation the rights | ||
| 17 | // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
| 18 | // copies of the Software, and to permit persons to whom the Software is | ||
| 19 | // furnished to do so, subject to the following conditions : | ||
| 20 | // The above copyright notice and this permission notice shall be included in | ||
| 21 | // all copies or substantial portions of the Software. | ||
| 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE | ||
| 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 28 | // THE SOFTWARE. | ||
| 29 | |||
| 30 | layout (location = 0) uniform uvec4 constants[4]; | ||
| 31 | |||
| 32 | #define A_GPU 1 | ||
| 33 | #define A_GLSL 1 | ||
| 34 | |||
| 35 | #ifdef YUZU_USE_FP16 | ||
| 36 | #define A_HALF | ||
| 37 | #endif | ||
| 38 | #include "ffx_a.h" | ||
| 39 | |||
| 40 | #ifndef YUZU_USE_FP16 | ||
| 41 | layout (binding=0) uniform sampler2D InputTexture; | ||
| 42 | #if USE_EASU | ||
| 43 | #define FSR_EASU_F 1 | ||
| 44 | AF4 FsrEasuRF(AF2 p) { AF4 res = textureGather(InputTexture, p, 0); return res; } | ||
| 45 | AF4 FsrEasuGF(AF2 p) { AF4 res = textureGather(InputTexture, p, 1); return res; } | ||
| 46 | AF4 FsrEasuBF(AF2 p) { AF4 res = textureGather(InputTexture, p, 2); return res; } | ||
| 47 | #endif | ||
| 48 | #if USE_RCAS | ||
| 49 | #define FSR_RCAS_F | ||
| 50 | AF4 FsrRcasLoadF(ASU2 p) { return texelFetch(InputTexture, ASU2(p), 0); } | ||
| 51 | void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {} | ||
| 52 | #endif | ||
| 53 | #else | ||
| 54 | layout (binding=0) uniform sampler2D InputTexture; | ||
| 55 | #if USE_EASU | ||
| 56 | #define FSR_EASU_H 1 | ||
| 57 | AH4 FsrEasuRH(AF2 p) { AH4 res = AH4(textureGather(InputTexture, p, 0)); return res; } | ||
| 58 | AH4 FsrEasuGH(AF2 p) { AH4 res = AH4(textureGather(InputTexture, p, 1)); return res; } | ||
| 59 | AH4 FsrEasuBH(AF2 p) { AH4 res = AH4(textureGather(InputTexture, p, 2)); return res; } | ||
| 60 | #endif | ||
| 61 | #if USE_RCAS | ||
| 62 | #define FSR_RCAS_H | ||
| 63 | AH4 FsrRcasLoadH(ASW2 p) { return AH4(texelFetch(InputTexture, ASU2(p), 0)); } | ||
| 64 | void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b){} | ||
| 65 | #endif | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #include "ffx_fsr1.h" | ||
| 69 | |||
| 70 | #if USE_RCAS | ||
| 71 | layout(location = 0) in vec2 frag_texcoord; | ||
| 72 | #endif | ||
| 73 | layout (location = 0) out vec4 frag_color; | ||
| 74 | |||
| 75 | void CurrFilter(AU2 pos) | ||
| 76 | { | ||
| 77 | #if USE_EASU | ||
| 78 | #ifndef YUZU_USE_FP16 | ||
| 79 | AF3 c; | ||
| 80 | FsrEasuF(c, pos, constants[0], constants[1], constants[2], constants[3]); | ||
| 81 | frag_color = AF4(c, 1.0); | ||
| 82 | #else | ||
| 83 | AH3 c; | ||
| 84 | FsrEasuH(c, pos, constants[0], constants[1], constants[2], constants[3]); | ||
| 85 | frag_color = AH4(c, 1.0); | ||
| 86 | #endif | ||
| 87 | #endif | ||
| 88 | #if USE_RCAS | ||
| 89 | #ifndef YUZU_USE_FP16 | ||
| 90 | AF3 c; | ||
| 91 | FsrRcasF(c.r, c.g, c.b, pos, constants[0]); | ||
| 92 | frag_color = AF4(c, 1.0); | ||
| 93 | #else | ||
| 94 | AH3 c; | ||
| 95 | FsrRcasH(c.r, c.g, c.b, pos, constants[0]); | ||
| 96 | frag_color = AH4(c, 1.0); | ||
| 97 | #endif | ||
| 98 | #endif | ||
| 99 | } | ||
| 100 | |||
| 101 | void main() | ||
| 102 | { | ||
| 103 | #if USE_RCAS | ||
| 104 | CurrFilter(AU2(frag_texcoord * vec2(textureSize(InputTexture, 0)))); | ||
| 105 | #else | ||
| 106 | CurrFilter(AU2(gl_FragCoord.xy)); | ||
| 107 | #endif | ||
| 108 | } | ||
diff --git a/src/video_core/host_shaders/opengl_fidelityfx_fsr_easu.frag b/src/video_core/host_shaders/opengl_fidelityfx_fsr_easu.frag new file mode 100644 index 000000000..d39f80ac1 --- /dev/null +++ b/src/video_core/host_shaders/opengl_fidelityfx_fsr_easu.frag | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #version 460 core | ||
| 5 | #extension GL_GOOGLE_include_directive : enable | ||
| 6 | |||
| 7 | #define USE_EASU 1 | ||
| 8 | |||
| 9 | #include "opengl_fidelityfx_fsr.frag" | ||
diff --git a/src/video_core/host_shaders/opengl_fidelityfx_fsr_rcas.frag b/src/video_core/host_shaders/opengl_fidelityfx_fsr_rcas.frag new file mode 100644 index 000000000..cfa78ddc7 --- /dev/null +++ b/src/video_core/host_shaders/opengl_fidelityfx_fsr_rcas.frag | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #version 460 core | ||
| 5 | #extension GL_GOOGLE_include_directive : enable | ||
| 6 | |||
| 7 | #define USE_RCAS 1 | ||
| 8 | |||
| 9 | #include "opengl_fidelityfx_fsr.frag" | ||
diff --git a/src/video_core/renderer_opengl/gl_fsr.cpp b/src/video_core/renderer_opengl/gl_fsr.cpp new file mode 100644 index 000000000..77262dcf1 --- /dev/null +++ b/src/video_core/renderer_opengl/gl_fsr.cpp | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/settings.h" | ||
| 5 | #include "video_core/fsr.h" | ||
| 6 | #include "video_core/renderer_opengl/gl_fsr.h" | ||
| 7 | #include "video_core/renderer_opengl/gl_shader_manager.h" | ||
| 8 | #include "video_core/renderer_opengl/gl_shader_util.h" | ||
| 9 | |||
| 10 | namespace OpenGL { | ||
| 11 | using namespace FSR; | ||
| 12 | |||
| 13 | using FsrConstants = std::array<u32, 4 * 4>; | ||
| 14 | |||
| 15 | FSR::FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source, | ||
| 16 | std::string_view fsr_rcas_source) | ||
| 17 | : fsr_vertex{CreateProgram(fsr_vertex_source, GL_VERTEX_SHADER)}, | ||
| 18 | fsr_easu_frag{CreateProgram(fsr_easu_source, GL_FRAGMENT_SHADER)}, | ||
| 19 | fsr_rcas_frag{CreateProgram(fsr_rcas_source, GL_FRAGMENT_SHADER)} { | ||
| 20 | glProgramUniform2f(fsr_vertex.handle, 0, 1.0f, 1.0f); | ||
| 21 | glProgramUniform2f(fsr_vertex.handle, 1, 0.0f, 0.0f); | ||
| 22 | } | ||
| 23 | |||
| 24 | FSR::~FSR() = default; | ||
| 25 | |||
| 26 | void FSR::Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen, | ||
| 27 | u32 input_image_width, u32 input_image_height, | ||
| 28 | const Common::Rectangle<int>& crop_rect) { | ||
| 29 | |||
| 30 | const auto output_image_width = screen.GetWidth(); | ||
| 31 | const auto output_image_height = screen.GetHeight(); | ||
| 32 | |||
| 33 | if (fsr_intermediate_tex.handle) { | ||
| 34 | GLint fsr_tex_width, fsr_tex_height; | ||
| 35 | glGetTextureLevelParameteriv(fsr_intermediate_tex.handle, 0, GL_TEXTURE_WIDTH, | ||
| 36 | &fsr_tex_width); | ||
| 37 | glGetTextureLevelParameteriv(fsr_intermediate_tex.handle, 0, GL_TEXTURE_HEIGHT, | ||
| 38 | &fsr_tex_height); | ||
| 39 | if (static_cast<u32>(fsr_tex_width) != output_image_width || | ||
| 40 | static_cast<u32>(fsr_tex_height) != output_image_height) { | ||
| 41 | fsr_intermediate_tex.Release(); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | if (!fsr_intermediate_tex.handle) { | ||
| 45 | fsr_intermediate_tex.Create(GL_TEXTURE_2D); | ||
| 46 | glTextureStorage2D(fsr_intermediate_tex.handle, 1, GL_RGB16F, output_image_width, | ||
| 47 | output_image_height); | ||
| 48 | glNamedFramebufferTexture(fsr_framebuffer.handle, GL_COLOR_ATTACHMENT0, | ||
| 49 | fsr_intermediate_tex.handle, 0); | ||
| 50 | } | ||
| 51 | |||
| 52 | GLint old_draw_fb; | ||
| 53 | glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &old_draw_fb); | ||
| 54 | |||
| 55 | glFrontFace(GL_CW); | ||
| 56 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fsr_framebuffer.handle); | ||
| 57 | glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(output_image_width), | ||
| 58 | static_cast<GLfloat>(output_image_height)); | ||
| 59 | |||
| 60 | FsrConstants constants; | ||
| 61 | FsrEasuConOffset( | ||
| 62 | constants.data() + 0, constants.data() + 4, constants.data() + 8, constants.data() + 12, | ||
| 63 | |||
| 64 | static_cast<f32>(crop_rect.GetWidth()), static_cast<f32>(crop_rect.GetHeight()), | ||
| 65 | static_cast<f32>(input_image_width), static_cast<f32>(input_image_height), | ||
| 66 | static_cast<f32>(output_image_width), static_cast<f32>(output_image_height), | ||
| 67 | static_cast<f32>(crop_rect.left), static_cast<f32>(crop_rect.top)); | ||
| 68 | |||
| 69 | glProgramUniform4uiv(fsr_easu_frag.handle, 0, sizeof(constants), std::data(constants)); | ||
| 70 | |||
| 71 | program_manager.BindPresentPrograms(fsr_vertex.handle, fsr_easu_frag.handle); | ||
| 72 | glDrawArrays(GL_TRIANGLES, 0, 3); | ||
| 73 | |||
| 74 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, old_draw_fb); | ||
| 75 | glBindTextureUnit(0, fsr_intermediate_tex.handle); | ||
| 76 | |||
| 77 | const float sharpening = | ||
| 78 | static_cast<float>(Settings::values.fsr_sharpening_slider.GetValue()) / 100.0f; | ||
| 79 | |||
| 80 | FsrRcasCon(constants.data(), sharpening); | ||
| 81 | glProgramUniform4uiv(fsr_rcas_frag.handle, 0, sizeof(constants), std::data(constants)); | ||
| 82 | } | ||
| 83 | |||
| 84 | void FSR::InitBuffers() { | ||
| 85 | fsr_framebuffer.Create(); | ||
| 86 | } | ||
| 87 | |||
| 88 | void FSR::ReleaseBuffers() { | ||
| 89 | fsr_framebuffer.Release(); | ||
| 90 | fsr_intermediate_tex.Release(); | ||
| 91 | } | ||
| 92 | |||
| 93 | const OGLProgram& FSR::GetPresentFragmentProgram() const noexcept { | ||
| 94 | return fsr_rcas_frag; | ||
| 95 | } | ||
| 96 | |||
| 97 | bool FSR::AreBuffersInitialized() const noexcept { | ||
| 98 | return fsr_framebuffer.handle; | ||
| 99 | } | ||
| 100 | |||
| 101 | } // namespace OpenGL | ||
diff --git a/src/video_core/renderer_opengl/gl_fsr.h b/src/video_core/renderer_opengl/gl_fsr.h new file mode 100644 index 000000000..1f6ae3115 --- /dev/null +++ b/src/video_core/renderer_opengl/gl_fsr.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <string_view> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "common/math_util.h" | ||
| 10 | #include "video_core/fsr.h" | ||
| 11 | #include "video_core/renderer_opengl/gl_resource_manager.h" | ||
| 12 | |||
| 13 | namespace OpenGL { | ||
| 14 | |||
| 15 | class ProgramManager; | ||
| 16 | |||
| 17 | class FSR { | ||
| 18 | public: | ||
| 19 | explicit FSR(std::string_view fsr_vertex_source, std::string_view fsr_easu_source, | ||
| 20 | std::string_view fsr_rcas_source); | ||
| 21 | ~FSR(); | ||
| 22 | |||
| 23 | void Draw(ProgramManager& program_manager, const Common::Rectangle<u32>& screen, | ||
| 24 | u32 input_image_width, u32 input_image_height, | ||
| 25 | const Common::Rectangle<int>& crop_rect); | ||
| 26 | |||
| 27 | void InitBuffers(); | ||
| 28 | |||
| 29 | void ReleaseBuffers(); | ||
| 30 | |||
| 31 | [[nodiscard]] const OGLProgram& GetPresentFragmentProgram() const noexcept; | ||
| 32 | |||
| 33 | [[nodiscard]] bool AreBuffersInitialized() const noexcept; | ||
| 34 | |||
| 35 | private: | ||
| 36 | OGLFramebuffer fsr_framebuffer; | ||
| 37 | OGLProgram fsr_vertex; | ||
| 38 | OGLProgram fsr_easu_frag; | ||
| 39 | OGLProgram fsr_rcas_frag; | ||
| 40 | OGLTexture fsr_intermediate_tex; | ||
| 41 | }; | ||
| 42 | |||
| 43 | } // namespace OpenGL | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index de95f2634..2a74c1d05 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -17,8 +17,14 @@ | |||
| 17 | #include "core/frontend/emu_window.h" | 17 | #include "core/frontend/emu_window.h" |
| 18 | #include "core/memory.h" | 18 | #include "core/memory.h" |
| 19 | #include "core/telemetry_session.h" | 19 | #include "core/telemetry_session.h" |
| 20 | #include "video_core/host_shaders/ffx_a_h.h" | ||
| 21 | #include "video_core/host_shaders/ffx_fsr1_h.h" | ||
| 22 | #include "video_core/host_shaders/full_screen_triangle_vert.h" | ||
| 20 | #include "video_core/host_shaders/fxaa_frag.h" | 23 | #include "video_core/host_shaders/fxaa_frag.h" |
| 21 | #include "video_core/host_shaders/fxaa_vert.h" | 24 | #include "video_core/host_shaders/fxaa_vert.h" |
| 25 | #include "video_core/host_shaders/opengl_fidelityfx_fsr_easu_frag.h" | ||
| 26 | #include "video_core/host_shaders/opengl_fidelityfx_fsr_frag.h" | ||
| 27 | #include "video_core/host_shaders/opengl_fidelityfx_fsr_rcas_frag.h" | ||
| 22 | #include "video_core/host_shaders/opengl_present_frag.h" | 28 | #include "video_core/host_shaders/opengl_present_frag.h" |
| 23 | #include "video_core/host_shaders/opengl_present_scaleforce_frag.h" | 29 | #include "video_core/host_shaders/opengl_present_scaleforce_frag.h" |
| 24 | #include "video_core/host_shaders/opengl_present_vert.h" | 30 | #include "video_core/host_shaders/opengl_present_vert.h" |
| @@ -31,6 +37,7 @@ | |||
| 31 | #include "video_core/host_shaders/smaa_edge_detection_vert.h" | 37 | #include "video_core/host_shaders/smaa_edge_detection_vert.h" |
| 32 | #include "video_core/host_shaders/smaa_neighborhood_blending_frag.h" | 38 | #include "video_core/host_shaders/smaa_neighborhood_blending_frag.h" |
| 33 | #include "video_core/host_shaders/smaa_neighborhood_blending_vert.h" | 39 | #include "video_core/host_shaders/smaa_neighborhood_blending_vert.h" |
| 40 | #include "video_core/renderer_opengl/gl_fsr.h" | ||
| 34 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 41 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 35 | #include "video_core/renderer_opengl/gl_shader_manager.h" | 42 | #include "video_core/renderer_opengl/gl_shader_manager.h" |
| 36 | #include "video_core/renderer_opengl/gl_shader_util.h" | 43 | #include "video_core/renderer_opengl/gl_shader_util.h" |
| @@ -268,12 +275,17 @@ void RendererOpenGL::InitOpenGLObjects() { | |||
| 268 | fxaa_vertex = CreateProgram(HostShaders::FXAA_VERT, GL_VERTEX_SHADER); | 275 | fxaa_vertex = CreateProgram(HostShaders::FXAA_VERT, GL_VERTEX_SHADER); |
| 269 | fxaa_fragment = CreateProgram(HostShaders::FXAA_FRAG, GL_FRAGMENT_SHADER); | 276 | fxaa_fragment = CreateProgram(HostShaders::FXAA_FRAG, GL_FRAGMENT_SHADER); |
| 270 | 277 | ||
| 271 | const auto SmaaShader = [](std::string_view specialized_source, GLenum stage) { | 278 | const auto replace_include = [](std::string& shader_source, std::string_view include_name, |
| 272 | std::string shader_source{specialized_source}; | 279 | std::string_view include_content) { |
| 273 | constexpr std::string_view include_string = "#include \"opengl_smaa.glsl\""; | 280 | const std::string include_string = fmt::format("#include \"{}\"", include_name); |
| 274 | const std::size_t pos = shader_source.find(include_string); | 281 | const std::size_t pos = shader_source.find(include_string); |
| 275 | ASSERT(pos != std::string::npos); | 282 | ASSERT(pos != std::string::npos); |
| 276 | shader_source.replace(pos, include_string.size(), HostShaders::OPENGL_SMAA_GLSL); | 283 | shader_source.replace(pos, include_string.size(), include_content); |
| 284 | }; | ||
| 285 | |||
| 286 | const auto SmaaShader = [&](std::string_view specialized_source, GLenum stage) { | ||
| 287 | std::string shader_source{specialized_source}; | ||
| 288 | replace_include(shader_source, "opengl_smaa.glsl", HostShaders::OPENGL_SMAA_GLSL); | ||
| 277 | return CreateProgram(shader_source, stage); | 289 | return CreateProgram(shader_source, stage); |
| 278 | }; | 290 | }; |
| 279 | 291 | ||
| @@ -298,14 +310,32 @@ void RendererOpenGL::InitOpenGLObjects() { | |||
| 298 | CreateProgram(fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG), | 310 | CreateProgram(fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG), |
| 299 | GL_FRAGMENT_SHADER); | 311 | GL_FRAGMENT_SHADER); |
| 300 | 312 | ||
| 313 | std::string fsr_source{HostShaders::OPENGL_FIDELITYFX_FSR_FRAG}; | ||
| 314 | replace_include(fsr_source, "ffx_a.h", HostShaders::FFX_A_H); | ||
| 315 | replace_include(fsr_source, "ffx_fsr1.h", HostShaders::FFX_FSR1_H); | ||
| 316 | |||
| 317 | std::string fsr_easu_frag_source{HostShaders::OPENGL_FIDELITYFX_FSR_EASU_FRAG}; | ||
| 318 | std::string fsr_rcas_frag_source{HostShaders::OPENGL_FIDELITYFX_FSR_RCAS_FRAG}; | ||
| 319 | replace_include(fsr_easu_frag_source, "opengl_fidelityfx_fsr.frag", fsr_source); | ||
| 320 | replace_include(fsr_rcas_frag_source, "opengl_fidelityfx_fsr.frag", fsr_source); | ||
| 321 | |||
| 322 | fsr = std::make_unique<FSR>(HostShaders::FULL_SCREEN_TRIANGLE_VERT, fsr_easu_frag_source, | ||
| 323 | fsr_rcas_frag_source); | ||
| 324 | |||
| 301 | // Generate presentation sampler | 325 | // Generate presentation sampler |
| 302 | present_sampler.Create(); | 326 | present_sampler.Create(); |
| 303 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 327 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 304 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 328 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 329 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | ||
| 330 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||
| 331 | glSamplerParameteri(present_sampler.handle, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); | ||
| 305 | 332 | ||
| 306 | present_sampler_nn.Create(); | 333 | present_sampler_nn.Create(); |
| 307 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 334 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 308 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 335 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 336 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | ||
| 337 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||
| 338 | glSamplerParameteri(present_sampler_nn.handle, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); | ||
| 309 | 339 | ||
| 310 | // Generate VBO handle for drawing | 340 | // Generate VBO handle for drawing |
| 311 | vertex_buffer.Create(); | 341 | vertex_buffer.Create(); |
| @@ -525,6 +555,31 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 525 | 555 | ||
| 526 | glBindTextureUnit(0, aa_texture.handle); | 556 | glBindTextureUnit(0, aa_texture.handle); |
| 527 | } | 557 | } |
| 558 | glDisablei(GL_SCISSOR_TEST, 0); | ||
| 559 | |||
| 560 | if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { | ||
| 561 | if (!fsr->AreBuffersInitialized()) { | ||
| 562 | fsr->InitBuffers(); | ||
| 563 | } | ||
| 564 | |||
| 565 | auto crop_rect = framebuffer_crop_rect; | ||
| 566 | if (crop_rect.GetWidth() == 0) { | ||
| 567 | crop_rect.right = framebuffer_width; | ||
| 568 | } | ||
| 569 | if (crop_rect.GetHeight() == 0) { | ||
| 570 | crop_rect.bottom = framebuffer_height; | ||
| 571 | } | ||
| 572 | crop_rect = crop_rect.Scale(Settings::values.resolution_info.up_factor); | ||
| 573 | const auto fsr_input_width = Settings::values.resolution_info.ScaleUp(framebuffer_width); | ||
| 574 | const auto fsr_input_height = Settings::values.resolution_info.ScaleUp(framebuffer_height); | ||
| 575 | glBindSampler(0, present_sampler.handle); | ||
| 576 | fsr->Draw(program_manager, layout.screen, fsr_input_width, fsr_input_height, crop_rect); | ||
| 577 | } else { | ||
| 578 | if (fsr->AreBuffersInitialized()) { | ||
| 579 | fsr->ReleaseBuffers(); | ||
| 580 | } | ||
| 581 | } | ||
| 582 | |||
| 528 | const std::array ortho_matrix = | 583 | const std::array ortho_matrix = |
| 529 | MakeOrthographicMatrix(static_cast<float>(layout.width), static_cast<float>(layout.height)); | 584 | MakeOrthographicMatrix(static_cast<float>(layout.width), static_cast<float>(layout.height)); |
| 530 | 585 | ||
| @@ -540,10 +595,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 540 | case Settings::ScalingFilter::ScaleForce: | 595 | case Settings::ScalingFilter::ScaleForce: |
| 541 | return present_scaleforce_fragment.handle; | 596 | return present_scaleforce_fragment.handle; |
| 542 | case Settings::ScalingFilter::Fsr: | 597 | case Settings::ScalingFilter::Fsr: |
| 543 | LOG_WARNING( | 598 | return fsr->GetPresentFragmentProgram().handle; |
| 544 | Render_OpenGL, | ||
| 545 | "FidelityFX Super Resolution is not supported in OpenGL, changing to ScaleForce"); | ||
| 546 | return present_scaleforce_fragment.handle; | ||
| 547 | default: | 599 | default: |
| 548 | return present_bilinear_fragment.handle; | 600 | return present_bilinear_fragment.handle; |
| 549 | } | 601 | } |
| @@ -578,15 +630,18 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 578 | f32 scale_u = static_cast<f32>(framebuffer_width) / static_cast<f32>(screen_info.texture.width); | 630 | f32 scale_u = static_cast<f32>(framebuffer_width) / static_cast<f32>(screen_info.texture.width); |
| 579 | f32 scale_v = | 631 | f32 scale_v = |
| 580 | static_cast<f32>(framebuffer_height) / static_cast<f32>(screen_info.texture.height); | 632 | static_cast<f32>(framebuffer_height) / static_cast<f32>(screen_info.texture.height); |
| 581 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering | 633 | |
| 582 | // (e.g. handheld mode) on a 1920x1080 framebuffer. | 634 | if (Settings::values.scaling_filter.GetValue() != Settings::ScalingFilter::Fsr) { |
| 583 | if (framebuffer_crop_rect.GetWidth() > 0) { | 635 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering |
| 584 | scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / | 636 | // (e.g. handheld mode) on a 1920x1080 framebuffer. |
| 585 | static_cast<f32>(screen_info.texture.width); | 637 | if (framebuffer_crop_rect.GetWidth() > 0) { |
| 586 | } | 638 | scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / |
| 587 | if (framebuffer_crop_rect.GetHeight() > 0) { | 639 | static_cast<f32>(screen_info.texture.width); |
| 588 | scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) / | 640 | } |
| 589 | static_cast<f32>(screen_info.texture.height); | 641 | if (framebuffer_crop_rect.GetHeight() > 0) { |
| 642 | scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) / | ||
| 643 | static_cast<f32>(screen_info.texture.height); | ||
| 644 | } | ||
| 590 | } | 645 | } |
| 591 | if (Settings::values.anti_aliasing.GetValue() == Settings::AntiAliasing::Fxaa && | 646 | if (Settings::values.anti_aliasing.GetValue() == Settings::AntiAliasing::Fxaa && |
| 592 | !screen_info.was_accelerated) { | 647 | !screen_info.was_accelerated) { |
| @@ -612,7 +667,6 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 612 | } else { | 667 | } else { |
| 613 | glDisable(GL_FRAMEBUFFER_SRGB); | 668 | glDisable(GL_FRAMEBUFFER_SRGB); |
| 614 | } | 669 | } |
| 615 | glDisablei(GL_SCISSOR_TEST, 0); | ||
| 616 | glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(layout.width), | 670 | glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(layout.width), |
| 617 | static_cast<GLfloat>(layout.height)); | 671 | static_cast<GLfloat>(layout.height)); |
| 618 | 672 | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index cc97d7b26..f1d5fd954 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "video_core/renderer_base.h" | 11 | #include "video_core/renderer_base.h" |
| 12 | #include "video_core/renderer_opengl/gl_device.h" | 12 | #include "video_core/renderer_opengl/gl_device.h" |
| 13 | #include "video_core/renderer_opengl/gl_fsr.h" | ||
| 13 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 14 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 14 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 15 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 15 | #include "video_core/renderer_opengl/gl_shader_manager.h" | 16 | #include "video_core/renderer_opengl/gl_shader_manager.h" |
| @@ -141,6 +142,8 @@ private: | |||
| 141 | OGLTexture smaa_edges_tex; | 142 | OGLTexture smaa_edges_tex; |
| 142 | OGLTexture smaa_blend_tex; | 143 | OGLTexture smaa_blend_tex; |
| 143 | 144 | ||
| 145 | std::unique_ptr<FSR> fsr; | ||
| 146 | |||
| 144 | /// OpenGL framebuffer data | 147 | /// OpenGL framebuffer data |
| 145 | std::vector<u8> gl_framebuffer_data; | 148 | std::vector<u8> gl_framebuffer_data; |
| 146 | 149 | ||
diff --git a/src/video_core/renderer_vulkan/vk_fsr.cpp b/src/video_core/renderer_vulkan/vk_fsr.cpp index 33daa8c1c..df972cd54 100644 --- a/src/video_core/renderer_vulkan/vk_fsr.cpp +++ b/src/video_core/renderer_vulkan/vk_fsr.cpp | |||
| @@ -1,12 +1,11 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cmath> | ||
| 5 | #include "common/bit_cast.h" | ||
| 6 | #include "common/common_types.h" | 4 | #include "common/common_types.h" |
| 7 | #include "common/div_ceil.h" | 5 | #include "common/div_ceil.h" |
| 8 | #include "common/settings.h" | 6 | #include "common/settings.h" |
| 9 | 7 | ||
| 8 | #include "video_core/fsr.h" | ||
| 10 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h" | 9 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h" |
| 11 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h" | 10 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h" |
| 12 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h" | 11 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h" |
| @@ -17,146 +16,7 @@ | |||
| 17 | #include "video_core/vulkan_common/vulkan_device.h" | 16 | #include "video_core/vulkan_common/vulkan_device.h" |
| 18 | 17 | ||
| 19 | namespace Vulkan { | 18 | namespace Vulkan { |
| 20 | namespace { | 19 | using namespace FSR; |
| 21 | // Reimplementations of the constant generating functions in ffx_fsr1.h | ||
| 22 | // GCC generated a lot of warnings when using the official header. | ||
| 23 | u32 AU1_AH1_AF1(f32 f) { | ||
| 24 | static constexpr u32 base[512]{ | ||
| 25 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 26 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 27 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 28 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 29 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 30 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 31 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 32 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 33 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 34 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, | ||
| 35 | 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x0c00, 0x1000, 0x1400, 0x1800, 0x1c00, 0x2000, | ||
| 36 | 0x2400, 0x2800, 0x2c00, 0x3000, 0x3400, 0x3800, 0x3c00, 0x4000, 0x4400, 0x4800, 0x4c00, | ||
| 37 | 0x5000, 0x5400, 0x5800, 0x5c00, 0x6000, 0x6400, 0x6800, 0x6c00, 0x7000, 0x7400, 0x7800, | ||
| 38 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 39 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 40 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 41 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 42 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 43 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 44 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 45 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 46 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 47 | 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, | ||
| 48 | 0x7bff, 0x7bff, 0x7bff, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 49 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 50 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 51 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 52 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 53 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 54 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 55 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 56 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, | ||
| 57 | 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001, 0x8002, 0x8004, 0x8008, | ||
| 58 | 0x8010, 0x8020, 0x8040, 0x8080, 0x8100, 0x8200, 0x8400, 0x8800, 0x8c00, 0x9000, 0x9400, | ||
| 59 | 0x9800, 0x9c00, 0xa000, 0xa400, 0xa800, 0xac00, 0xb000, 0xb400, 0xb800, 0xbc00, 0xc000, | ||
| 60 | 0xc400, 0xc800, 0xcc00, 0xd000, 0xd400, 0xd800, 0xdc00, 0xe000, 0xe400, 0xe800, 0xec00, | ||
| 61 | 0xf000, 0xf400, 0xf800, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 62 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 63 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 64 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 65 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 66 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 67 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 68 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 69 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 70 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 71 | 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, | ||
| 72 | }; | ||
| 73 | static constexpr s8 shift[512]{ | ||
| 74 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 75 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 76 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 77 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 78 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 79 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 80 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, 0x16, | ||
| 81 | 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 82 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 83 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 84 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 85 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 86 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 87 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 88 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 89 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 90 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 91 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 92 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 93 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 94 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 95 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 96 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 97 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, | ||
| 98 | 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 99 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, | ||
| 100 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 101 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 102 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 103 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 104 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 105 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 106 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 107 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | ||
| 108 | 0x18, 0x18, | ||
| 109 | }; | ||
| 110 | const u32 u = Common::BitCast<u32>(f); | ||
| 111 | const u32 i = u >> 23; | ||
| 112 | return base[i] + ((u & 0x7fffff) >> shift[i]); | ||
| 113 | } | ||
| 114 | |||
| 115 | u32 AU1_AH2_AF2(f32 a[2]) { | ||
| 116 | return AU1_AH1_AF1(a[0]) + (AU1_AH1_AF1(a[1]) << 16); | ||
| 117 | } | ||
| 118 | |||
| 119 | void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], f32 inputViewportInPixelsX, | ||
| 120 | f32 inputViewportInPixelsY, f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, | ||
| 121 | f32 outputSizeInPixelsX, f32 outputSizeInPixelsY) { | ||
| 122 | con0[0] = Common::BitCast<u32>(inputViewportInPixelsX / outputSizeInPixelsX); | ||
| 123 | con0[1] = Common::BitCast<u32>(inputViewportInPixelsY / outputSizeInPixelsY); | ||
| 124 | con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f); | ||
| 125 | con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f); | ||
| 126 | con1[0] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); | ||
| 127 | con1[1] = Common::BitCast<u32>(1.0f / inputSizeInPixelsY); | ||
| 128 | con1[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); | ||
| 129 | con1[3] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsY); | ||
| 130 | con2[0] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsX); | ||
| 131 | con2[1] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY); | ||
| 132 | con2[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); | ||
| 133 | con2[3] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY); | ||
| 134 | con3[0] = Common::BitCast<u32>(0.0f / inputSizeInPixelsX); | ||
| 135 | con3[1] = Common::BitCast<u32>(4.0f / inputSizeInPixelsY); | ||
| 136 | con3[2] = con3[3] = 0; | ||
| 137 | } | ||
| 138 | |||
| 139 | void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], | ||
| 140 | f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, | ||
| 141 | f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX, | ||
| 142 | f32 outputSizeInPixelsY, f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) { | ||
| 143 | FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, | ||
| 144 | inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); | ||
| 145 | con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f + | ||
| 146 | inputOffsetInPixelsX); | ||
| 147 | con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f + | ||
| 148 | inputOffsetInPixelsY); | ||
| 149 | } | ||
| 150 | |||
| 151 | void FsrRcasCon(u32* con, f32 sharpness) { | ||
| 152 | sharpness = std::exp2f(-sharpness); | ||
| 153 | f32 hSharp[2]{sharpness, sharpness}; | ||
| 154 | con[0] = Common::BitCast<u32>(sharpness); | ||
| 155 | con[1] = AU1_AH2_AF2(hSharp); | ||
| 156 | con[2] = 0; | ||
| 157 | con[3] = 0; | ||
| 158 | } | ||
| 159 | } // Anonymous namespace | ||
| 160 | 20 | ||
| 161 | FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_, | 21 | FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_, |
| 162 | VkExtent2D output_size_) | 22 | VkExtent2D output_size_) |
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index bb9910a53..a45ec69ec 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui | |||
| @@ -460,7 +460,7 @@ | |||
| 460 | </item> | 460 | </item> |
| 461 | <item> | 461 | <item> |
| 462 | <property name="text"> | 462 | <property name="text"> |
| 463 | <string>AMD FidelityFX™️ Super Resolution (Vulkan Only)</string> | 463 | <string>AMD FidelityFX™️ Super Resolution</string> |
| 464 | </property> | 464 | </property> |
| 465 | </item> | 465 | </item> |
| 466 | </widget> | 466 | </widget> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 62aaf41bf..42b7b64c8 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -983,11 +983,6 @@ void GMainWindow::InitializeWidgets() { | |||
| 983 | filter_status_button->setFocusPolicy(Qt::NoFocus); | 983 | filter_status_button->setFocusPolicy(Qt::NoFocus); |
| 984 | connect(filter_status_button, &QPushButton::clicked, this, | 984 | connect(filter_status_button, &QPushButton::clicked, this, |
| 985 | &GMainWindow::OnToggleAdaptingFilter); | 985 | &GMainWindow::OnToggleAdaptingFilter); |
| 986 | auto filter = Settings::values.scaling_filter.GetValue(); | ||
| 987 | if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL && | ||
| 988 | filter == Settings::ScalingFilter::Fsr) { | ||
| 989 | Settings::values.scaling_filter.SetValue(Settings::ScalingFilter::NearestNeighbor); | ||
| 990 | } | ||
| 991 | UpdateFilterText(); | 986 | UpdateFilterText(); |
| 992 | filter_status_button->setCheckable(true); | 987 | filter_status_button->setCheckable(true); |
| 993 | filter_status_button->setChecked(true); | 988 | filter_status_button->setChecked(true); |
| @@ -3468,10 +3463,6 @@ void GMainWindow::OnToggleAdaptingFilter() { | |||
| 3468 | } else { | 3463 | } else { |
| 3469 | filter = static_cast<Settings::ScalingFilter>(static_cast<u32>(filter) + 1); | 3464 | filter = static_cast<Settings::ScalingFilter>(static_cast<u32>(filter) + 1); |
| 3470 | } | 3465 | } |
| 3471 | if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL && | ||
| 3472 | filter == Settings::ScalingFilter::Fsr) { | ||
| 3473 | filter = Settings::ScalingFilter::NearestNeighbor; | ||
| 3474 | } | ||
| 3475 | Settings::values.scaling_filter.SetValue(filter); | 3466 | Settings::values.scaling_filter.SetValue(filter); |
| 3476 | filter_status_button->setChecked(true); | 3467 | filter_status_button->setChecked(true); |
| 3477 | UpdateFilterText(); | 3468 | UpdateFilterText(); |