Detanup01 / gbe_fork

Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
https://gitlab.com/Mr_Goldberg/goldberg_emulator
GNU Lesser General Public License v3.0
316 stars 63 forks source link

Update Overlay project #81

Closed Detanup01 closed 3 weeks ago

Detanup01 commented 1 month ago

Might fix overlay related stuff

Detanup01 commented 1 month ago

eh, It needs to compress into .tar.gz :/

Detanup01 commented 1 month ago

@Sak32009 how the hell did you compressed it? I tried linux VM with command "tar -cvf ingame_overlay.tar.gz ingame_overlay" I tried on Windows with 7z, and still not resulting the same.

Sak32009 commented 1 month ago

I used 7zip on windows, for linux i think it's right like this:

tar -zcvf ingame_overlay.tar.gz ingame_overlay/

Detanup01 commented 1 month ago

Any specific setting for 7z tar on win?

alex47exe commented 1 month ago

Not sure about the command-line arguments to create it in one go, but basically you have to first create a .tar archive then create a .gzip archive containing only the previously created .tar archive

Sak32009 commented 1 month ago

@Detanup01 follow what @alex47exe said

Detanup01 commented 1 month ago

thanks

otavepto commented 1 month ago

hmmm the new ingame_overlay project is way different than before, the public functions signatures are different and even some are entirely replaced, also now by default it links against the non-static version of the C/C++ runtime, meaning unless you change it's CMake flags the emu's import table will contain stuff like vcruntime.dll which will introduce dependency problems on different versions of Windows (if it even compiled since we use /MT).

I'm surprised the project even compiled, are you sure you invalidated/removed the current deps cache?

otavepto commented 1 month ago

some examples:

StartHook takes an array of keys instead of a hash set https://github.com/Nemirtingas/ingame_overlay/blob/f819c89e3b59dd7704eea8148c40c9f9be52284e/include/InGameOverlay/RendererHook.h#L92

GetLibraryName returns C-style char array instead of std::string https://github.com/Nemirtingas/ingame_overlay/blob/f819c89e3b59dd7704eea8148c40c9f9be52284e/include/InGameOverlay/RendererHook.h#L124

to create an image resource (achievements icons) you have to call this new API instead of the old one, which now returns a class pointer RendererResource_t* instead of std::weak_pointer https://github.com/Nemirtingas/ingame_overlay/blob/f819c89e3b59dd7704eea8148c40c9f9be52284e/include/InGameOverlay/RendererHook.h#L178

Edremon commented 1 month ago

I have been using a newer version (c42f3e3) of ingame_overlay for a while now. Everything works correctly and overlay now work using wine+dxvk on linux. This commit doesn't include the change listed by @otavepto.

Currently, CI is still using the old version, git submodule wasn't updated and still point at old commit of deps. That why it doesn't error like @otavepto expected.

ndiruhniu commented 1 month ago

@Edremon

I just tried it. Doesn't work. Do you have an Nvidia graphics card? I have: Linux Mint 22 AMD RX 6600 Wine 9.20 DXVK 2.4.1. Overlay only works in dx12 and opengl games.

Edremon commented 1 month ago

Have you rebuilt gbe with a newer version of ingame_overlay that include dxvk fix?

ndiruhniu commented 1 month ago

I use this.

Edremon commented 1 month ago

Yes, this still use old version, see this https://github.com/Detanup01/gbe_fork/issues/48#issuecomment-2466487153

ndiruhniu commented 1 month ago

Where can I get the updated version?

Edremon commented 1 month ago

Well, you update the dependency either to a version before breaking change or to the latest and adapt signature changes then rebuild the emulator. If you are asking this question, you probably don't know how to do that, just wait for someone to properly update it.

alex47exe commented 1 month ago

https://github.com/Nemirtingas/ingame_overlay/tree/master

Though if you have git installed, it is better to download it all in one go, including submodules, using: git clone --recurse-submodules https://github.com/Nemirtingas/ingame_overlay.git

ndiruhniu commented 1 month ago

Got it, thank you.

Edremon commented 3 weeks ago

Tried to update to latest version of ingame_overlay but I got some annoying linking issues, for some reason ingame_overlay doesn't build statically correctly. Below are gbe change, although untested.

diff --git a/overlay_experimental/overlay/steam_overlay.h b/overlay_experimental/overlay/steam_overlay.h
index 467a170c..6a09673d 100644
--- a/overlay_experimental/overlay/steam_overlay.h
+++ b/overlay_experimental/overlay/steam_overlay.h
@@ -71,8 +71,8 @@ struct Overlay_Achievement
     bool hidden{};
     bool achieved{};
     uint32 unlock_time{};
-    std::weak_ptr<uint64_t> icon{};
-    std::weak_ptr<uint64_t> icon_gray{};
+    InGameOverlay::RendererResource_t* icon{};
+    InGameOverlay::RendererResource_t* icon_gray{};
     int icon_handle = Settings::UNLOADED_IMAGE_HANDLE;
     int icon_gray_handle = Settings::UNLOADED_IMAGE_HANDLE;
 };
diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp
index 107c3477..c66d5dc6 100644
--- a/overlay_experimental/steam_overlay.cpp
+++ b/overlay_experimental/steam_overlay.cpp
@@ -32,9 +32,8 @@ static constexpr int base_notif_window_id  = 0 * max_window_id;
 static constexpr int base_friend_window_id = 1 * max_window_id;
 static constexpr int base_friend_item_id   = 2 * max_window_id;

-static const std::set<InGameOverlay::ToggleKey> overlay_toggle_keys = {
-    InGameOverlay::ToggleKey::SHIFT, InGameOverlay::ToggleKey::TAB
-};
+static InGameOverlay::ToggleKey overlay_toggle_keys[] = {InGameOverlay::ToggleKey::SHIFT, InGameOverlay::ToggleKey::TAB};
+static const int toggle_keys_count = 2;

 // look for the column 'API language code' here: https://partner.steamgames.com/doc/store/localization/languages
 static constexpr const char* valid_languages[] = {
@@ -203,7 +202,7 @@ bool Steam_Overlay::renderer_hook_proc()
         PRINT_DEBUG("renderer hook was null!");
         return true;
     }
-    PRINT_DEBUG("got renderer hook %p for '%s'", _renderer, _renderer->GetLibraryName().c_str());
+    PRINT_DEBUG("got renderer hook %p for '%s'", _renderer, _renderer->GetLibraryName());

     // note: make sure to load all relevant strings before creating the font(s), otherwise some glyphs ranges will be missing
     load_achievements_data();
@@ -218,7 +217,7 @@ bool Steam_Overlay::renderer_hook_proc()
         overlay_state_hook(state == InGameOverlay::OverlayHookState::Ready || state == InGameOverlay::OverlayHookState::Reset);
     };

-    bool started = _renderer->StartHook(overlay_toggle_callback, overlay_toggle_keys, &fonts_atlas);
+    bool started = _renderer->StartHook(overlay_toggle_callback, overlay_toggle_keys, toggle_keys_count, &fonts_atlas);
     PRINT_DEBUG("started renderer hook (result=%i)", (int)started);

     return true;
@@ -1057,13 +1056,13 @@ void Steam_Overlay::build_notifications(float width, float height)
                     auto &icon_rsrc = (notification_type)it->type == notification_type::achievement
                         ? ach.icon
                         : ach.icon_gray;
-                    if (!icon_rsrc.expired() && ImGui::BeginTable("imgui_table", 2)) {
+                    if (icon_rsrc->IsLoaded() && ImGui::BeginTable("imgui_table", 2)) {
                         ImGui::TableSetupColumn("imgui_table_image", ImGuiTableColumnFlags_WidthFixed, settings->overlay_appearance.icon_size);
                         ImGui::TableSetupColumn("imgui_table_text");
                         ImGui::TableNextRow(ImGuiTableRowFlags_None, settings->overlay_appearance.icon_size);

                         ImGui::TableSetColumnIndex(0);
-                        ImGui::Image((ImTextureID)*icon_rsrc.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size));
+                        ImGui::Image((ImTextureID)icon_rsrc->GetResourceId(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size));

                         ImGui::TableSetColumnIndex(1);
                         ImGui::TextWrapped("%s", it->message.c_str());
@@ -1208,7 +1207,7 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved, b
     if (!settings->overlay_upload_achs_icons_to_gpu) return false; // don't upload anything to the GPU

     auto &icon_rsrc = achieved ? ach.icon : ach.icon_gray;
-    if (!icon_rsrc.expired()) return true;
+    if (icon_rsrc->IsLoaded()) return true;

     // icons needs to be loaded, but we're not allowed
     if (!upload_new_icon_to_gpu) return false;
@@ -1220,14 +1219,14 @@ bool Steam_Overlay::try_load_ach_icon(Overlay_Achievement &ach, bool achieved, b
     auto image_info = settings->get_image(icon_handle);
     if (image_info) {
         int icon_size = static_cast<int>(settings->overlay_appearance.icon_size);
-        icon_rsrc = _renderer->CreateImageResource(
+        icon_rsrc = _renderer->CreateAndLoadResource(
             (void*)image_info->data.c_str(),
-            icon_size, icon_size);
+            icon_size, icon_size, true);

-        PRINT_DEBUG("'%s' (result=%i)", ach.name.c_str(), (int)!icon_rsrc.expired());
+        PRINT_DEBUG("'%s' (result=%i)", ach.name.c_str(), (int)icon_rsrc->IsLoaded());
     }

-    return !icon_rsrc.expired();
+    return icon_rsrc->IsLoaded();
 }

 // Try to make this function as short as possible or it might affect game's fps.
@@ -1325,7 +1324,7 @@ uint32 Steam_Overlay::apply_global_style_color()
 void Steam_Overlay::render_main_window()
 {
     char tmp[TRANSLATION_BUFFER_SIZE]{};
-    snprintf(tmp, sizeof(tmp), translationRenderer[current_language], (_renderer == nullptr ? "Unknown" : _renderer->GetLibraryName().c_str()));
+    snprintf(tmp, sizeof(tmp), translationRenderer[current_language], (_renderer == nullptr ? "Unknown" : _renderer->GetLibraryName()));
     std::string windowTitle{};
     // Note: don't translate this, project and author names are nouns, they must be kept intact for proper referral
     // think of it as translating "Protobuf - Google"
@@ -1432,7 +1431,7 @@ void Steam_Overlay::render_main_window()
                     ImGui::Separator();

                     bool could_create_ach_table_entry = false;
-                    if (!x.icon.expired() || !x.icon_gray.expired()) {
+                    if (x.icon->IsLoaded() || x.icon_gray->IsLoaded()) {
                         if (ImGui::BeginTable(x.title.c_str(), 2)) {
                             could_create_ach_table_entry = true;

@@ -1442,9 +1441,9 @@ void Steam_Overlay::render_main_window()

                             ImGui::TableSetColumnIndex(0);
                             auto &icon_rsrc = achieved ? x.icon : x.icon_gray;
-                            if (!icon_rsrc.expired()) {
+                            if (icon_rsrc->IsLoaded()) {
                                 ImGui::Image(
-                                    (ImTextureID)*icon_rsrc.lock().get(),
+                                    (ImTextureID)icon_rsrc->GetResourceId(),
                                     ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)
                                 );
                             }
@@ -1667,14 +1666,12 @@ void Steam_Overlay::UnSetupOverlay()

             PRINT_DEBUG("releasing any images resources");
             for (auto &ach : achievements) {
-                if (!ach.icon.expired()) {
-                    _renderer->ReleaseImageResource(ach.icon);
-                    ach.icon.reset();
+                if (ach.icon->IsLoaded()) {
+                    ach.icon->Unload();
                 }

-                if (!ach.icon_gray.expired()) {
-                    _renderer->ReleaseImageResource(ach.icon_gray);
-                    ach.icon_gray.reset();
+                if (ach.icon_gray->IsLoaded()) {
+                    ach.icon_gray->Unload();
                 }
             }

diff --git a/premake5-deps.lua b/premake5-deps.lua
index 40d4a0e1..108ac6cd 100644
--- a/premake5-deps.lua
+++ b/premake5-deps.lua
@@ -694,6 +694,7 @@ if _OPTIONS["build-ingame_overlay"] or _OPTIONS["all-build"] then

     local ingame_overlay_common_defs = {
         'IMGUI_USER_CONFIG="' .. overaly_imgui_cfg_file:gsub('\\', '/') .. '"', -- ensure we use '/' because this lib doesn't handle it well
+        'INGAMEOVERLAY_DYNAMIC_RUNTIME=OFF',
         'INGAMEOVERLAY_USE_SYSTEM_LIBRARIES=OFF',
         'INGAMEOVERLAY_USE_SPDLOG=OFF',
         'INGAMEOVERLAY_BUILD_TESTS=OFF',

On a side note, .editorconfig have trim_trailing_whitespace = true but almost all files have plenty of trailing whitespace making anyone that edit a file with an editor respecting editorconfig have a huge diff to remove all of those, I suggest either remove all trailing whitespace or removing that from editorconfig.

Detanup01 commented 3 weeks ago

Cant build bc of : AArch64Disassembler.obj : warning LNK4006: __check_isa_support already defined in AArch64InstPrinter.obj;

debugzxcv commented 3 weeks ago

Tried to update to latest version of ingame_overlay but I got some annoying linking issues, for some reason ingame_overlay doesn't build statically correctly.

Need change these variable reference:

https://github.com/Nemirtingas/ingame_overlay/blob/f819c89e3b59dd7704eea8148c40c9f9be52284e/CMakeLists.txt#L207 https://github.com/Nemirtingas/mini_detour/blob/0cc6973be87ae12bbbe16ab4bf89f92154f5f0ea/CMakeLists.txt#L127C3-L127C23 https://github.com/Nemirtingas/System/blob/b1fcc11059381d5a013b86f01371de67ae4ee843/CMakeLists.txt#L63

https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variable-references https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:BOOL

Edremon commented 3 weeks ago

Need change these variable reference:

https://github.com/Nemirtingas/ingame_overlay/blob/f819c89e3b59dd7704eea8148c40c9f9be52284e/CMakeLists.txt#L207 https://github.com/Nemirtingas/mini_detour/blob/0cc6973be87ae12bbbe16ab4bf89f92154f5f0ea/CMakeLists.txt#L127C3-L127C23 https://github.com/Nemirtingas/System/blob/b1fcc11059381d5a013b86f01371de67ae4ee843/CMakeLists.txt#L63

https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variable-references https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:BOOL

Why? MSVC_RUNTIME_LIBRARY is being set to "MultiThreaded" which is what is expected for a static build.

MultiThreaded Compile with -MT or equivalent flag(s) to use a multi-threaded statically-linked runtime library.

It's just that for whatever reason it's getting changed to '/MD'.

cl : Command line warning D9025 : overriding '/MT' with '/MD'

debugzxcv commented 3 weeks ago

Need change these variable reference: https://github.com/Nemirtingas/ingame_overlay/blob/f819c89e3b59dd7704eea8148c40c9f9be52284e/CMakeLists.txt#L207 https://github.com/Nemirtingas/mini_detour/blob/0cc6973be87ae12bbbe16ab4bf89f92154f5f0ea/CMakeLists.txt#L127C3-L127C23 https://github.com/Nemirtingas/System/blob/b1fcc11059381d5a013b86f01371de67ae4ee843/CMakeLists.txt#L63 https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variable-references https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:BOOL

Why? MSVC_RUNTIME_LIBRARY is being set to "MultiThreaded" which is what is expected for a static build.

MultiThreaded Compile with -MT or equivalent flag(s) to use a multi-threaded statically-linked runtime library.

It's just that for whatever reason it's getting changed to '/MD'.

cl : Command line warning D9025 : overriding '/MT' with '/MD'

"MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:INGAMEOVERLAY_DYNAMIC_RUNTIME>:DLL>" should be "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${INGAMEOVERLAY_DYNAMIC_RUNTIME}>:DLL>"

otavepto commented 3 weeks ago

This commit contains all the new fixes/changes but without the new forced dynamic linking stuff: https://github.com/Nemirtingas/ingame_overlay/tree/18533f6f54171330262222645407cf6382d61b80

If you decided to use it you'll need the changes by @Edremon mentioned above.

alex47exe commented 3 weeks ago

@debugzxcv ... tried to build the emu with the latest ingame_overlay, the modifications on your fork and also the required CMakeLists.txt changes, but now I seem to be getting this error: CMake Error: The source directory "D:/a/gse_fork/gse_fork/build/deps/win/vs2022/ingame_overlay/deps/System" does not appear to contain CMakeLists.txt. Not sure why it happens, as CMakeLists.txt is present there. Any idea what I am missing? Thanks. https://github.com/alex47exe/gse_fork/actions/runs/11873201514/job/33087777779

debugzxcv commented 3 weeks ago

@debugzxcv ... tried to build the emu with the latest ingame_overlay, the modifications on your fork and also the required CMakeLists.txt changes, but now I seem to be getting this error: CMake Error: The source directory "D:/a/gse_fork/gse_fork/build/deps/win/vs2022/ingame_overlay/deps/System" does not appear to contain CMakeLists.txt. Not sure why it happens, as CMakeLists.txt is present there. Any idea what I am missing? Thanks. https://github.com/alex47exe/gse_fork/actions/runs/11873201514/job/33087777779

your ingame_overlay.tar.gz archive folder structure incorrect

check this https://github.com/debugzxcv/Detanup01/commit/6ec90dbbabee662f2c1c51ba119a5607baca7abd

alex47exe commented 3 weeks ago

Thanks to @debugzxcv, @Edremon, @otavepto & @Nemirtingas, managed to finally build a working version of the emu with properly updated ingame_overlay up to this commit. Haven't yet tested it with a lot of games, but overlay now seems to work correctly on some games that previously had issues with it. Here's the release if you want to test it. As usual with my fork, just download generate_emu_config and run the 'user' exe to generate the complete config for your desired game.

Detanup01 commented 3 weeks ago

Added latest overlay thanks to Nemirtingas and debugzxcv! Added also the latest 1.61 things, Hope and pray the build works

Sak32009 commented 3 weeks ago

@Detanup01 Check the "third-party/deps/common" branch, you made a mistake.

Detanup01 commented 3 weeks ago

Ah ye, Now! should be proper

Detanup01 commented 3 weeks ago

forgot the overlay_toggle_keys const thing, but the deps should be good now!

Detanup01 commented 3 weeks ago

Seems error are github runners issue.

work: Image: windows-2022 Version: 20241113.3.0

Not work: Image: windows-2022 Version: 20241021.1.0

20241021.1.0 : MSVC 14.40.33816 20241113.3.0 : MSVC 14.42.34433

Cant release and such because any time it could just get an old version of image.