Skip to content

Commit

Permalink
UI Compat: Fix case where ViewFamilyTexture could sometimes not be seen
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Feb 14, 2024
1 parent 3997108 commit 25c405a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/CommitHash.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#define UEVR_COMMIT_HASH "ef68b854db04abe74cf577f4d4a5a8c1a7e448fb"
#define UEVR_BUILD_DATE "12.02.2024"
#define UEVR_COMMIT_HASH "3997108934a41fdbb1c6a6e8ff59d7fcd63362ac"
#define UEVR_BUILD_DATE "13.02.2024"
#define UEVR_BUILD_TIME "00:00"
33 changes: 24 additions & 9 deletions src/mods/vr/FFakeStereoRenderingHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,7 @@ FRHITexture2D** FFakeStereoRenderingHook::viewport_get_render_target_texture_hoo
const auto retaddr = (uintptr_t)_ReturnAddress();
static std::unordered_set<uintptr_t> redirected_retaddrs{};
static std::unordered_set<uintptr_t> call_original_retaddrs{};
static std::unordered_set<uintptr_t> seen_retaddrs{};
static std::recursive_mutex retaddr_mutex{};
static bool has_view_family_tex{false};

Expand All @@ -1744,22 +1745,20 @@ FRHITexture2D** FFakeStereoRenderingHook::viewport_get_render_target_texture_hoo

{
std::scoped_lock _{retaddr_mutex};
utility::ScopeGuard guard{[&](){ seen_retaddrs.insert(retaddr); }};

if (call_original_retaddrs.contains(retaddr)) {
return og(viewport);
}

// Hacky way to allow the first texture to go through
// For the games that are using something other than ViewFamilyTexture as the scene RT.
if (!call_original_retaddrs.empty() && !redirected_retaddrs.contains(retaddr) && !has_view_family_tex) {
return og(viewport);
}
std::optional<size_t> func_start{};

if (!redirected_retaddrs.contains(retaddr) && !call_original_retaddrs.contains(retaddr)) {
// ALWAYS check the retaddr for ViewFamilyTexture first and never skip it
// This will fix the case where we run into some other texture initially.
if (!seen_retaddrs.contains(retaddr)) {
SPDLOG_INFO("FViewport::GetRenderTargetTexture called from {:x}", retaddr);

// Analyze surrounding code to determine if this is a valid call.
auto func_start = utility::find_function_start(retaddr);

func_start = utility::find_function_start(retaddr);

if (!func_start) {
func_start = retaddr;
Expand All @@ -1774,6 +1773,22 @@ FRHITexture2D** FFakeStereoRenderingHook::viewport_get_render_target_texture_hoo
has_view_family_tex = true;
return og(viewport);
}
}

// Hacky way to allow the first texture to go through
// For the games that are using something other than ViewFamilyTexture as the scene RT.
if (!call_original_retaddrs.empty() && !redirected_retaddrs.contains(retaddr) && !has_view_family_tex) {
return og(viewport);
}

if (!redirected_retaddrs.contains(retaddr) && !call_original_retaddrs.contains(retaddr)) {
if (!func_start) {
func_start = utility::find_function_start(retaddr);

if (!func_start) {
func_start = retaddr;
}
}

// Probably NOT...
/*if (utility::find_string_reference_in_path(*func_start, L"r.RHICmdAsyncRHIThreadDispatch")) {
Expand Down

0 comments on commit 25c405a

Please sign in to comment.