Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Video Super Resolution for Windows (AMD, Intel and NVIDIA) and MacOS #1180

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
aad9113
Add a new UI feature called "Video AI-Enhancement" (VAE)
linckosz Feb 7, 2024
d40a8f1
Add AI Super Resolution for NVIDIA and Intel GPUs
linckosz Feb 8, 2024
2a1e226
Fix Mac build issue
linckosz Feb 10, 2024
b5061f3
Improve the rendering of HDR mode by removing visual glitches
linckosz Feb 10, 2024
1832c7b
Merge branch 'moonlight-stream:master' into master
Feb 10, 2024
7391f94
Add a new UI feature called "Video AI-Enhancement" (VAE)
linckosz Feb 7, 2024
89b6485
Add AI Super Resolution for NVIDIA and Intel GPUs
linckosz Feb 8, 2024
6c0181d
Correct spelling in comments
linckosz Feb 24, 2024
05000db
Add flag D3D11_BIND_RENDER_TARGET only if Video enhancement is enabled
linckosz Feb 24, 2024
937be56
Replace the variable m_IsHDRenabled
linckosz Feb 26, 2024
362f5ca
Change the method to get Video Driver version to a more conventional way
linckosz Feb 26, 2024
ae8118b
Use Hexadecimal value for VendorID
linckosz Feb 26, 2024
7e317ef
Correct the HDR metadata for Stream and Output sources
linckosz Feb 26, 2024
9562a59
Replace CComPtr by Microsoft::WRL::ComPtr
linckosz Feb 26, 2024
0ed68bf
Remove "reset" parameter from the method "D3D11VARenderer::createVide…
linckosz Feb 26, 2024
17d4d00
Turn off D3D11_VIDEO_PROCESSOR_FILTER_HUE in SDR mode
linckosz Feb 26, 2024
7c22abd
Add the source links of some key values for VSR and SDR->HDR features
linckosz Feb 26, 2024
4bb3eff
Remove ID3D11VideoContext1::VideoProcessorSetOutputShaderUsage as it …
linckosz Feb 27, 2024
9ca8b6f
Enable Video AI-Enhancement in Exclusive Fullscreen
linckosz Feb 27, 2024
d34d7b8
Simplifying the initialization of the Color Space for Stream and Output
linckosz Feb 27, 2024
b10243b
For Multi-GPU setup, select most appropriate GPU when Video Enhanceme…
linckosz Mar 1, 2024
cbc9fd3
Update setHDRoutput to match the display in-use
linckosz Mar 1, 2024
51753e1
Disable VSR and HDR when scan for capabilities
linckosz Mar 1, 2024
3de61ec
Bug Fixes
linckosz Mar 1, 2024
ec5c69e
Use of setHdrMode callback to set HDR MetaData for Stream and Output
linckosz Mar 1, 2024
4db0f6b
Add enableVideoEnhancement to DECODER_PARAMETERS
linckosz Mar 1, 2024
986774b
Replace VideEnhancement method used in QML by SystemProperties' ones.
linckosz Mar 1, 2024
0957d50
Remove the use of VideoProcessorSetStreamSourceRect
linckosz Mar 1, 2024
f5d3f5f
Merge branch 'master' of https://github.com/linckosz/moonlight-qt
linckosz Mar 1, 2024
cd3b3af
Merge branch 'vsr2' into vsr
linckosz Mar 1, 2024
e503d26
Resolution merge conflicts
linckosz Mar 1, 2024
8e239a3
Simplify the code for the checkbox Video Enhancement
linckosz Mar 2, 2024
51912e3
Merge branch 'vsr'
linckosz Mar 2, 2024
715fbd4
Merge branch 'moonlight-stream:master' into master
Mar 3, 2024
df93102
Add AMD Video Enhancement feature
linckosz Mar 27, 2024
01c1c79
Merge branch 'vsr-amd' into vsr
linckosz Mar 27, 2024
63101e0
Add AMD Video Enhancement feature
linckosz Mar 27, 2024
4c965db
Color rendering fix for NVIDIA and Intel when using VideoProcessor
linckosz Mar 29, 2024
2afd294
Color rendering fix for AMD when using AMF
linckosz Mar 31, 2024
336c7ad
Code formating
linckosz Mar 31, 2024
c87a4e1
Merge branch 'vsr-amd' into vsr
linckosz Mar 31, 2024
c637151
Fixing merge issues
linckosz Mar 31, 2024
175cd29
Merge upstream master onto vsr
linckosz Mar 31, 2024
889bd16
Fix Intel HDR grey screen
linckosz Apr 1, 2024
58ed19b
More explicit UI information when Video Enhancement is unavailable
linckosz Apr 5, 2024
0024573
Merge branch 'master' of https://github.com/moonlight-stream/moonligh…
linckosz Apr 21, 2024
44971fe
AMF rendering speed optimization (FSR and Memory)
linckosz Apr 21, 2024
ad903e7
Add Video Super Resolution for MacOS using MetalFX
linckosz May 6, 2024
09fcd4e
Merge remote-tracking branch 'upstream/master' into vsr
linckosz May 6, 2024
dbad1bf
Merge vsr with v6
linckosz Jun 12, 2024
0859028
Merge remote-tracking branch 'origin/vsr' into vsr
linckosz Jun 15, 2024
1caccf8
Fix crash because of CFRelease
linckosz Jun 15, 2024
645e164
Merge remote-tracking branch 'upstream/master' into vsr
linckosz Jul 28, 2024
2068cb3
Reapply some code optimizations related to the Video Enhancement
linckosz Jul 28, 2024
f22d7ff
Fix rendering issue
linckosz Jul 28, 2024
81de32e
For Intel GPU, force binding while using VSR
linckosz Aug 2, 2024
93c5f65
Merge remote-tracking branch 'upstream/master' into vsr
linckosz Aug 3, 2024
8477631
Clean code
linckosz Aug 3, 2024
ee7a0b6
Merge remote-tracking branch 'upstream/master' into vsr
linckosz Aug 22, 2024
f79a57c
Submodules merge
linckosz Aug 23, 2024
bdf5a27
Code fixes
linckosz Aug 23, 2024
f5301fb
Move pixBuf to the method scope
linckosz Aug 23, 2024
da19eea
Merge remote-tracking branch 'upstream/master' into vsr
linckosz Sep 24, 2024
7687561
Merge remote-tracking branch 'origin/master' into vsr
linckosz Sep 24, 2024
009ad8a
Fix memory leak on MacOS
linckosz Sep 27, 2024
1267df4
Merge remote-tracking branch 'origin/master' into vsr
linckosz Sep 27, 2024
77563e8
Fix duplicated variable
linckosz Sep 28, 2024
e716703
Merge remote-tracking branch 'upstream/master' into vsr
linckosz Nov 12, 2024
40070d2
Disable Video enhancement when using Software video decoder
linckosz Nov 13, 2024
fff78a2
Enable CLI command "--video-enhancement"
linckosz Nov 13, 2024
2a40e63
Merge remote-tracking branch 'upstream/master' into vsr
linckosz Nov 16, 2024
4a48953
Disable VSR checkbox for unsupported GPU
linckosz Nov 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


**/.vs/
**/.vscode/
build/
config.tests/*/.qmake.stash
config.tests/*/Makefile
2 changes: 2 additions & 0 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ SOURCES += \
gui/sdlgamepadkeynavigation.cpp \
streaming/video/overlaymanager.cpp \
backend/systemproperties.cpp \
streaming/video/videoenhancement.cpp \
wm.cpp

HEADERS += \
Expand All @@ -207,6 +208,7 @@ HEADERS += \
cli/pair.h \
settings/compatfetcher.h \
settings/mappingfetcher.h \
streaming/video/videoenhancement.h \
utils.h \
backend/computerseeker.h \
backend/identitymanager.h \
Expand Down
3 changes: 3 additions & 0 deletions app/cli/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
// Resolve --frame-pacing and --no-frame-pacing options
preferences->framePacing = parser.getToggleOptionValue("frame-pacing", preferences->framePacing);

// Resolve --video-enhancement and --no-video-enhancement options
preferences->videoEnhancement = parser.getToggleOptionValue("video-enhancement", preferences->videoEnhancement);

// Resolve --mute-on-focus-loss and --no-mute-on-focus-loss options
preferences->muteOnFocusLoss = parser.getToggleOptionValue("mute-on-focus-loss", preferences->muteOnFocusLoss);

Expand Down
106 changes: 106 additions & 0 deletions app/gui/SettingsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import StreamingPreferences 1.0
import ComputerManager 1.0
import SdlGamepadKeyNavigation 1.0
import SystemProperties 1.0
import VideoEnhancement 1.0

Flickable {
id: settingsPage
objectName: qsTr("Settings")

signal languageChanged()
signal displayModeChanged()
signal windowModeChanged()
signal videoEnhancementChanged()

boundsBehavior: Flickable.OvershootBounds

Expand Down Expand Up @@ -231,6 +235,9 @@ Flickable {
recalculateWidth()

lastIndexValue = currentIndex

// Signal other controls
displayModeChanged()
}

id: resolutionComboBox
Expand Down Expand Up @@ -292,6 +299,9 @@ Flickable {
else {
updateBitrateForSelection()
}

// Signal other controls
displayModeChanged()
}

NavigableDialog {
Expand All @@ -310,6 +320,9 @@ Flickable {
onClosed: {
widthField.clear()
heightField.clear()

// Signal other controls
displayModeChanged()
}

onRejected: {
Expand Down Expand Up @@ -759,9 +772,25 @@ Flickable {
activated(currentIndex)
}

// Video Super-Resolution does not work in exclusive full screen, so auto switch do borderless window
// [TODO] This may change according to what AMD and Intel will implement, if they can allow video enhancement in fullscreen
linckosz marked this conversation as resolved.
Show resolved Hide resolved
function checkVSR(){
if(videoEnhancementCheck.checked && model.get(currentIndex).val === StreamingPreferences.WM_FULLSCREEN){
for (var i = 0; i < model.count; i++) {
var thisWm = model.get(i).val;
if (model.get(i).val === StreamingPreferences.WM_FULLSCREEN_DESKTOP) {
currentIndex = i
break
}
}
activated(currentIndex)
}
}

Component.onCompleted: {
reinitialize()
languageChanged.connect(reinitialize)
videoEnhancementChanged.connect(checkVSR)
}

id: windowModeComboBox
Expand All @@ -771,6 +800,8 @@ Flickable {
textRole: "text"
onActivated: {
StreamingPreferences.windowMode = model.get(currentIndex).val
// Signal others
windowModeChanged()
}

ToolTip.delay: 1000
Expand Down Expand Up @@ -812,6 +843,81 @@ Flickable {
ToolTip.visible: hovered
ToolTip.text: qsTr("Frame pacing reduces micro-stutter by delaying frames that come in too early")
}

CheckBox {
id: videoEnhancementCheck
width: parent.width
hoverEnabled: true
text: qsTr("Video AI-Enhancement")
font.pointSize: 12
visible: VideoEnhancement.isUIvisible()
enabled: true
checked: StreamingPreferences.videoEnhancement
property bool checkedSaved

onCheckedChanged: {
StreamingPreferences.videoEnhancement = checked
// The value of checkedSaved is set while changing the WindowMode, need to find a way not to.
if(StreamingPreferences.windowMode !== StreamingPreferences.WM_FULLSCREEN){
checkedSaved = checked
}
// Signal others
videoEnhancementChanged()
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text:
qsTr("Enhance video quality by utilizing the GPU's AI-Enhancement capabilities.")
+ qsTr("\nThis feature effectively upscales, reduces compression artifacts and enhances the clarity of streamed content.")
+ qsTr("\nNote:")
+ qsTr("\n - For optimal performance, use the software in borderless window mode; this feature is not applicable in fullscreen mode.")
+ qsTr("\n - If available, ensure that appropriate settings, such as VSR (Virtual Super Resolution), are enabled in your GPU driver configurations.")
+ qsTr("\n - Be advised that using this feature on laptops running on battery power may lead to significant battery drain.")

function reinitialize() {
if(typeof(checkedSaved) === "undefined"){
checkedSaved = checked
}
if(!VideoEnhancement.isUIvisible()){
checked = false
checkedSaved = checked
visible = false
}
// If Exclusive fullscreen is selected, disabled the VSR as it does not work in this window mode
else if(StreamingPreferences.windowMode === StreamingPreferences.WM_FULLSCREEN){
checked = false
}
else {
// Get back the saved status
checked = checkedSaved
}
// Indicate if the feature is available but not officially deployed by the Vendor
if(VideoEnhancement.isExperimental()){
text = qsTr("Video AI-Enhancement (Experimental)")
}
}

Timer {
id: vsrTimer
interval: 300 // 0 to make it async to get the final status of StreamingPreferences.windowMode (which is set too late in the process)
running: false // Don't start the timer immediately
repeat: false // Run only once

onTriggered: {
parent.reinitialize()
}
}

Component.onCompleted: {
checkedSaved = checked
reinitialize()
windowModeChanged.connect(() => {
checked = checkedSaved
vsrTimer.start()
})
}
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "streaming/session.h"
#include "settings/streamingpreferences.h"
#include "gui/sdlgamepadkeynavigation.h"
#include "streaming/video/videoenhancement.h"

#if !defined(QT_DEBUG) && defined(Q_OS_WIN32)
// Log to file for release Windows builds
Expand Down Expand Up @@ -636,6 +637,15 @@ int main(int argc, char *argv[])
[](QQmlEngine* qmlEngine, QJSEngine*) -> QObject* {
return new StreamingPreferences(qmlEngine);
});
qmlRegisterSingletonType<VideoEnhancement>("VideoEnhancement", 1, 0, "VideoEnhancement",
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
VideoEnhancement* videoEnhancement = &VideoEnhancement::getInstance();
// Set the ownership to CppOwnership to avoid an error when QLM engine tries to delete the object
QQmlEngine::setObjectOwnership(videoEnhancement, QQmlEngine::CppOwnership);
return videoEnhancement;
linckosz marked this conversation as resolved.
Show resolved Hide resolved
});

// Create the identity manager on the main thread
IdentityManager::get();
Expand Down
3 changes: 3 additions & 0 deletions app/settings/streamingpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define SER_ABSTOUCHMODE "abstouchmode"
#define SER_STARTWINDOWED "startwindowed"
#define SER_FRAMEPACING "framepacing"
#define SER_VIDEOENHANCEMENT "videoenhancement"
#define SER_CONNWARNINGS "connwarnings"
#define SER_UIDISPLAYMODE "uidisplaymode"
#define SER_RICHPRESENCE "richpresence"
Expand Down Expand Up @@ -93,6 +94,7 @@ void StreamingPreferences::reload()
absoluteMouseMode = settings.value(SER_ABSMOUSEMODE, false).toBool();
absoluteTouchMode = settings.value(SER_ABSTOUCHMODE, true).toBool();
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
videoEnhancement = settings.value(SER_VIDEOENHANCEMENT, false).toBool();
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
richPresence = settings.value(SER_RICHPRESENCE, true).toBool();
gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool();
Expand Down Expand Up @@ -275,6 +277,7 @@ void StreamingPreferences::save()
settings.setValue(SER_ABSMOUSEMODE, absoluteMouseMode);
settings.setValue(SER_ABSTOUCHMODE, absoluteTouchMode);
settings.setValue(SER_FRAMEPACING, framePacing);
settings.setValue(SER_VIDEOENHANCEMENT, videoEnhancement);
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
settings.setValue(SER_RICHPRESENCE, richPresence);
settings.setValue(SER_GAMEPADMOUSE, gamepadMouse);
Expand Down
6 changes: 6 additions & 0 deletions app/settings/streamingpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class StreamingPreferences : public QObject
Q_PROPERTY(bool absoluteMouseMode MEMBER absoluteMouseMode NOTIFY absoluteMouseModeChanged)
Q_PROPERTY(bool absoluteTouchMode MEMBER absoluteTouchMode NOTIFY absoluteTouchModeChanged)
Q_PROPERTY(bool framePacing MEMBER framePacing NOTIFY framePacingChanged)
Q_PROPERTY(bool videoEnhancement MEMBER videoEnhancement NOTIFY videoEnhancementChanged)
Q_PROPERTY(bool videoEnhancementVisible MEMBER videoEnhancementVisible NOTIFY videoEnhancementVisibleChanged)
Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged)
Q_PROPERTY(bool richPresence MEMBER richPresence NOTIFY richPresenceChanged)
Q_PROPERTY(bool gamepadMouse MEMBER gamepadMouse NOTIFY gamepadMouseChanged)
Expand Down Expand Up @@ -152,6 +154,8 @@ class StreamingPreferences : public QObject
bool absoluteMouseMode;
bool absoluteTouchMode;
bool framePacing;
bool videoEnhancement;
bool videoEnhancementVisible;
bool connectionWarnings;
bool richPresence;
bool gamepadMouse;
Expand Down Expand Up @@ -192,6 +196,8 @@ class StreamingPreferences : public QObject
void uiDisplayModeChanged();
void windowModeChanged();
void framePacingChanged();
void videoEnhancementChanged();
void videoEnhancementVisibleChanged();
void connectionWarningsChanged();
void richPresenceChanged();
void gamepadMouseChanged();
Expand Down
Loading