Skip to content

Commit

Permalink
Merge branch 'master' into pd-upscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jul 21, 2024
2 parents da39503 + 2a5f834 commit 838cb85
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ Supports both DirectX 11 and DirectX 12.
* Street Fighter 6
* Monster Hunter Rise
* Dragon's Dogma 2
* Ghosts 'n Goblins Resurrection (Using RE8 build)
* Apollo Justice: Ace Attorney Trilogy (Using DD2 build)
* Kunitsu-Gami: Path of the Goddess (Using DD2 build)

## Thanks
[SkacikPL](https://github.com/SkacikPL) for originally creating the Manual Flashlight mod.
Expand Down
30 changes: 29 additions & 1 deletion src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility/ScopeGuard.hpp>

#include <sdk/TDBVer.hpp>
#include <reframework/API.hpp>

#if TDB_VER <= 49
#include "sdk/regenny/re7/via/Window.hpp"
Expand Down Expand Up @@ -51,6 +52,7 @@
#include "utility/Module.hpp"
#include "utility/Memory.hpp"
#include "utility/Registry.hpp"
#include "utility/ScopeGuard.hpp"

#include "FirstPerson.hpp"
#include "ManualFlashlight.hpp"
Expand Down Expand Up @@ -80,6 +82,18 @@ std::optional<regenny::via::Size> g_previous_size{};

// Purpose: spoof the render target size to the size of the HMD displays
void VR::on_view_get_size(REManagedObject* scene_view, float* result) {
// There are some very dumb optimizations that cause set_DisplayType
// to go through this hook. This function is actually something like "updateSceneView"
static thread_local bool already_inside = false;

if (already_inside) {
return;
}

already_inside = true;

utility::ScopeGuard _{ [&]() { already_inside = false; } };

if (!g_framework->is_ready()) {
return;
}
Expand All @@ -96,7 +110,7 @@ void VR::on_view_get_size(REManagedObject* scene_view, float* result) {
auto window = regenny_view->window;

static auto via_scene_view = sdk::find_type_definition("via.SceneView");
static auto set_display_type_method = via_scene_view->get_method("set_DisplayType");
static auto set_display_type_method = via_scene_view != nullptr ? via_scene_view->get_method("set_DisplayType") : nullptr;

// Force the display to stretch to the window size
if (set_display_type_method != nullptr) {
Expand Down Expand Up @@ -211,11 +225,25 @@ void VR::on_view_get_size(REManagedObject* scene_view, float* result) {
// spoof the size to the HMD's size
if (!TemporalUpscaler::get()->activated()) {
if (!is_using_multipass()) {
#if TDB_VER < 73
result[0] = wanted_width;
result[1] = wanted_height;
#else
// Stupid optimizations cause the game to not use the result variant of this function
// but rather update the current scene view's size directly.
regenny_view->size.w = wanted_width;
regenny_view->size.h = wanted_height;
#endif
} else {
#if TDB_VER < 73
result[0] = wanted_width - 1.0f;
result[1] = wanted_height - 1.0f;
#else
// Stupid optimizations cause the game to not use the result variant of this function
// but rather update the current scene view's size directly.
regenny_view->size.w = wanted_width - 1.0f;
regenny_view->size.h = wanted_height - 1.0f;
#endif
}
}
}
Expand Down

0 comments on commit 838cb85

Please sign in to comment.