Skip to content

Commit

Permalink
System: Required changes for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jan 19, 2025
1 parent e1cbb50 commit 9b8d2a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/core/gpu_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ bool GPUThread::SleepGPUThread(bool allow_sleep)
void GPUThread::Internal::GPUThreadEntryPoint()
{
s_state.gpu_thread = Threading::ThreadHandle::GetForCallingThread();
std::atomic_thread_fence(std::memory_order_release);

// Take a local copy of the FIFO, that way it's not ping-ponging between the threads.
u8* const command_fifo_data = s_state.command_fifo_data.get();
Expand Down Expand Up @@ -521,6 +522,8 @@ void GPUThread::Internal::GPUThreadEntryPoint()

s_state.command_fifo_read_ptr.store(read_ptr, std::memory_order_release);
}

s_state.gpu_thread = {};
}

void GPUThread::Internal::DoRunIdle()
Expand Down
19 changes: 10 additions & 9 deletions src/core/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,14 @@ bool System::CPUThreadInitialize(Error* error, u32 async_worker_thread_count)
}
#endif

s_state.cpu_thread_handle = Threading::ThreadHandle::GetForCallingThread();
s_state.async_task_queue.SetWorkerCount(async_worker_thread_count);

// This will call back to Host::LoadSettings() -> ReloadSources().
LoadSettings(false);

LogStartupInformation();

s_state.async_task_queue.SetWorkerCount(async_worker_thread_count);

GPUThread::Internal::ProcessStartup();

if (g_settings.achievements_enabled)
Expand All @@ -545,6 +546,7 @@ void System::CPUThreadShutdown()
InputManager::CloseSources();

s_state.async_task_queue.SetWorkerCount(0);
s_state.cpu_thread_handle = {};

#ifdef _WIN32
CoUninitialize();
Expand All @@ -556,6 +558,11 @@ const Threading::ThreadHandle& System::GetCPUThreadHandle()
return s_state.cpu_thread_handle;
}

void System::SetCPUThreadHandle(Threading::ThreadHandle handle)
{
s_state.cpu_thread_handle = std::move(handle);
}

void System::IdlePollUpdate()
{
InputManager::PollSources();
Expand Down Expand Up @@ -1930,8 +1937,6 @@ bool System::Initialize(std::unique_ptr<CDImage> disc, DiscRegion disc_region, b
SIO::Initialize();
PCDrv::Initialize();

s_state.cpu_thread_handle = Threading::ThreadHandle::GetForCallingThread();

UpdateGTEAspectRatio();
UpdateThrottlePeriod();
UpdateMemorySaveStateSettings();
Expand Down Expand Up @@ -4230,17 +4235,13 @@ bool System::CheckForRequiredSubQ(Error* error)
return true;
}
}
#ifndef __ANDROID__

Error::SetStringFmt(
error,
TRANSLATE_FS("System", "You are attempting to run a libcrypt protected game without an SBI file:\n\n{0}: "
"{1}\n\nYour dump is incomplete, you must add the SBI file to run this game. \n\nThe "
"name of the SBI file must match the name of the disc image."),
s_state.running_game_serial, s_state.running_game_title);
#else
// Shorter because no confirm messages.
Error::SetStringView(error, "The selected game requires a SBI file to run properly.");
#endif

return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/system_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void CPUThreadShutdown();
/// Returns a handle to the CPU thread.
const Threading::ThreadHandle& GetCPUThreadHandle();

/// Changes the CPU thread handle, use with care.
void SetCPUThreadHandle(Threading::ThreadHandle handle);

/// Polls input, updates subsystems which are present while paused/inactive.
void IdlePollUpdate();

Expand Down

0 comments on commit 9b8d2a8

Please sign in to comment.