From 1eed8a2a86c9343c596bb64661982af2feb16562 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 24 Sep 2023 21:27:55 +1000 Subject: [PATCH] Achievements: Fix UI crash with DX11 --- pcsx2/Achievements.cpp | 15 ++++++++------- pcsx2/ImGui/ImGuiFullscreen.cpp | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pcsx2/Achievements.cpp b/pcsx2/Achievements.cpp index 97bfa45ec1..6c9d604f3b 100644 --- a/pcsx2/Achievements.cpp +++ b/pcsx2/Achievements.cpp @@ -21,6 +21,7 @@ #include "CDVD/CDVD.h" #include "Elfheader.h" #include "Host.h" +#include "GS/Renderers/Common/GSTexture.h" #include "ImGui/FullscreenUI.h" #include "ImGui/ImGuiFullscreen.h" #include "ImGui/ImGuiManager.h" @@ -1881,7 +1882,7 @@ void Achievements::DrawGameOverlays() GSTexture* badge = ImGuiFullscreen::GetCachedTextureAsync(indicator.badge_path.c_str()); if (badge) { - dl->AddImage(badge, current_position, current_position + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), col); + dl->AddImage(badge->GetNativeHandle(), current_position, current_position + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), col); current_position.x -= x_advance; } @@ -1921,7 +1922,7 @@ void Achievements::DrawGameOverlays() if (badge) { const ImVec2 badge_pos = box_min + ImVec2(padding, padding); - dl->AddImage(badge, badge_pos, badge_pos + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), col); + dl->AddImage(badge->GetNativeHandle(), badge_pos, badge_pos + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), col); } const ImVec2 text_pos = box_min + ImVec2(padding + image_size.x + spacing, (box_max.y - box_min.y - text_size.y) * 0.5f); @@ -2019,7 +2020,7 @@ void Achievements::DrawPauseMenuOverlays() if (!badge) continue; - dl->AddImage(badge, position, position + image_size); + dl->AddImage(badge->GetNativeHandle(), position, position + image_size); const char* achievement_title = indicator.achievement->title; const char* achievement_title_end = achievement_title + std::strlen(indicator.achievement->title); @@ -2110,7 +2111,7 @@ void Achievements::DrawAchievementsWindow() if (badge) { ImGui::GetWindowDrawList()->AddImage( - badge, icon_min, icon_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255)); + badge->GetNativeHandle(), icon_min, icon_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255)); } } @@ -2273,7 +2274,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo) if (badge) { ImGui::GetWindowDrawList()->AddImage( - badge, bb.Min, bb.Min + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255)); + badge->GetNativeHandle(), bb.Min, bb.Min + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255)); } } @@ -2421,7 +2422,7 @@ void Achievements::DrawLeaderboardsWindow() if (badge) { ImGui::GetWindowDrawList()->AddImage( - badge, icon_min, icon_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255)); + badge->GetNativeHandle(), icon_min, icon_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255)); } } @@ -2712,7 +2713,7 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent if (icon_tex) { ImGui::GetWindowDrawList()->AddImage( - reinterpret_cast(icon_tex), icon_bb.Min, icon_bb.Min + ImVec2(icon_size, icon_size)); + icon_tex->GetNativeHandle(), icon_bb.Min, icon_bb.Min + ImVec2(icon_size, icon_size)); } const ImRect user_bb(ImVec2(text_start_x + column_spacing + icon_size, bb.Min.y), ImVec2(bb.Max.x, midpoint)); diff --git a/pcsx2/ImGui/ImGuiFullscreen.cpp b/pcsx2/ImGui/ImGuiFullscreen.cpp index d8d43100d2..dc3a55fa14 100644 --- a/pcsx2/ImGui/ImGuiFullscreen.cpp +++ b/pcsx2/ImGui/ImGuiFullscreen.cpp @@ -2512,7 +2512,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing) GSTexture* tex = GetCachedTexture(notif.badge_path.c_str()); if (tex) { - dl->AddImage(tex, badge_min, badge_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), + dl->AddImage(tex->GetNativeHandle(), badge_min, badge_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, opacity)); } }