Skip to content

Commit

Permalink
Fixed potential crash at exit in D3D12 games
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Jan 2, 2025
1 parent b7b53dd commit cd79b2c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
25.1.2.1
25.1.2.2
========
+ Fixed potential crash at exit in D3D12 games.

25.1.2.1
========
+ Re-enable anti-cheat workarounds for various Asian gambling games.

Expand Down
4 changes: 2 additions & 2 deletions include/SpecialK/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#define SK_YEAR 25
#define SK_MONTH 1
#define SK_DATE 2
#define SK_REV_N 1
#define SK_REV 1
#define SK_REV_N 2
#define SK_REV 2

#ifndef _A2
#define _A2(a) #a
Expand Down
7 changes: 5 additions & 2 deletions include/imgui/imgui_user.inl
Original file line number Diff line number Diff line change
Expand Up @@ -3285,11 +3285,14 @@ SK_ImGui_BackupInputThread (LPVOID)
static LASTINPUTINFO
lii = { sizeof (LASTINPUTINFO), 1 };

DWORD dwLastInput = lii.dwTime;

static DWORD dwLastInput =
lii.dwTime;
if (!GetLastInputInfo (&lii) ||
lii.dwTime != dwLastInput)
{
dwLastInput =
std::max (dwLastInput, lii.dwTime);

auto& io =
ImGui::GetIO ();

Expand Down
31 changes: 20 additions & 11 deletions src/control_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2022,10 +2022,19 @@ SK_Display_ResolutionSelectUI (bool bMarkDirty)
config.utility.save_async ();
}

ImGui::SetItemTooltip (
"Covers secondary monitors with a black window to reduce distractions "
"while playing games."
);
if (ImGui::BeginItemTooltip ( ))
{
ImGui::TextUnformatted (
"Covers secondary monitors with a black window to reduce distractions "
"while playing this game.");
ImGui::Separator ( );
ImGui::Spacing ( );
ImGui::Spacing ( );
ImGui::Spacing ( );
ImGui::SameLine ( );
ImGui::BulletText ("This has a Display Management Keybind.");
ImGui::EndTooltip ( );
}

if (! config.display.focus_mode)
ImGui::BeginDisabled ();
Expand Down Expand Up @@ -7651,13 +7660,13 @@ SK_ImGui_StageNextFrame (void)
widget->setActive (true);
}

extern bool SK_Tobii_IsCursorVisible (void);

if ( widget->isVisible () ||
// Tobii widget needs to be drawn to show its cursor
( widget == SK_ImGui_Widgets->tobii &&
SK_Tobii_IsCursorVisible () )
)
//extern bool SK_Tobii_IsCursorVisible (void);
//
if ( widget->isVisible () )
// // Tobii widget needs to be drawn to show its cursor
// ( widget == SK_ImGui_Widgets->tobii &&
// SK_Tobii_IsCursorVisible () )
// )
{
widget->draw_base ();
}
Expand Down
2 changes: 1 addition & 1 deletion src/imgui/backends/imgui_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ D3D12GraphicsCommandList_CopyResource_Detour (
D3D12GraphicsCommandList_CopyResource_Original (
This, pDstResource, pSrcResource
);
}
}

//extern void
//SK_D3D12_CopyTexRegion_Dump (ID3D12GraphicsCommandList* This, ID3D12Resource* pResource, const wchar_t *wszName = nullptr);
Expand Down
3 changes: 1 addition & 2 deletions src/input/hid_reports/playstation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2435,8 +2435,7 @@ SK_HID_PlayStationDevice::request_input_report (void)
}
}

if (ReadAcquire (&pDevice->bNeedOutput))
pDevice->write_output_report ();
pDevice->write_output_report ();

for ( auto& button : pDevice->buttons )
{
Expand Down
12 changes: 7 additions & 5 deletions src/render/d3d12/d3d12_command_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@ D3D12CommandQueue_ExecuteCommandLists_Detour (
UINT NumCommandLists,
ID3D12CommandList* const *ppCommandLists )
{
if (ReadAcquire (&__SK_DLL_Ending) == 0)
return;

SK_RenderBackend_V2 &rb =
SK_GetCurrentRenderBackend ();

D3D12_COMMAND_QUEUE_DESC
queueDesc = This->GetDesc ();

static volatile LONG once = FALSE;
static volatile LONG once = FALSE;
static DWORD search_start_time = SK_timeGetTime ();
static ULONG64 first_frame_examined = SK_GetFramesDrawn ();

if ( queueDesc.Type == D3D12_COMMAND_LIST_TYPE_DIRECT &&
rb.d3d12.command_queue.p == nullptr &&
pLazyD3D12Chain != nullptr &&
pLazyD3D12Device != nullptr )
pLazyD3D12Device != nullptr && SK_GetFramesDrawn () < 50 )
{
static DWORD search_start_time = SK_timeGetTime ();
static ULONG64 first_frame_examined = SK_GetFramesDrawn ();

// Start marking all the backbuffers this command queue writes to,
// then after enough frames have been presented, check if it has
// written to every buffer... if it has, it's probably our queue.
Expand Down

0 comments on commit cd79b2c

Please sign in to comment.