mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-26 23:31:14 +01:00
Compare commits
37 commits
ae3e86821d
...
d619b851f7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d619b851f7 | ||
|
|
0a5395b61c | ||
|
|
443c64d7cb | ||
|
|
be689d1579 | ||
|
|
cd02b9f375 | ||
|
|
d20b9a9acc | ||
|
|
ee534cb9fb | ||
|
|
ce09cfb0c6 | ||
|
|
e5aeb03d98 | ||
|
|
f8c972569d | ||
|
|
caa949e7e2 | ||
|
|
dabd8a65a2 | ||
|
|
54a45f736a | ||
|
|
48e718946e | ||
|
|
0a1133901a | ||
|
|
a6e5c38804 | ||
|
|
f514ecaa81 | ||
|
|
5460ca464a | ||
|
|
8451112a2f | ||
|
|
bfc72fd364 | ||
|
|
bc8bcb1310 | ||
|
|
0924d8918c | ||
|
|
3d9e5e50d9 | ||
|
|
9df6919f4d | ||
|
|
e94af3c0c8 | ||
|
|
4a1abeded0 | ||
|
|
1924110609 | ||
|
|
e5fe0caa3c | ||
|
|
c7c1c4fad1 | ||
|
|
ec5bc4ed67 | ||
|
|
af44f11139 | ||
|
|
5117039552 | ||
|
|
6e5b800d09 | ||
|
|
a5c6692e34 | ||
|
|
a6408a5292 | ||
|
|
6cc91a9bcc | ||
|
|
7087d889bb |
20 changed files with 523 additions and 12 deletions
|
|
@ -233,6 +233,7 @@ endif()
|
|||
|
||||
option(YUZU_USE_BUNDLED_OPENSSL "Download bundled OpenSSL build" ${DEFAULT_YUZU_USE_BUNDLED_OPENSSL})
|
||||
|
||||
# TODO(crueter): CPM this
|
||||
if (ANDROID AND YUZU_DOWNLOAD_ANDROID_VVL)
|
||||
AddJsonPackage(vulkan-validation-layers)
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ Various graphical filters exist - each of them aimed at a specific target/image
|
|||
- **MMPX**: Nearest-neighbour filter aimed at providing higher pixel-art quality.
|
||||
- **Pros**: Offers decent pixel-art upscaling.
|
||||
- **Cons**: Only works for pixel-art.
|
||||
- **SGSR**: Uses Snapdragon Studios Game Super Resolution to enhance image quality (similar to FSR, but for Adreno devices).
|
||||
- **Pros**: Optimized for Adreno devices.
|
||||
- **Cons**: Doesn't play nicely with non-Adreno devices.
|
||||
- **SGSR Edge**: Almost the same pipeline as SGSR, but with improved edge detection.
|
||||
|
||||
### Anisotropy values
|
||||
|
||||
|
|
|
|||
|
|
@ -240,6 +240,8 @@
|
|||
<item>@string/scaling_filter_bspline</item>
|
||||
<item>@string/scaling_filter_mitchell</item>
|
||||
<item>@string/scaling_filter_spline1</item>
|
||||
<item>@string/scaling_filter_sgsr</item>
|
||||
<item>@string/scaling_filter_sgsr_edge</item>
|
||||
</string-array>
|
||||
|
||||
<integer-array name="rendererScalingFilterValues">
|
||||
|
|
@ -256,6 +258,8 @@
|
|||
<item>10</item>
|
||||
<item>11</item>
|
||||
<item>12</item>
|
||||
<item>13</item>
|
||||
<item>14</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="rendererAntiAliasingNames">
|
||||
|
|
|
|||
|
|
@ -466,8 +466,8 @@
|
|||
<string name="renderer_resolution">Resolution (Handheld/Docked)</string>
|
||||
<string name="renderer_vsync">VSync mode</string>
|
||||
<string name="renderer_scaling_filter">Window adapting filter</string>
|
||||
<string name="fsr_sharpness">FSR sharpness</string>
|
||||
<string name="fsr_sharpness_description">Determines how sharpened the image will look while using FSR\'s dynamic contrast</string>
|
||||
<string name="fsr_sharpness">FSR/SGSR sharpness</string>
|
||||
<string name="fsr_sharpness_description">Determines how sharpened the image will look while using FSR or SGSR filters</string>
|
||||
<string name="renderer_anti_aliasing">Anti-aliasing method</string>
|
||||
<string name="renderer_optimize_spirv_output">Optimize SPIRV output</string>
|
||||
<string name="renderer_optimize_spirv_output_description">Optimizes compiled shaders to improve GPU efficiency, but may introduce longer loading times and initial slowdowns.</string>
|
||||
|
|
@ -1074,6 +1074,8 @@
|
|||
<string name="scaling_filter_bspline" translatable="false">B-Spline</string>
|
||||
<string name="scaling_filter_mitchell" translatable="false">Mitchell</string>
|
||||
<string name="scaling_filter_mmpx" translatable="false">MMPX</string>
|
||||
<string name="scaling_filter_sgsr" translatable="false">Snapdragon GSR</string>
|
||||
<string name="scaling_filter_sgsr_edge" translatable="false">Snapdragon GSR EdgeDir</string>
|
||||
|
||||
<!-- Anti-Aliasing -->
|
||||
<string name="anti_aliasing_none">None</string>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ ENUM(ConfirmStop, Ask_Always, Ask_Based_On_Game, Ask_Never);
|
|||
ENUM(FullscreenMode, Borderless, Exclusive);
|
||||
ENUM(NvdecEmulation, Off, Cpu, Gpu);
|
||||
ENUM(ResolutionSetup, Res1_4X, Res1_2X, Res3_4X, Res1X, Res5_4X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, Res7X, Res8X);
|
||||
ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, Lanczos, ScaleForce, Fsr, Area, ZeroTangent, BSpline, Mitchell, Spline1, Mmpx, MaxEnum);
|
||||
ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, Lanczos, ScaleForce, Fsr, Area, ZeroTangent, BSpline, Mitchell, Spline1, Mmpx, Sgsr, SgsrEdge, MaxEnum);
|
||||
ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum);
|
||||
ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch);
|
||||
ENUM(ConsoleMode, Handheld, Docked);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent) {
|
|||
"Options lower than 1X can cause artifacts."));
|
||||
INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QString());
|
||||
INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"),
|
||||
tr("Determines how sharpened the image will look using FSR's dynamic contrast."));
|
||||
tr("Determines how sharpened the image will look using FSR's or SGSR's dynamic contrast."));
|
||||
INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"),
|
||||
tr("The anti-aliasing method to use.\nSMAA offers the best quality.\nFXAA "
|
||||
"can produce a more stable picture in lower resolutions."));
|
||||
|
|
@ -493,6 +493,8 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QObject* parent) {
|
|||
PAIR(ScalingFilter, BSpline, tr("B-Spline")),
|
||||
PAIR(ScalingFilter, Mitchell, tr("Mitchell")),
|
||||
PAIR(ScalingFilter, Spline1, tr("Spline-1")),
|
||||
PAIR(ScalingFilter, Sgsr, tr("Snapdragon Game Super Resolution")),
|
||||
PAIR(ScalingFilter, SgsrEdge, tr("Snapdragon Game Super Resolution EdgeDir")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::AntiAliasing>::Index(),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ static const std::map<Settings::ScalingFilter, QString> scaling_filter_texts_map
|
|||
{Settings::ScalingFilter::Fsr, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "FSR"))},
|
||||
{Settings::ScalingFilter::Area, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Area"))},
|
||||
{Settings::ScalingFilter::Mmpx, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "MMPX"))},
|
||||
{Settings::ScalingFilter::Sgsr, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "SGSR"))},
|
||||
{Settings::ScalingFilter::SgsrEdge, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "SGSR EdgeDir"))},
|
||||
};
|
||||
|
||||
static const std::map<Settings::ConsoleMode, QString> use_docked_mode_texts_map = {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ add_library(video_core STATIC
|
|||
renderer_vulkan/present/present_push_constants.h
|
||||
renderer_vulkan/present/smaa.cpp
|
||||
renderer_vulkan/present/smaa.h
|
||||
renderer_vulkan/present/sgsr.cpp
|
||||
renderer_vulkan/present/sgsr.h
|
||||
renderer_vulkan/present/util.cpp
|
||||
renderer_vulkan/present/util.h
|
||||
renderer_vulkan/present/window_adapt_pass.cpp
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ set(SHADER_FILES
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/vulkan_quad_indexed.comp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vulkan_turbo_mode.comp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vulkan_uint8.comp
|
||||
|
||||
# Snapdragon Game Super Resolution
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sgsr1_shader.vert
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sgsr1_shader_mobile.frag
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sgsr1_shader_mobile_edge_direction.frag
|
||||
)
|
||||
|
||||
if (PLATFORM_HAIKU)
|
||||
|
|
@ -90,7 +95,7 @@ if ("${GLSLANGVALIDATOR}" STREQUAL "GLSLANGVALIDATOR-NOTFOUND")
|
|||
message(FATAL_ERROR "Required program `glslangValidator` not found.")
|
||||
endif()
|
||||
|
||||
set(GLSL_FLAGS "")
|
||||
set(GLSL_FLAGS "-DUseUniformBlock=1")
|
||||
set(SPIR_V_VERSION "spirv1.3")
|
||||
set(QUIET_FLAG "--quiet")
|
||||
|
||||
|
|
|
|||
18
src/video_core/host_shaders/sgsr1_shader.vert
Normal file
18
src/video_core/host_shaders/sgsr1_shader.vert
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#version 450
|
||||
|
||||
layout( push_constant ) uniform constants {
|
||||
highp vec4 ViewportInfo[1];
|
||||
highp vec2 ResizeFactor;
|
||||
highp float EdgeSharpness;
|
||||
};
|
||||
layout(location = 0) out highp vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
float x = float((gl_VertexIndex & 1) << 2);
|
||||
float y = float((gl_VertexIndex & 2) << 1);
|
||||
gl_Position = vec4(x - 1.0f, y - 1.0f, 0.0, 1.0f);
|
||||
texcoord = vec2(x, y) * ResizeFactor * 0.5;
|
||||
}
|
||||
116
src/video_core/host_shaders/sgsr1_shader_mobile.frag
Normal file
116
src/video_core/host_shaders/sgsr1_shader_mobile.frag
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// SPDX-FileCopyrightText: Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#version 460 core
|
||||
|
||||
//precision mediump float;
|
||||
//precision highp int;
|
||||
#define highp
|
||||
#define mediump
|
||||
|
||||
// Operation modes: RGBA -> 1, RGBY -> 3, LERP -> 4
|
||||
#define OperationMode 1
|
||||
#define EdgeThreshold 8.0/255.0
|
||||
// #define EdgeSharpness 2.0
|
||||
// #define UseUniformBlock
|
||||
|
||||
#if defined(UseUniformBlock)
|
||||
layout( push_constant ) uniform constants {
|
||||
highp vec4 ViewportInfo[1];
|
||||
highp vec2 ResizeFactor;
|
||||
highp float EdgeSharpness;
|
||||
};
|
||||
layout(set = 0, binding = 0) uniform mediump sampler2D ps0;
|
||||
#else
|
||||
uniform highp vec4 ViewportInfo[1];
|
||||
uniform mediump sampler2D ps0;
|
||||
#endif
|
||||
|
||||
layout(location=0) in highp vec2 in_TEXCOORD0;
|
||||
layout(location=0) out vec4 out_Target0;
|
||||
|
||||
float fastLanczos2(float x) {
|
||||
float wA = x-4.0;
|
||||
float wB = x*wA-wA;
|
||||
wA *= wA;
|
||||
return wB*wA;
|
||||
}
|
||||
|
||||
vec2 weightY(float dx, float dy,float c, float std) {
|
||||
float x = ((dx*dx)+(dy* dy))* 0.55 + clamp(abs(c)*std, 0.0, 1.0);
|
||||
float w = fastLanczos2(x);
|
||||
return vec2(w, w * c);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color;
|
||||
if(OperationMode == 1)
|
||||
color.xyz = textureLod(ps0, in_TEXCOORD0.xy, 0.0).xyz;
|
||||
else
|
||||
color.xyzw = textureLod(ps0, in_TEXCOORD0.xy, 0.0).xyzw;
|
||||
|
||||
highp float xCenter = abs(in_TEXCOORD0.x + -0.5);
|
||||
highp float yCenter = abs(in_TEXCOORD0.y + -0.5);
|
||||
|
||||
//todo: config the SR region based on needs
|
||||
//if ( OperationMode!=4 && xCenter*xCenter+yCenter*yCenter<=0.4 * 0.4)
|
||||
if ( OperationMode!=4) {
|
||||
highp vec2 imgCoord = ((in_TEXCOORD0.xy * ViewportInfo[0].zw) + vec2(-0.5, 0.5));
|
||||
highp vec2 imgCoordPixel = floor(imgCoord);
|
||||
highp vec2 coord = imgCoordPixel * ViewportInfo[0].xy;
|
||||
vec2 pl = imgCoord - imgCoordPixel;
|
||||
vec4 left = textureGather(ps0, coord, OperationMode);
|
||||
float edgeVote = abs(left.z - left.y) + abs(color[OperationMode] - left.y) + abs(color[OperationMode] - left.z) ;
|
||||
if(edgeVote > EdgeThreshold) {
|
||||
coord.x += ViewportInfo[0].x;
|
||||
|
||||
highp vec2 IR_highp_vec2_0 = coord + vec2(ViewportInfo[0].x, 0.0);
|
||||
vec4 right = textureGather(ps0, IR_highp_vec2_0, OperationMode);
|
||||
vec4 upDown;
|
||||
highp vec2 IR_highp_vec2_1 = coord + vec2(0.0, -ViewportInfo[0].y);
|
||||
upDown.xy = textureGather(ps0, IR_highp_vec2_1, OperationMode).wz;
|
||||
highp vec2 IR_highp_vec2_2 = coord + vec2(0.0, ViewportInfo[0].y);
|
||||
upDown.zw = textureGather(ps0, IR_highp_vec2_2, OperationMode).yx;
|
||||
|
||||
float mean = (left.y+left.z+right.x+right.w)*0.25;
|
||||
left = left - vec4(mean);
|
||||
right = right - vec4(mean);
|
||||
upDown = upDown - vec4(mean);
|
||||
color.w =color[OperationMode] - mean;
|
||||
|
||||
float sum = (((((abs(left.x)+abs(left.y))+abs(left.z))+abs(left.w))+(((abs(right.x)+abs(right.y))+abs(right.z))+abs(right.w)))+(((abs(upDown.x)+abs(upDown.y))+abs(upDown.z))+abs(upDown.w)));
|
||||
float std = 2.181818/sum;
|
||||
|
||||
vec2 aWY = weightY(pl.x, pl.y+1.0, upDown.x,std);
|
||||
aWY += weightY(pl.x-1.0, pl.y+1.0, upDown.y,std);
|
||||
aWY += weightY(pl.x-1.0, pl.y-2.0, upDown.z,std);
|
||||
aWY += weightY(pl.x, pl.y-2.0, upDown.w,std);
|
||||
aWY += weightY(pl.x+1.0, pl.y-1.0, left.x,std);
|
||||
aWY += weightY(pl.x, pl.y-1.0, left.y,std);
|
||||
aWY += weightY(pl.x, pl.y, left.z,std);
|
||||
aWY += weightY(pl.x+1.0, pl.y, left.w,std);
|
||||
aWY += weightY(pl.x-1.0, pl.y-1.0, right.x,std);
|
||||
aWY += weightY(pl.x-2.0, pl.y-1.0, right.y,std);
|
||||
aWY += weightY(pl.x-2.0, pl.y, right.z,std);
|
||||
aWY += weightY(pl.x-1.0, pl.y, right.w,std);
|
||||
|
||||
float finalY = aWY.y/aWY.x;
|
||||
|
||||
float maxY = max(max(left.y,left.z),max(right.x,right.w));
|
||||
float minY = min(min(left.y,left.z),min(right.x,right.w));
|
||||
finalY = clamp(EdgeSharpness*finalY, minY, maxY);
|
||||
|
||||
float deltaY = finalY -color.w;
|
||||
|
||||
//smooth high contrast input
|
||||
deltaY = clamp(deltaY, -23.0 / 255.0, 23.0 / 255.0);
|
||||
|
||||
color.x = clamp((color.x+deltaY),0.0,1.0);
|
||||
color.y = clamp((color.y+deltaY),0.0,1.0);
|
||||
color.z = clamp((color.z+deltaY),0.0,1.0);
|
||||
}
|
||||
}
|
||||
|
||||
color.w = 1.0; //assume alpha channel is not used
|
||||
out_Target0.xyzw = color;
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
// SPDX-FileCopyrightText: Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#version 460 core
|
||||
|
||||
//precision mediump float;
|
||||
//precision highp int;
|
||||
#define highp
|
||||
#define mediump
|
||||
|
||||
// Operation modes: RGBA -> 1, RGBY -> 3, LERP -> 4
|
||||
#define OperationMode 1
|
||||
// If set, will use edge direction to improve visual quality
|
||||
// Expect a minimal cost increase
|
||||
#define UseEdgeDirection 1
|
||||
#define EdgeThreshold 8.0/255.0
|
||||
// #define EdgeSharpness 2.0
|
||||
// #define UseUniformBlock
|
||||
|
||||
#if defined(UseUniformBlock)
|
||||
layout( push_constant ) uniform constants {
|
||||
highp vec4 ViewportInfo[1];
|
||||
highp vec2 ResizeFactor;
|
||||
highp float EdgeSharpness;
|
||||
};
|
||||
layout(set = 0, binding = 0) uniform mediump sampler2D ps0;
|
||||
#else
|
||||
uniform highp vec4 ViewportInfo[1];
|
||||
uniform mediump sampler2D ps0;
|
||||
#endif
|
||||
|
||||
layout(location=0) in highp vec2 in_TEXCOORD0;
|
||||
layout(location=0) out vec4 out_Target0;
|
||||
|
||||
float fastLanczos2(float x) {
|
||||
float wA = x-4.0;
|
||||
float wB = x*wA-wA;
|
||||
wA *= wA;
|
||||
return wB*wA;
|
||||
}
|
||||
|
||||
#if defined(UseEdgeDirection)
|
||||
vec2 weightY(float dx, float dy, float c, vec3 data)
|
||||
#else
|
||||
vec2 weightY(float dx, float dy, float c, float data)
|
||||
#endif
|
||||
{
|
||||
#if defined(UseEdgeDirection)
|
||||
float std = data.x;
|
||||
vec2 dir = data.yz;
|
||||
|
||||
float edgeDis = ((dx*dir.y)+(dy*dir.x));
|
||||
float x = (((dx*dx)+(dy*dy))+((edgeDis*edgeDis)*((clamp(((c*c)*std),0.0,1.0)*0.7)+-1.0)));
|
||||
#else
|
||||
float std = data;
|
||||
float x = ((dx*dx)+(dy* dy))* 0.55 + clamp(abs(c)*std, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
float w = fastLanczos2(x);
|
||||
return vec2(w, w * c);
|
||||
}
|
||||
|
||||
vec2 edgeDirection(vec4 left, vec4 right) {
|
||||
vec2 dir;
|
||||
float RxLz = (right.x + (-left.z));
|
||||
float RwLy = (right.w + (-left.y));
|
||||
vec2 delta;
|
||||
delta.x = (RxLz + RwLy);
|
||||
delta.y = (RxLz + (-RwLy));
|
||||
float lengthInv = inversesqrt((delta.x * delta.x+ 3.075740e-05) + (delta.y * delta.y));
|
||||
dir.x = (delta.x * lengthInv);
|
||||
dir.y = (delta.y * lengthInv);
|
||||
return dir;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color;
|
||||
if(OperationMode == 1)
|
||||
color.xyz = textureLod(ps0, in_TEXCOORD0.xy, 0.0).xyz;
|
||||
else
|
||||
color.xyzw = textureLod(ps0, in_TEXCOORD0.xy, 0.0).xyzw;
|
||||
|
||||
highp float xCenter = abs(in_TEXCOORD0.x + -0.5);
|
||||
highp float yCenter = abs(in_TEXCOORD0.y + -0.5);
|
||||
|
||||
//todo: config the SR region based on needs
|
||||
//if ( OperationMode!=4 && xCenter*xCenter+yCenter*yCenter<=0.4 * 0.4)
|
||||
if ( OperationMode!=4) {
|
||||
highp vec2 imgCoord = ((in_TEXCOORD0.xy*ViewportInfo[0].zw)+vec2(-0.5,0.5));
|
||||
highp vec2 imgCoordPixel = floor(imgCoord);
|
||||
highp vec2 coord = (imgCoordPixel*ViewportInfo[0].xy);
|
||||
vec2 pl = imgCoord - imgCoordPixel;
|
||||
vec4 left = textureGather(ps0, coord, OperationMode);
|
||||
float edgeVote = abs(left.z - left.y) + abs(color[OperationMode] - left.y) + abs(color[OperationMode] - left.z) ;
|
||||
if(edgeVote > EdgeThreshold) {
|
||||
coord.x += ViewportInfo[0].x;
|
||||
|
||||
highp vec2 IR_highp_vec2_0 = coord + vec2(ViewportInfo[0].x, 0.0);
|
||||
vec4 right = textureGather(ps0, IR_highp_vec2_0, OperationMode);
|
||||
vec4 upDown;
|
||||
highp vec2 IR_highp_vec2_1 = coord + vec2(0.0, -ViewportInfo[0].y);
|
||||
upDown.xy = textureGather(ps0, IR_highp_vec2_1, OperationMode).wz;
|
||||
highp vec2 IR_highp_vec2_2 = coord + vec2(0.0, ViewportInfo[0].y);
|
||||
upDown.zw = textureGather(ps0, IR_highp_vec2_2, OperationMode).yx;
|
||||
|
||||
float mean = (left.y+left.z+right.x+right.w)*0.25;
|
||||
left = left - vec4(mean);
|
||||
right = right - vec4(mean);
|
||||
upDown = upDown - vec4(mean);
|
||||
color.w =color[OperationMode] - mean;
|
||||
|
||||
float sum = (((((abs(left.x)+abs(left.y))+abs(left.z))+abs(left.w))+(((abs(right.x)+abs(right.y))+abs(right.z))+abs(right.w)))+(((abs(upDown.x)+abs(upDown.y))+abs(upDown.z))+abs(upDown.w)));
|
||||
float sumMean = 1.014185e+01/sum;
|
||||
float std = (sumMean*sumMean);
|
||||
|
||||
#if defined(UseEdgeDirection)
|
||||
vec3 data = vec3(std, edgeDirection(left, right));
|
||||
#else
|
||||
float data = std;
|
||||
#endif
|
||||
vec2 aWY = weightY(pl.x, pl.y+1.0, upDown.x,data);
|
||||
aWY += weightY(pl.x-1.0, pl.y+1.0, upDown.y,data);
|
||||
aWY += weightY(pl.x-1.0, pl.y-2.0, upDown.z,data);
|
||||
aWY += weightY(pl.x, pl.y-2.0, upDown.w,data);
|
||||
aWY += weightY(pl.x+1.0, pl.y-1.0, left.x,data);
|
||||
aWY += weightY(pl.x, pl.y-1.0, left.y,data);
|
||||
aWY += weightY(pl.x, pl.y, left.z,data);
|
||||
aWY += weightY(pl.x+1.0, pl.y, left.w,data);
|
||||
aWY += weightY(pl.x-1.0, pl.y-1.0, right.x,data);
|
||||
aWY += weightY(pl.x-2.0, pl.y-1.0, right.y,data);
|
||||
aWY += weightY(pl.x-2.0, pl.y, right.z,data);
|
||||
aWY += weightY(pl.x-1.0, pl.y, right.w,data);
|
||||
|
||||
float finalY = aWY.y/aWY.x;
|
||||
float maxY = max(max(left.y,left.z),max(right.x,right.w));
|
||||
float minY = min(min(left.y,left.z),min(right.x,right.w));
|
||||
float deltaY = clamp(EdgeSharpness*finalY, minY, maxY) -color.w;
|
||||
|
||||
//smooth high contrast input
|
||||
deltaY = clamp(deltaY, -23.0 / 255.0, 23.0 / 255.0);
|
||||
|
||||
color.x = clamp((color.x+deltaY),0.0,1.0);
|
||||
color.y = clamp((color.y+deltaY),0.0,1.0);
|
||||
color.z = clamp((color.z+deltaY),0.0,1.0);
|
||||
}
|
||||
}
|
||||
color.w = 1.0; //assume alpha channel is not used
|
||||
out_Target0.xyzw = color;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2024 Torzu Emulator Project
|
||||
|
|
@ -115,6 +115,8 @@ void BlitScreen::CreateWindowAdapt() {
|
|||
window_adapt = MakeMmpx(device);
|
||||
break;
|
||||
case Settings::ScalingFilter::Fsr:
|
||||
case Settings::ScalingFilter::Sgsr:
|
||||
case Settings::ScalingFilter::SgsrEdge:
|
||||
case Settings::ScalingFilter::Bilinear:
|
||||
default:
|
||||
window_adapt = MakeBilinear(device);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "common/settings.h"
|
||||
#include "video_core/framebuffer_config.h"
|
||||
#include "video_core/renderer_vulkan/present/fsr.h"
|
||||
#include "video_core/renderer_vulkan/present/sgsr.h"
|
||||
#include "video_core/renderer_vulkan/present/fxaa.h"
|
||||
#include "video_core/renderer_vulkan/present/layer.h"
|
||||
#include "video_core/renderer_vulkan/present/present_push_constants.h"
|
||||
|
|
@ -63,7 +64,11 @@ Layer::Layer(const Device& device_, MemoryAllocator& memory_allocator_, Schedule
|
|||
CreateDescriptorPool();
|
||||
CreateDescriptorSets(layout);
|
||||
if (filters.get_scaling_filter() == Settings::ScalingFilter::Fsr) {
|
||||
fsr.emplace(device, memory_allocator, image_count, output_size);
|
||||
sr_filter.emplace<FSR>(device, memory_allocator, image_count, output_size);
|
||||
} else if (filters.get_scaling_filter() == Settings::ScalingFilter::Sgsr) {
|
||||
sr_filter.emplace<SGSR>(device, memory_allocator, image_count, output_size, false);
|
||||
} else if (filters.get_scaling_filter() == Settings::ScalingFilter::SgsrEdge) {
|
||||
sr_filter.emplace<SGSR>(device, memory_allocator, image_count, output_size, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,9 +119,12 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
|
|||
.height = scaled_height,
|
||||
};
|
||||
|
||||
if (fsr) {
|
||||
if (auto* fsr = std::get_if<FSR>(&sr_filter)) {
|
||||
source_image_view = fsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
|
||||
crop_rect = {0, 0, 1, 1};
|
||||
} else if (auto* sgsr = std::get_if<SGSR>(&sr_filter)) {
|
||||
source_image_view = sgsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
|
||||
crop_rect = {0, 0, 1, 1};
|
||||
}
|
||||
|
||||
SetMatrixData(*out_push_constants, layout);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "video_core/host1x/gpu_device_memory_manager.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
#include "video_core/renderer_vulkan/present/fsr.h"
|
||||
#include "video_core/renderer_vulkan/present/sgsr.h"
|
||||
#include "video_core/renderer_vulkan/present/fxaa.h"
|
||||
#include "video_core/renderer_vulkan/present/smaa.h"
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ private:
|
|||
|
||||
Settings::AntiAliasing anti_alias_setting{};
|
||||
std::variant<std::monostate, FXAA, SMAA> anti_alias{};
|
||||
std::optional<FSR> fsr{};
|
||||
std::variant<std::monostate, SGSR, FSR> sr_filter{};
|
||||
std::vector<u64> resource_ticks{};
|
||||
};
|
||||
|
||||
|
|
|
|||
144
src/video_core/renderer_vulkan/present/sgsr.cpp
Normal file
144
src/video_core/renderer_vulkan/present/sgsr.cpp
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/div_ceil.h"
|
||||
#include "common/settings.h"
|
||||
|
||||
//#include "video_core/sgsr.h"
|
||||
#include "video_core/host_shaders/sgsr1_shader_mobile_frag_spv.h"
|
||||
#include "video_core/host_shaders/sgsr1_shader_mobile_edge_direction_frag_spv.h"
|
||||
#include "video_core/host_shaders/sgsr1_shader_vert_spv.h"
|
||||
#include "video_core/renderer_vulkan/present/sgsr.h"
|
||||
#include "video_core/renderer_vulkan/present/util.h"
|
||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_shader_util.h"
|
||||
#include "video_core/vulkan_common/vulkan_device.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
using PushConstants = std::array<u32, 4 + 2 + 1>;
|
||||
|
||||
SGSR::SGSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count, VkExtent2D extent, bool edge_dir)
|
||||
: m_device{device}, m_memory_allocator{memory_allocator}
|
||||
, m_image_count{image_count}, m_extent{extent}
|
||||
, m_edge_dir{edge_dir}
|
||||
{
|
||||
// Not finished yet initializing at ctor time?
|
||||
m_dynamic_images.resize(m_image_count);
|
||||
for (auto& images : m_dynamic_images) {
|
||||
images.images[0] = CreateWrappedImage(m_memory_allocator, m_extent, VK_FORMAT_R16G16B16A16_SFLOAT);
|
||||
images.image_views[0] = CreateWrappedImageView(m_device, images.images[0], VK_FORMAT_R16G16B16A16_SFLOAT);
|
||||
}
|
||||
|
||||
m_renderpass = CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16B16A16_SFLOAT);
|
||||
for (auto& images : m_dynamic_images)
|
||||
images.framebuffers[0] = CreateWrappedFramebuffer(m_device, m_renderpass, images.image_views[0], m_extent);
|
||||
|
||||
m_sampler = CreateBilinearSampler(m_device);
|
||||
m_vert_shader = BuildShader(m_device, SGSR1_SHADER_VERT_SPV);
|
||||
m_stage_shader[0] = m_edge_dir
|
||||
? BuildShader(m_device, SGSR1_SHADER_MOBILE_EDGE_DIRECTION_FRAG_SPV)
|
||||
: BuildShader(m_device, SGSR1_SHADER_MOBILE_FRAG_SPV);
|
||||
// 2 descriptors, 2 descriptor sets per invocation
|
||||
m_descriptor_pool = CreateWrappedDescriptorPool(m_device, SGSR_STAGE_COUNT * m_image_count, SGSR_STAGE_COUNT * m_image_count);
|
||||
m_descriptor_set_layout = CreateWrappedDescriptorSetLayout(m_device, {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER});
|
||||
|
||||
std::vector<VkDescriptorSetLayout> layouts(SGSR_STAGE_COUNT, *m_descriptor_set_layout);
|
||||
for (auto& images : m_dynamic_images)
|
||||
images.descriptor_sets = CreateWrappedDescriptorSets(m_descriptor_pool, layouts);
|
||||
|
||||
const VkPushConstantRange range{
|
||||
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
.offset = 0,
|
||||
.size = sizeof(PushConstants),
|
||||
};
|
||||
VkPipelineLayoutCreateInfo ci{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.setLayoutCount = 1,
|
||||
.pSetLayouts = m_descriptor_set_layout.address(),
|
||||
.pushConstantRangeCount = 1,
|
||||
.pPushConstantRanges = &range,
|
||||
};
|
||||
m_pipeline_layout = m_device.GetLogical().CreatePipelineLayout(ci);
|
||||
m_stage_pipeline[0] = CreateWrappedPipeline(m_device, m_renderpass, m_pipeline_layout, std::tie(m_vert_shader, m_stage_shader[0]));
|
||||
}
|
||||
|
||||
void SGSR::UpdateDescriptorSets(VkImageView image_view, size_t image_index) {
|
||||
Images& images = m_dynamic_images[image_index];
|
||||
std::vector<VkDescriptorImageInfo> image_infos;
|
||||
std::vector<VkWriteDescriptorSet> updates;
|
||||
image_infos.reserve(1);
|
||||
updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, image_view, images.descriptor_sets[0], 0));
|
||||
m_device.GetLogical().UpdateDescriptorSets(updates, {});
|
||||
}
|
||||
|
||||
void SGSR::UploadImages(Scheduler& scheduler) {
|
||||
if (!m_images_ready) {
|
||||
scheduler.Record([&](vk::CommandBuffer cmdbuf) {
|
||||
for (auto& image : m_dynamic_images) {
|
||||
ClearColorImage(cmdbuf, *image.images[0]);
|
||||
}
|
||||
});
|
||||
scheduler.Finish();
|
||||
m_images_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
VkImageView SGSR::Draw(Scheduler& scheduler, size_t image_index, VkImage source_image, VkImageView source_image_view, VkExtent2D input_image_extent, const Common::Rectangle<f32>& crop_rect) {
|
||||
Images& images = m_dynamic_images[image_index];
|
||||
auto const stage0_image = *images.images[0];
|
||||
auto const stage0_descriptor_set = images.descriptor_sets[0];
|
||||
auto const stage0_framebuffer = *images.framebuffers[0];
|
||||
auto const stage0_pipeline = *m_stage_pipeline[0];
|
||||
|
||||
VkPipelineLayout pipeline_layout = *m_pipeline_layout;
|
||||
VkRenderPass renderpass = *m_renderpass;
|
||||
VkExtent2D extent = m_extent;
|
||||
|
||||
const f32 input_image_width = f32(input_image_extent.width);
|
||||
const f32 input_image_height = f32(input_image_extent.height);
|
||||
const f32 viewport_width = (crop_rect.right - crop_rect.left) * input_image_width;
|
||||
const f32 viewport_height = (crop_rect.bottom - crop_rect.top) * input_image_height;
|
||||
// expected [0, 2]
|
||||
const f32 sharpening = f32(Settings::values.fsr_sharpening_slider.GetValue()) / 100.0f;
|
||||
|
||||
// p = (tex * viewport) / input = [0,n] (normalized texcoords)
|
||||
// p * input = [0,1024], [0,768]
|
||||
// layout( push_constant ) uniform constants {
|
||||
// highp vec4 ViewportInfo[1];
|
||||
// highp vec2 ResizeFactor;
|
||||
// highp float EdgeSharpness;
|
||||
// };
|
||||
PushConstants viewport_con{};
|
||||
viewport_con[0] = std::bit_cast<u32>(1.f / viewport_width);
|
||||
viewport_con[1] = std::bit_cast<u32>(1.f / viewport_height);
|
||||
viewport_con[2] = std::bit_cast<u32>(viewport_width);
|
||||
viewport_con[3] = std::bit_cast<u32>(viewport_height);
|
||||
viewport_con[4] = std::bit_cast<u32>(viewport_width / input_image_width);
|
||||
viewport_con[5] = std::bit_cast<u32>(viewport_height / input_image_height);
|
||||
viewport_con[6] = std::bit_cast<u32>(sharpening);
|
||||
|
||||
UploadImages(scheduler);
|
||||
UpdateDescriptorSets(source_image_view, image_index);
|
||||
|
||||
scheduler.RequestOutsideRenderPassOperationContext();
|
||||
scheduler.Record([=](vk::CommandBuffer cmdbuf) {
|
||||
TransitionImageLayout(cmdbuf, source_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||
TransitionImageLayout(cmdbuf, stage0_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||
BeginRenderPass(cmdbuf, renderpass, stage0_framebuffer, extent);
|
||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, stage0_pipeline);
|
||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, stage0_descriptor_set, {});
|
||||
cmdbuf.PushConstants(pipeline_layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
viewport_con);
|
||||
cmdbuf.Draw(3, 1, 0, 0);
|
||||
cmdbuf.EndRenderPass();
|
||||
TransitionImageLayout(cmdbuf, stage0_image, VK_IMAGE_LAYOUT_GENERAL);
|
||||
});
|
||||
return *images.image_views[0];
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
50
src/video_core/renderer_vulkan/present/sgsr.h
Normal file
50
src/video_core/renderer_vulkan/present/sgsr.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/math_util.h"
|
||||
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
class Device;
|
||||
class Scheduler;
|
||||
|
||||
class SGSR {
|
||||
public:
|
||||
static constexpr size_t SGSR_STAGE_COUNT = 1;
|
||||
explicit SGSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count, VkExtent2D extent, bool edge_dir);
|
||||
VkImageView Draw(Scheduler& scheduler, size_t image_index, VkImage source_image, VkImageView source_image_view, VkExtent2D input_image_extent, const Common::Rectangle<f32>& crop_rect);
|
||||
private:
|
||||
void Initialize();
|
||||
void UploadImages(Scheduler& scheduler);
|
||||
void UpdateDescriptorSets(VkImageView image_view, size_t image_index);
|
||||
|
||||
const Device& m_device;
|
||||
MemoryAllocator& m_memory_allocator;
|
||||
const size_t m_image_count;
|
||||
const VkExtent2D m_extent;
|
||||
|
||||
vk::DescriptorPool m_descriptor_pool;
|
||||
vk::DescriptorSetLayout m_descriptor_set_layout;
|
||||
vk::PipelineLayout m_pipeline_layout;
|
||||
vk::ShaderModule m_vert_shader;
|
||||
std::array<vk::ShaderModule, SGSR_STAGE_COUNT> m_stage_shader;
|
||||
std::array<vk::Pipeline, SGSR_STAGE_COUNT> m_stage_pipeline;
|
||||
vk::RenderPass m_renderpass;
|
||||
vk::Sampler m_sampler;
|
||||
|
||||
struct Images {
|
||||
vk::DescriptorSets descriptor_sets;
|
||||
std::array<vk::Image, SGSR_STAGE_COUNT> images;
|
||||
std::array<vk::ImageView, SGSR_STAGE_COUNT> image_views;
|
||||
std::array<vk::Framebuffer, SGSR_STAGE_COUNT> framebuffers;
|
||||
};
|
||||
std::vector<Images> m_dynamic_images;
|
||||
bool m_images_ready{};
|
||||
bool m_edge_dir{};
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
|
@ -73,6 +73,8 @@ void BlitScreen::SetWindowAdaptPass() {
|
|||
window_adapt = MakeMmpx(device, swapchain_view_format);
|
||||
break;
|
||||
case Settings::ScalingFilter::Fsr:
|
||||
case Settings::ScalingFilter::Sgsr:
|
||||
case Settings::ScalingFilter::SgsrEdge:
|
||||
case Settings::ScalingFilter::Bilinear:
|
||||
default:
|
||||
window_adapt = MakeBilinear(device, swapchain_view_format);
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
|
|||
// FSR needs a reversed slider and a 0.5 multiplier
|
||||
return builder.BuildWidget(
|
||||
setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true,
|
||||
0.5f, nullptr, tr("%", "FSR sharpening percentage (e.g. 50%)"));
|
||||
0.5f, nullptr, tr("%", "FSR/SGSR sharpening percentage (e.g. 50%)"));
|
||||
} else {
|
||||
return builder.BuildWidget(setting, apply_funcs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4394,8 +4394,7 @@ void MainWindow::UpdateAPIText() {
|
|||
void MainWindow::UpdateFilterText() {
|
||||
const auto filter = Settings::values.scaling_filter.GetValue();
|
||||
const auto filter_text = ConfigurationShared::scaling_filter_texts_map.find(filter)->second;
|
||||
filter_status_button->setText(filter == Settings::ScalingFilter::Fsr ? tr("FSR")
|
||||
: filter_text.toUpper());
|
||||
filter_status_button->setText(filter_text.toUpper());
|
||||
}
|
||||
|
||||
void MainWindow::UpdateAAText() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue