Skip to content

Commit e57dcdb

Browse files
committed
SDK (Renderer): Possible copy_texture fix (untested)
1 parent f8061df commit e57dcdb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

shared/sdk/Renderer.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ void RenderContext::copy_texture(Texture* dest, Texture* src, Fence& fence) {
782782
return;
783783
#else*/
784784

785+
#if TDB_VER < 82
785786
using CopyTexFn = void (*)(RenderContext*, Texture*, Texture*, Fence&);
786787
static auto func = []() -> CopyTexFn {
787788
spdlog::info("Searching for RenderContext::copy_texture");
@@ -866,6 +867,35 @@ void RenderContext::copy_texture(Texture* dest, Texture* src, Fence& fence) {
866867
}();
867868

868869
func(this, dest, src, fence);
870+
#else
871+
using CopyTexFn = void (*)(RenderContext*, Texture*, void*, Texture*, void*, Fence&);
872+
static auto func = []() -> CopyTexFn {
873+
spdlog::info("Searching for RenderContext::copy_texture (>= TDB82)");
874+
875+
const auto game = utility::get_executable();
876+
// constants 0x301 (the typeid 1 or'd with something) 0x36, 0x3f, 0x2a.
877+
const auto mid_result = utility::scan(game, "01 03 00 00 *[64] 36 *[32] 3f *[32] 2a");
878+
879+
if (!mid_result) {
880+
spdlog::error("Failed to find copy_texture (>= TDB82)");
881+
return nullptr;
882+
}
883+
884+
const auto fn_start = utility::find_function_start_unwind(*mid_result);
885+
886+
if (!fn_start) {
887+
spdlog::error("Failed to find copy_texture function start (>= TDB82)");
888+
return nullptr;
889+
}
890+
891+
spdlog::info("Found copy_texture (>= TDB82) at {:x}", *fn_start);
892+
893+
return (CopyTexFn)*fn_start;
894+
}();
895+
896+
// src, src_subresource, dst, dst_subresource, fence
897+
func(this, src, nullptr, dest, nullptr, fence);
898+
#endif
869899
//#endif
870900
}
871901

0 commit comments

Comments
 (0)