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 a GUI and basically rewrite half of the code #33

Merged
merged 41 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
98360b1
WIP migrate UI to ImGui
Erimelowo Sep 19, 2024
7afeee9
OpenVR -> OVR
Erimelowo Sep 19, 2024
858a2a0
cleanups, minimize, no resize and set resolution to Custom
Erimelowo Sep 19, 2024
f1826e8
fix .ini categories and improve regions
Erimelowo Sep 19, 2024
2cb11de
move some nvml stuff
Erimelowo Sep 19, 2024
89eb63e
fix autostart and error handling
Erimelowo Sep 19, 2024
984e8f7
Add saveSettings method and can write defaults + icon
Erimelowo Sep 20, 2024
a41f7c7
properly quit and cleanup with OpenVR
Erimelowo Sep 20, 2024
230098d
add screenshot in readme, add lodepng license and clarify build steps
Erimelowo Sep 20, 2024
1359578
Update icon.png
Erimelowo Sep 20, 2024
2c71e00
display VRAM as GB and optimize getting it
Erimelowo Sep 20, 2024
76f0b04
use openvr buffer
Erimelowo Sep 21, 2024
e05f267
settings wip
Erimelowo Sep 22, 2024
2e696b1
Add tray icon
Erimelowo Sep 22, 2024
9425378
reorder settings
Erimelowo Sep 22, 2024
4776f89
fix FPS going wild because of division by 0
Erimelowo Sep 22, 2024
f9bbf4c
use int instead of float for configs
Erimelowo Sep 23, 2024
60cde82
code clarity + better nvml init
Erimelowo Sep 23, 2024
2b82906
prevent errors with config
Erimelowo Sep 23, 2024
ab40c57
fix vram, fps and reprojection
Erimelowo Sep 23, 2024
ed29d57
add missing configs in GUI
Erimelowo Sep 23, 2024
b747867
Refactor settings finish them!
Erimelowo Sep 25, 2024
e4fccc4
Add Traypp license
Erimelowo Sep 25, 2024
8cc6ac3
fix res change scales and defaults
Erimelowo Sep 25, 2024
9bbef55
tray show instead of open
Erimelowo Sep 25, 2024
9a7b5c2
Update screenshot.png
Erimelowo Sep 25, 2024
509b0cf
fix resolution capitalization
Erimelowo Sep 25, 2024
8957733
Apply most suggestions from Daniel
Erimelowo Sep 25, 2024
0886586
Simplify dependencies by only using CPM
Erimelowo Sep 26, 2024
85c3c0e
Delete FindOpenVR.cmake
Erimelowo Sep 26, 2024
782efa8
use another way to copy files so that it may not error
Erimelowo Sep 26, 2024
ab06068
Don't copy binary because CI doesn't like it
Erimelowo Sep 26, 2024
0fc48c7
Update .gitignore
Erimelowo Sep 26, 2024
f0fa673
More portable!!! (#34)
lemire Sep 26, 2024
30783c6
give printLine window a name
Erimelowo Sep 26, 2024
a86ce4a
silently restore settings
Erimelowo Sep 26, 2024
efeabdd
Remove auto-start confirmation (non-error) message
Erimelowo Sep 26, 2024
dfcf6d4
Update README.md
Erimelowo Sep 26, 2024
8dc48b0
improve default config
Erimelowo Sep 27, 2024
be1be0b
update manifest
Erimelowo Oct 1, 2024
a5b1ff6
add buttons to pause adjustment and disable current app
Erimelowo Oct 2, 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
[submodule "traypp"]
Erimelowo marked this conversation as resolved.
Show resolved Hide resolved
path = traypp
url = https://github.com/Soundux/traypp.git
31 changes: 18 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
cmake_minimum_required(VERSION 3.17)
cmake_minimum_required(VERSION 3.28)

project(OpenVR-Dynamic-Resolution)
project(OVR-Dynamic-Resolution)

include("${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

## Find dependencies
find_package(fmt CONFIG REQUIRED)
if(WIN32)
find_path(PDC_INCLUDES curses.h)
include_directories(${PDC_INCLUDES})
find_library(CURSES_LIBRARIES pdcurses REQUIRED)
else()
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIRS})
endif()
find_library(OPENVR_LIB openvr_api)

find_package(glfw3 REQUIRED)
find_package(imgui REQUIRED)
set(protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/protos)
file(MAKE_DIRECTORY "${protos_OUTPUT_DIR}")

Expand All @@ -27,8 +21,19 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH $ORIGIN)

# Project
add_executable("${PROJECT_NAME}" "src/main.cpp" "src/pathtools_excerpt.cpp" "src/setup.cpp")
target_link_libraries("${PROJECT_NAME}" PRIVATE "${OPENVR_LIB}" fmt::fmt-header-only ${CURSES_LIBRARIES})
# Set some Win32 Specific Settings
IF(WIN32)
SET(GUI_TYPE WIN32)
ENDIF(WIN32)
# Set some Apple MacOS Specific settings
IF (APPLE)
SET(GUI_TYPE MACOSX_BUNDLE)
ENDIF (APPLE)

add_subdirectory(traypp EXCLUDE_FROM_ALL)
link_libraries(tray)
add_executable("${PROJECT_NAME}" ${GUI_TYPE} "src/main.cpp" "src/pathtools_excerpt.cpp" "src/setup.cpp" "src/lodepng.cpp")
Erimelowo marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries("${PROJECT_NAME}" PRIVATE "${OPENVR_LIB}" fmt::fmt-header-only glfw imgui::imgui)
target_include_directories("${PROJECT_NAME}" PUBLIC ${protos_OUTPUT_DIR} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
Erimelowo marked this conversation as resolved.
Show resolved Hide resolved
target_compile_features("${PROJECT_NAME}" PRIVATE cxx_std_17)

Expand Down
56 changes: 27 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,42 @@

[![Windows build testing](https://github.com/Louka3000/OpenVR-Dynamic-Resolution/actions/workflows/vs17.yml/badge.svg)](https://github.com/Louka3000/OpenVR-Dynamic-Resolution/actions/workflows/vs17.yml)

OpenVR app that dynamically adjusts the HMD's resolution to the GPU frametime, CPU frametime and VRAM.
![screenshot of the app](screenshot.png)

This allows you to always have the maximum resolution your GPU can handle while hitting your target FPS (without reprojecting). Useful for games in which GPU requirement varies a lot (e.g. VRChat).
Lightweight OpenVR app to dynamically adjust your HMD's resolution depending on your GPU frametime, CPU frametime and VRAM.

This is **not** the same as SteamVR's Auto Resolution, which seems to be using some benchmarking approach that does not work for the same as OVRDR.
This allows you to always play at the maximum resolution your GPU can handle while hitting your target FPS (without reprojecting). This is especially useful for games in which performance varies a lot (e.g. VRChat).

Pro tip: if you want a higher resolution (for supersampling), you can lower your HMD's framerate to increase the target frametime.
This is **not** the same as SteamVR's Auto Resolution, which instead seems to be using a kind of benchmarking approach.

**Check out [WorkingGames.md](WorkingGames.md) for a list of working and non-working games.**

## Installation/Using It

**_Make sure SteamVR's Render Resolution is set to Custom_**

- Download the [latest release ](https://github.com/Louka3000/OpenVR-Dynamic-Resolution/releases/latest/download/OpenVR-Dynamic-Resolution.zip)
- Download the [latest release ](https://github.com/Louka3000/OpenVR-Dynamic-Resolution/releases/latest/download/OVR-Dynamic-Resolution.zip)
- Extract the .zip
- Launch `OpenVR-Dynamic-Resolution.exe`
- Launch `OVR-Dynamic-Resolution.exe`

## Settings Descriptions

Settings are found in the `settings.ini` file. Do not rename that file. It should be located in the same folder as your executable file (`OpenVR-Dynamic-Resolution.exe`).
Settings are found in the `settings.ini` file. Do not rename that file. It should be located in the same folder as the executable file (`OpenVR-Dynamic-Resolution.exe`).
*Pro tip: if you want a higher resolution (for supersampling), you can lower your HMD's framerate or set `alwaysReproject` to 1 to increase the target frametime.*

- `autoStart`: (0 = disabled, 1 = enabled) Enabling it will launch the program with SteamVR automatically.

- `minimizeOnStart`: (0 = show, 1 = minimize, 2 = hide) Will automatically minimize or hide the window on launch. If set to 2 (hide), you won't be able to exit the program manually, but it will automatically exit with SteamVR.
- `minimizeOnStart`: (0 = show, 1 = minimize, 2 = hide) Will automatically minimize or hide the window on launch.

- `initialRes`: The resolution the program sets your HMD's resolution when starting. Also the resolution that is targeted in vramOnlyMode.

- `minRes`: The minimum value the program will be allowed to set your HMD's resolution to.

- `maxRes`: The maximum value the program will be allowed to set your HMD's resolution to.

- `dataPullDelayMs`: The time in milliseconds (1000ms = 1s) the program waits to pull and display new information. Adjust dataAverageSamples accordingly.

- `resChangeDelayMs`: The delay in milliseconds (1000ms = 1s) between each resolution change. Lowering it will make the resolution change more responsive, but will cause more stuttering from resolution changes.

- `minCpuTimeThreshold`: Don't increase resolution when CPU time in milliseconds is below this value. Useful to avoid the resolution increasing in the SteamVR void or during loading screens. Also see resetOnThreshold.
- `resIncreaseMin`: How many static % to increase resolution when we have GPU and VRAM headroom.

- `resIncreaseMin`: How many static % to increase resolution when we have GPU or/and VRAM headroom.

- `resDecreaseMin`: How many static % to decrease resolution when GPU frametime or/and VRAM usage is too high.
- `resDecreaseMin`: How many static % to decrease resolution when GPU frametime or VRAM usage is too high.

- `resIncreaseScale`: How much to increase resolution depending on GPU frametime headroom.

Expand All @@ -52,10 +47,16 @@ Settings are found in the `settings.ini` file. Do not rename that file. It shoul

- `resDecreaseThreshold`: Percentage of the target frametime at which the program will stop decreasing resolution

- `dataAverageSamples`: Number of samples to use for the average GPU time. Depends on dataPullDelayMs.
- `dataAverageSamples`: Number of samples to use for the average GPU time. One frame gives one sample.

- `minCpuTimeThreshold`: Don't increase resolution when CPU time in milliseconds is below this value. Useful to avoid the resolution increasing in the SteamVR void or during loading screens. Also see resetOnThreshold.

- `resetOnThreshold`: (0 = disabled, 1 = enabled) Enabling will reset the resolution to initialRes whenever minCpuTimeThreshold is met. Useful if you wanna go from playing a supported game to an unsuported games without having to reset your resolution/the program/SteamVR.

- `ignoreCpuTime`: (0 = disabled, 1 = enabled) Don't use the CPU frametime to adjust resolution.

- `preferReprojection`: (0 = disabled, 1 = enabled) If enabled, the GPU target frametime will double as soon as the CPU frametime is over the target frametime; else, the CPU frametime needs to be 2 times greater than the target frametime for the GPU target frametime to double.

- `alwaysReproject`: (0 = disabled, 1 = enabled) Enabling will double the target frametime, so if you're at a target FPS of 120, it'll target 60. Useful if you have a bad CPU but good GPU.

- `vramTarget`: The target VRAM usage in percents. Once your VRAM usage exceeds this amount, the resolution will stop increasing.
Expand All @@ -66,10 +67,6 @@ Settings are found in the `settings.ini` file. Do not rename that file. It shoul

- `vramOnlyMode`: (0 = disabled, 1 = enabled) Only adjust resolution based off VRAM; ignore GPU and CPU frametimes. Will always stay at initialRes or lower (if VRAM limit is reached).

- `preferReprojection`: (0 = disabled, 1 = enabled) If enabled, the GPU target frametime will double as soon as the CPU frametime is over the target frametime; else, the CPU frametime needs to be 2 times greater than the target frametime for the GPU target frametime to double.

- `ignoreCpuTime`: (0 = disabled, 1 = enabled) Don't use the CPU frametime to adjust resolution.

- `disabledApps`: Space-delimited list of OpenVR application keys that should be ignored for resolution adjustment. Steam games use the format steam.app.APPID, e.g. steam.app.438100 for VRChat and steam.app.620980 for Beat Saber.

## Building from source
Expand All @@ -84,17 +81,18 @@ cmake -B build
cmake --build build --config Release
```

You can then execute the newly built binary by running:

```
.\build\Release\OpenVR-Dynamic-Resolution.exe
```
The newly built binary and its dependencies will be located at `\build\Release\OpenVR-Dynamic-Resolution.exe`.
The `resources` directory contains additional files that are distributed in releases and that you might want.

## Licensing

[BSD 3-Clause License](/LICENSE)

This work is based on [SlimeVR-Feeder-App](https://github.com/SlimeVR/SlimeVR-Feeder-App) which is licensed under the BSD 3-Clause License.
We use the [OpenVR](https://github.com/ValveSoftware/openvr) library which is also available under the BSD 3-Clause License.
Additionally, we use [simpleini](https://github.com/brofield/simpleini) which is available the MIT License.
We also use the [fmt](https://github.com/fmtlib/fmt) library which is available under a Boost-like license.
We also use:
- The [OpenVR](https://github.com/ValveSoftware/openvr) library which is also available under the BSD 3-Clause License.
- [simpleini](https://github.com/brofield/simpleini) which is available the MIT License.
- The [fmt](https://github.com/fmtlib/fmt) library which is available under a Boost-like license.
- [DearImGui](https://github.com/ocornut/imgui) which is available under the MIT license.
- [lodepng](https://github.com/lvandeve/lodepng/blob/master/LICENSE) which is available under the zlib license.
- [Traypp](https://github.com/Soundux/traypp) which is available under the MIT license.
63 changes: 0 additions & 63 deletions resources/SettingsDescription.txt

This file was deleted.

68 changes: 68 additions & 0 deletions resources/ThirdPartyLicenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,71 @@ As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.

---------- Dear ImGui License ----------
The MIT License (MIT)

Copyright (c) 2014-2024 Omar Cornut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---------- lodepng License ----------
Copyright (c) 2005-2018 Lode Vandevenne

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source
distribution.

---------- lodepng License ----------
MIT License

Copyright (c) 2021 Soundux

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added resources/icon.ico
Binary file not shown.
Binary file added resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions resources/manifest.vrmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"source" : "builtin",
"applications": [
{
"app_key": "openvr-dynamic-resolution",
"app_key": "ovr-dynamic-resolution",
"launch_type": "binary",
"binary_path_windows": "OpenVR-Dynamic-Resolution.exe",
"binary_path_windows": "OVR-Dynamic-Resolution.exe",
"is_dashboard_overlay": true,

"strings": {
"en_us": {
"name": "OpenVR Dynamic Resolution",
"name": "OVR Dynamic Resolution",
"description": "Adjusts HMD resolution with frametimes"
}
}
Expand Down
63 changes: 36 additions & 27 deletions resources/settings.ini
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
[Initialization]
autoStart=1
minimizeOnStart=0
initialRes=100

[Resolution change]
minRes=80
maxRes=500
dataPullDelayMs=200
resChangeDelayMs=1800
minCpuTimeThreshold=1.0
resIncreaseMin=3
resDecreaseMin=9
resIncreaseScale=60
resDecreaseScale=90
resIncreaseThreshold=80
resDecreaseThreshold=88
dataAverageSamples=16
resetOnThreshold=1
alwaysReproject=0
vramTarget=80
vramLimit=90
vramMonitorEnabled=1
vramOnlyMode=0
preferReprojection=0
ignoreCpuTime=0
disabledApps=
[Startup]
autoStart = 1
minimizeOnStart = 0


[General]
resChangeDelayMs = 2000
dataAverageSamples = 128
disabledApps = steam.app.620980


[Resolution]
initialRes = 100
minRes = 70
maxRes = 350
resIncreaseThreshold = 80
resDecreaseThreshold = 88
resIncreaseMin = 3
resDecreaseMin = 7
resIncreaseScale = 60
resDecreaseScale = 90
minCpuTimeThreshold = 0.600000
resetOnThreshold = 1


[Reprojection]
alwaysReproject = 0
preferReprojection = 0
ignoreCpuTime = 0


[VRAM]
vramMonitorEnabled = 1
vramOnlyMode = 0
vramTarget = 80
vramLimit = 90
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading