Remove Snapdragon Game Super Resolution

This commit is contained in:
Patrick Nicolas
2025-09-10 21:44:22 +02:00
parent 80933a3392
commit 200586a0af
7 changed files with 1 additions and 364 deletions
-32
View File
@@ -1,32 +0,0 @@
Snapdragon(TM) Game Super Resolution
Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
https://github.com/SnapdragonStudios/snapdragon-gsr
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
SPDX-License-Identifier: BSD-3-Clause
-36
View File
@@ -181,9 +181,6 @@ configuration::configuration(xr::system & system)
if (auto val = root["enable_stream_gui"]; val.is_bool())
enable_stream_gui = val.get_bool();
if (auto val = root["sgsr"]; val.is_object())
parse_sgsr_options(val.get_object());
if (auto val = root["openxr_post_processing"]; val.is_object())
parse_openxr_post_processing_options(val.get_object());
@@ -231,31 +228,11 @@ configuration::configuration(xr::system & system)
preferred_refresh_rate.reset();
minimum_refresh_rate.reset();
resolution_scale = 1.4;
sgsr = {};
openxr_post_processing = {};
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
}
}
void configuration::parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::object> sgsr_root)
{
sgsr = {};
if (auto val = sgsr_root["enabled"]; val.is_bool())
sgsr.enabled = val.get_bool();
if (auto val = sgsr_root["upscaling_factor"]; val.is_double())
sgsr.upscaling_factor = val.get_double();
if (auto val = sgsr_root["use_edge_direction"]; val.is_bool())
sgsr.use_edge_direction = val.get_bool();
if (auto val = sgsr_root["edge_threshold"]; val.is_double())
sgsr.edge_threshold = val.get_double();
if (auto val = sgsr_root["edge_sharpness"]; val.is_double())
sgsr.edge_sharpness = val.get_double();
}
void configuration::parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> openxr_post_processing_root)
{
openxr_post_processing = {};
@@ -271,17 +248,6 @@ static std::ostream & operator<<(std::ostream & stream, feature f)
return stream << "\"" << magic_enum::enum_name(f) << "\"";
}
static std::ostream & write_sgsr(std::ofstream & stream, const configuration::sgsr_settings & sgsr)
{
stream << "{\"enabled\":" << std::boolalpha << sgsr.enabled;
stream << ",\"upscaling_factor\":" << sgsr.upscaling_factor;
stream << ",\"use_edge_direction\":" << std::boolalpha << sgsr.use_edge_direction;
stream << ",\"edge_threshold\":" << sgsr.edge_threshold;
stream << ",\"edge_sharpness\":" << sgsr.edge_sharpness;
stream << "}";
return stream;
}
static std::ostream & write_openxr_post_processing(std::ofstream & stream, const configuration::openxr_post_processing_settings & openxr_post_processing)
{
stream << "{\"super_sampling\":" << openxr_post_processing.super_sampling;
@@ -324,8 +290,6 @@ void configuration::save()
if (minimum_refresh_rate)
json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
json << ",\"resolution_scale\":" << resolution_scale;
json << ",\"sgsr\":";
write_sgsr(json, sgsr);
json << ",\"openxr_post_processing\":";
write_openxr_post_processing(json, openxr_post_processing);
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
-12
View File
@@ -58,17 +58,6 @@ public:
bool enable_stream_gui = true;
// Snapdragon Game Super Resolution
struct sgsr_settings
{
bool enabled = false;
float upscaling_factor = 1.5;
bool use_edge_direction = true;
float edge_threshold = 4.0;
float edge_sharpness = 2.0;
};
sgsr_settings sgsr{};
// XR_FB_composition_layer_settings extension flags
struct openxr_post_processing_settings
{
@@ -92,7 +81,6 @@ private:
mutable std::mutex mutex;
std::map<feature, bool> features;
void parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::object> root);
void parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> root);
public:
+1 -84
View File
@@ -1060,89 +1060,6 @@ void scenes::lobby::gui_post_processing()
ImGui::Unindent();
}
{
// SGSR
{
if (ImGui::Checkbox(_S("Enable Snapdragon Game Super Resolution"), &config.sgsr.enabled))
{
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
{
if (application::get_openxr_post_processing_supported())
imgui_ctx->tooltip(_("On this headset, this setting has been fully superseded by the native Sharpening setting above.\nOnly enable if you know what you're doing."));
else
imgui_ctx->tooltip(_("Client-side upscaling and sharpening, adds a performance cost on the headset"));
}
if (application::get_openxr_post_processing_supported())
{
ImGui::SameLine();
ImGui::TextColored(ImColor(0xf9, 0x73, 0x06) /*orange*/, ICON_FA_TRIANGLE_EXCLAMATION);
}
}
{
ImGui::BeginDisabled(not config.sgsr.enabled);
ImGui::Indent();
{
const auto current = config.sgsr.upscaling_factor;
const auto width = stream_view.recommendedImageRectWidth * config.resolution_scale;
const auto height = stream_view.recommendedImageRectHeight * config.resolution_scale;
auto intScale = int(current * 100);
const auto slider = ImGui::SliderInt(
_("Upscaling factor").append("##upscaling_factor").c_str(),
&intScale,
100,
200,
fmt::format(_F("%d%% - {}x{} per eye"), int(width * current), int(height * current)).c_str());
if (slider)
{
config.sgsr.upscaling_factor = intScale * 0.01;
config.save();
}
imgui_ctx->vibrate_on_hover();
if (width * current > stream_view.maxImageRectWidth or height * current > stream_view.maxImageRectHeight)
{
ImGui::TextColored(ImColor(0xf9, 0x73, 0x06) /*orange*/, ICON_FA_TRIANGLE_EXCLAMATION);
ImGui::SameLine();
ImGui::Text("%s", fmt::format(_F("Resolution larger than {}x{} may not be supported by the headset"), stream_view.maxImageRectWidth, stream_view.maxImageRectHeight).c_str());
}
}
{
if (ImGui::Checkbox(_S("Use edge direction"), &config.sgsr.use_edge_direction))
{
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Adds an additional performance cost"));
}
{
const float current = config.sgsr.edge_threshold;
int intScale = int(current);
if (ImGui::SliderInt(_S("Edge threshold"), &intScale, 1, 16, "%d.0"))
{
config.sgsr.edge_threshold = float(intScale);
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(fmt::format(_F("Recommended: {:.1f}"), 4.0));
}
{
if (ImGui::SliderFloat(_S("Edge sharpness"), &config.sgsr.edge_sharpness, 1.0, 2.0, "%.2f"))
{
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(fmt::format(_F("Recommended: {:.1f}"), 2.0));
}
ImGui::Unindent();
ImGui::EndDisabled();
}
}
ImGui::PopStyleVar();
}
@@ -1370,7 +1287,7 @@ void scenes::lobby::gui_licenses()
ImGui::Text("%s", _("Licenses").c_str());
ImGui::PopFont();
const auto components = {"WiVRn", "FontAwesome", "openxr-loader", "simdjson", "SGSR"};
const auto components = {"WiVRn", "FontAwesome", "openxr-loader", "simdjson"};
if (not license)
{
selected_item = *components.begin();
-9
View File
@@ -1118,15 +1118,6 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
const uint32_t video_width = video_stream_description->width / view_count;
const uint32_t video_height = video_stream_description->height;
const configuration::sgsr_settings sgsr = application::get_config().sgsr;
if (sgsr.enabled)
{
const float upscaling_factor = sgsr.upscaling_factor;
spdlog::info("Using SGSR with an upscale factor of {}", upscaling_factor);
swapchain_width *= upscaling_factor;
swapchain_height *= upscaling_factor;
}
auto views = system.view_configuration_views(viewconfig);
swapchain = xr::swapchain(session, device, swapchain_format, swapchain_width, swapchain_height, 1, views.size());
-12
View File
@@ -134,22 +134,10 @@ stream_defoveator::pipeline_t & stream_defoveator::ensure_pipeline(size_t view,
vk::raii::ShaderModule vertex_shader = load_shader(device, fragment_shading_rate ? "reprojection_vsr.vert" : "reprojection.vert");
// Fragment shader
#if 0
FIXME: SGSR
const configuration::sgsr_settings & sgsr = application::get_config().sgsr;
auto sgsr_specialization = make_specialization_constants(
VkBool32(sgsr.use_edge_direction),
float(sgsr.edge_threshold / 255.f),
float(sgsr.edge_sharpness));
vk::raii::ShaderModule fragment_shader = load_shader(device, sgsr.enabled ? "reprojection_sgsr.frag" : "reprojection.frag");
#else
auto specialization = make_specialization_constants(
int32_t(alpha),
VkBool32(need_srgb_conversion(guess_model())));
vk::raii::ShaderModule fragment_shader = load_shader(device, "reprojection.frag");
#endif
vk::pipeline_builder pipeline_info_builder{
.flags = {},
-179
View File
@@ -1,179 +0,0 @@
/*
* Snapdragon™ Game Super Resolution
* Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
*
* https://github.com/SnapdragonStudios/snapdragon-gsr
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#version 450
precision mediump float;
precision highp int;
#define OperationMode 1
layout (constant_id = 0) const bool use_edge_direction = true;
layout (constant_id = 1) const float edge_threshold = 4.0/255.0;
layout (constant_id = 2) const float edge_sharpness = 2.0;
layout(set = 0, binding = 0) uniform mediump sampler2D texSampler;
layout(location = 0) in highp vec2 inUV;
layout(location = 0) out vec4 outColor;
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, vec3 data)
{
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)));
float w = fastLanczos2(x);
return vec2(w, w * c);
}
vec2 weightYned(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);
}
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 = textureLod(texSampler,inUV,0.0).xyzw;
float alpha = color.a;
if (OperationMode == 1)
color.a = 0.0;
if (OperationMode != 4)
{
vec2 dim = textureSize(texSampler, 0);
vec4 viewportInfo = vec4(1/dim.x, 1/dim.y, dim.x, dim.y);
highp vec2 imgCoord = ((inUV.xy*viewportInfo.zw)+vec2(-0.5,0.5));
highp vec2 imgCoordPixel = floor(imgCoord);
highp vec2 coord = (imgCoordPixel*viewportInfo.xy);
vec2 pl = (imgCoord+(-imgCoordPixel));
vec4 left = textureGather(texSampler,coord, OperationMode);
float edgeVote = abs(left.z - left.y) + abs(color[OperationMode] - left.y) + abs(color[OperationMode] - left.z) ;
if(edgeVote > edge_threshold)
{
coord.x += viewportInfo.x;
vec4 right = textureGather(texSampler,coord + vec2(viewportInfo.x, 0.0), OperationMode);
vec4 upDown;
upDown.xy = textureGather(texSampler,coord + vec2(0.0, -viewportInfo.y),OperationMode).wz;
upDown.zw = textureGather(texSampler,coord + vec2(0.0, viewportInfo.y), 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);
vec2 aWY;
if (use_edge_direction) {
vec3 data = vec3(std, edgeDirection(left, right));
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);
} else {
aWY = weightYned(pl.x, pl.y+1.0, upDown.x,std);
aWY += weightYned(pl.x-1.0, pl.y+1.0, upDown.y,std);
aWY += weightYned(pl.x-1.0, pl.y-2.0, upDown.z,std);
aWY += weightYned(pl.x, pl.y-2.0, upDown.w,std);
aWY += weightYned(pl.x+1.0, pl.y-1.0, left.x,std);
aWY += weightYned(pl.x, pl.y-1.0, left.y,std);
aWY += weightYned(pl.x, pl.y, left.z,std);
aWY += weightYned(pl.x+1.0, pl.y, left.w,std);
aWY += weightYned(pl.x-1.0, pl.y-1.0, right.x,std);
aWY += weightYned(pl.x-2.0, pl.y-1.0, right.y,std);
aWY += weightYned(pl.x-2.0, pl.y, right.z,std);
aWY += weightYned(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));
float deltaY = clamp(edge_sharpness*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);
}
}
outColor = vec4(color.rgb, alpha);
}