Skip to content

Commit

Permalink
Merge branch 'stenzek:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yeager authored Dec 21, 2024
2 parents 2424f60 + e1bd569 commit 2ae5711
Show file tree
Hide file tree
Showing 33 changed files with 365 additions and 368 deletions.
12 changes: 12 additions & 0 deletions data/resources/gamedb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106687,6 +106687,8 @@ SCES-02403:
controllers:
- AnalogController
- DigitalController
traits:
- ForcePGXPCPUMode # Fixes gaps in geometry.
metadata:
publisher: "Midway"
developer: "Magenta Software Ltd. / Traveller's Tales"
Expand All @@ -106706,6 +106708,8 @@ SCES-03090:
controllers:
- AnalogController
- DigitalController
traits:
- ForcePGXPCPUMode # Fixes gaps in geometry.
metadata:
publisher: "Midway"
developer: "Magenta Software Ltd. / Traveller's Tales"
Expand All @@ -106725,6 +106729,8 @@ SCES-03091:
controllers:
- AnalogController
- DigitalController
traits:
- ForcePGXPCPUMode # Fixes gaps in geometry.
metadata:
publisher: "Midway"
developer: "Magenta Software Ltd. / Traveller's Tales"
Expand All @@ -106744,6 +106750,8 @@ SCES-03092:
controllers:
- AnalogController
- DigitalController
traits:
- ForcePGXPCPUMode # Fixes gaps in geometry.
metadata:
publisher: "Midway"
developer: "Magenta Software Ltd. / Traveller's Tales"
Expand All @@ -106763,6 +106771,8 @@ SCES-03093:
controllers:
- AnalogController
- DigitalController
traits:
- ForcePGXPCPUMode # Fixes gaps in geometry.
metadata:
publisher: "Midway"
developer: "Magenta Software Ltd. / Traveller's Tales"
Expand All @@ -106782,6 +106792,8 @@ SLUS-01238:
controllers:
- AnalogController
- DigitalController
traits:
- ForcePGXPCPUMode # Fixes gaps in geometry.
metadata:
publisher: "Midway"
developer: "Magenta Software Ltd. / Traveller's Tales"
Expand Down
21 changes: 12 additions & 9 deletions src/core/achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2185,12 +2185,7 @@ void Achievements::ConfirmHardcoreModeDisableAsync(const char* trigger, std::fun

void Achievements::ClearUIState()
{
#ifndef __ANDROID__
if (FullscreenUI::IsAchievementsWindowOpen() || FullscreenUI::IsLeaderboardsWindowOpen())
FullscreenUI::ReturnToPreviousWindow();

CloseLeaderboard();
#endif

s_state.achievement_badge_paths = {};

Expand Down Expand Up @@ -2470,10 +2465,14 @@ void Achievements::DrawAchievementsWindow()
using ImGuiFullscreen::LayoutScale;
using ImGuiFullscreen::UIStyle;

auto lock = Achievements::GetLock();

// achievements can get turned off via the main UI
if (!s_state.achievement_list)
{
FullscreenUI::ReturnToPreviousWindow();
return;

auto lock = Achievements::GetLock();
}

static constexpr float alpha = 0.8f;
static constexpr float heading_alpha = 0.95f;
Expand Down Expand Up @@ -2846,7 +2845,12 @@ void Achievements::DrawLeaderboardsWindow()
static constexpr float heading_height_unscaled = 110.0f;
static constexpr float tab_height_unscaled = 50.0f;

auto lock = Achievements::GetLock();
const auto lock = Achievements::GetLock();
if (!s_state.leaderboard_list)
{
FullscreenUI::ReturnToPreviousWindow();
return;
}

const bool is_leaderboard_open = (s_state.open_leaderboard != nullptr);
bool close_leaderboard_on_exit = false;
Expand Down Expand Up @@ -3437,7 +3441,6 @@ void Achievements::CloseLeaderboard()
}

s_state.open_leaderboard = nullptr;
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
}

#if defined(_WIN32)
Expand Down
15 changes: 8 additions & 7 deletions src/core/analog_joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "common/bitutils.h"
#include "common/log.h"
#include "common/settings_interface.h"
#include "common/string_util.h"

#include "IconsFontAwesome5.h"
Expand Down Expand Up @@ -340,14 +341,14 @@ std::unique_ptr<AnalogJoystick> AnalogJoystick::Create(u32 index)

static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, icon_name, button, genb) \
{ \
name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
}
{name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb}
#define AXIS(name, display_name, icon_name, halfaxis, genb) \
{ \
name, display_name, icon_name, static_cast<u32>(AnalogJoystick::Button::Count) + static_cast<u32>(halfaxis), \
InputBindingInfo::Type::HalfAxis, genb \
}
{name, \
display_name, \
icon_name, \
static_cast<u32>(AnalogJoystick::Button::Count) + static_cast<u32>(halfaxis), \
InputBindingInfo::Type::HalfAxis, \
genb}

// clang-format off
BUTTON("Up", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Up"), ICON_PF_DPAD_UP, AnalogJoystick::Button::Up, GenericInputBinding::DPadUp),
Expand Down
4 changes: 2 additions & 2 deletions src/core/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ template<MemoryAccessSize size>
u32 Bus::HWHandlers::GPURead(PhysicalMemoryAddress address)
{
const u32 offset = address & GPU_MASK;
u32 value = g_gpu->ReadRegister(FIXUP_WORD_OFFSET(size, offset));
u32 value = g_gpu.ReadRegister(FIXUP_WORD_OFFSET(size, offset));
value = FIXUP_WORD_READ_VALUE(size, offset, value);
BUS_CYCLES(2);
return value;
Expand All @@ -1885,7 +1885,7 @@ template<MemoryAccessSize size>
void Bus::HWHandlers::GPUWrite(PhysicalMemoryAddress address, u32 value)
{
const u32 offset = address & GPU_MASK;
g_gpu->WriteRegister(FIXUP_WORD_OFFSET(size, offset), FIXUP_WORD_WRITE_VALUE(size, offset, value));
g_gpu.WriteRegister(FIXUP_WORD_OFFSET(size, offset), FIXUP_WORD_WRITE_VALUE(size, offset, value));
}

template<MemoryAccessSize size>
Expand Down
1 change: 1 addition & 0 deletions src/core/cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "common/file_system.h"
#include "common/log.h"
#include "common/path.h"
#include "common/settings_interface.h"
#include "common/small_string.h"
#include "common/string_util.h"
#include "common/zip_helpers.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/cpu_recompiler_x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "common/align.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/small_string.h"
#include "common/string_util.h"

#include <limits>
Expand Down
10 changes: 5 additions & 5 deletions src/core/dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
{
case Channel::GPU:
{
if (g_gpu->BeginDMAWrite()) [[likely]]
if (g_gpu.BeginDMAWrite()) [[likely]]
{
if (GPUDump::Recorder* dump = g_gpu->GetGPUDump()) [[unlikely]]
if (GPUDump::Recorder* dump = g_gpu.GetGPUDump()) [[unlikely]]
{
// No wraparound?
dump->BeginGP0Packet(word_count);
Expand All @@ -831,10 +831,10 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
{
u32 value;
std::memcpy(&value, &ram_pointer[address], sizeof(u32));
g_gpu->DMAWrite(address, value);
g_gpu.DMAWrite(address, value);
address = (address + increment) & mask;
}
g_gpu->EndDMAWrite();
g_gpu.EndDMAWrite();
}
}
break;
Expand Down Expand Up @@ -900,7 +900,7 @@ TickCount DMA::TransferDeviceToMemory(u32 address, u32 increment, u32 word_count
switch (channel)
{
case Channel::GPU:
g_gpu->DMARead(dest_pointer, word_count);
g_gpu.DMARead(dest_pointer, word_count);
break;

case Channel::CDROM:
Expand Down
32 changes: 2 additions & 30 deletions src/core/fullscreen_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,27 +632,9 @@ bool FullscreenUI::AreAnyDialogsOpen()
ImGuiFullscreen::IsFileSelectorOpen());
}

void FullscreenUI::CheckForConfigChanges(const Settings& old_settings)
void FullscreenUI::CheckForConfigChanges(const GPUSettings& old_settings)
{
// NOTE: Called on CPU thread.
if (!IsInitialized())
return;

// If achievements got disabled, we might have the menu open...
// That means we're going to be reading achievement state.
if (old_settings.achievements_enabled && !g_settings.achievements_enabled)
{
if (!IsInitialized())
return;

GPUThread::RunOnThread([]() {
if (s_state.current_main_window == MainWindowType::Achievements ||
s_state.current_main_window == MainWindowType::Leaderboards)
{
ReturnToPreviousWindow();
}
});
}
// NOTE: Called on GPU thread.
}

void FullscreenUI::UpdateRunIdleState()
Expand Down Expand Up @@ -7635,11 +7617,6 @@ void FullscreenUI::OpenAchievementsWindow()
});
}

bool FullscreenUI::IsAchievementsWindowOpen()
{
return (s_state.current_main_window == MainWindowType::Achievements);
}

void FullscreenUI::OpenLeaderboardsWindow()
{
if (!System::IsValid())
Expand Down Expand Up @@ -7674,11 +7651,6 @@ void FullscreenUI::OpenLeaderboardsWindow()
});
}

bool FullscreenUI::IsLeaderboardsWindowOpen()
{
return (s_state.current_main_window == MainWindowType::Leaderboards);
}

#endif // __ANDROID__

LoadingScreenProgressCallback::LoadingScreenProgressCallback()
Expand Down
6 changes: 2 additions & 4 deletions src/core/fullscreen_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

class SmallStringBase;

struct Settings;
struct GPUSettings;

namespace FullscreenUI {
bool Initialize();
bool IsInitialized();
bool HasActiveWindow();
void CheckForConfigChanges(const Settings& old_settings);
void CheckForConfigChanges(const GPUSettings& old_settings);
void OnSystemStarted();
void OnSystemResumed();
void OnSystemDestroyed();
Expand All @@ -29,9 +29,7 @@ void OnRunningGameChanged();
void OpenPauseMenu();
void OpenCheatsMenu();
void OpenAchievementsWindow();
bool IsAchievementsWindowOpen();
void OpenLeaderboardsWindow();
bool IsLeaderboardsWindowOpen();
void ReturnToMainWindow();
void ReturnToPreviousWindow();
void SetStandardSelectionFooterText(bool back_instead_of_cancel);
Expand Down
26 changes: 14 additions & 12 deletions src/core/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

LOG_CHANNEL(GPU);

std::unique_ptr<GPU> g_gpu;
ALIGN_TO_CACHE_LINE GPU g_gpu;

// aligning VRAM to 4K is fine, since the ARM64 instructions compute 4K page aligned addresses
// or it would be, except we want to import the memory for readbacks on metal..
Expand All @@ -60,13 +60,13 @@ u16 g_gpu_clut[GPU_CLUT_SIZE];
const GPU::GP0CommandHandlerTable GPU::s_GP0_command_handler_table = GPU::GenerateGP0CommandHandlerTable();

static TimingEvent s_crtc_tick_event(
"GPU CRTC Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu->CRTCTickEvent(ticks); },
"GPU CRTC Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.CRTCTickEvent(ticks); },
nullptr);
static TimingEvent s_command_tick_event(
"GPU Command Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu->CommandTickEvent(ticks); },
"GPU Command Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.CommandTickEvent(ticks); },
nullptr);
static TimingEvent s_frame_done_event(
"Frame Done", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu->FrameDoneEvent(ticks); },
"Frame Done", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.FrameDoneEvent(ticks); },
nullptr);

// #define PSX_GPU_STATS
Expand All @@ -77,14 +77,7 @@ static u32 s_active_gpu_cycles_frames = 0;

GPU::GPU() = default;

GPU::~GPU()
{
s_command_tick_event.Deactivate();
s_crtc_tick_event.Deactivate();
s_frame_done_event.Deactivate();

StopRecordingGPUDump();
}
GPU::~GPU() = default;

void GPU::Initialize()
{
Expand All @@ -104,6 +97,15 @@ void GPU::Initialize()
#endif
}

void GPU::Shutdown()
{
s_command_tick_event.Deactivate();
s_crtc_tick_event.Deactivate();
s_frame_done_event.Deactivate();

StopRecordingGPUDump();
}

void GPU::UpdateSettings(const Settings& old_settings)
{
m_force_progressive_scan = (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive);
Expand Down
3 changes: 2 additions & 1 deletion src/core/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class GPU final
~GPU();

void Initialize();
void Shutdown();
void Reset(bool clear_vram);
bool DoState(StateWrapper& sw, bool update_display);
void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss, bool update_display);
Expand Down Expand Up @@ -561,6 +562,6 @@ class GPU final
static const GP0CommandHandlerTable s_GP0_command_handler_table;
};

extern std::unique_ptr<GPU> g_gpu;
extern GPU g_gpu;
extern u16 g_vram[VRAM_SIZE / sizeof(u16)];
extern u16 g_gpu_clut[GPU_CLUT_SIZE];
Loading

0 comments on commit 2ae5711

Please sign in to comment.