Changeset View
Changeset View
Standalone View
Standalone View
source/main.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
// We don't want to include Windows.h as it might mess up the rest | // We don't want to include Windows.h as it might mess up the rest | ||||
// of the file so we just define DWORD as done in Windef.h. | // of the file so we just define DWORD as done in Windef.h. | ||||
#ifndef DWORD | #ifndef DWORD | ||||
typedef unsigned long DWORD; | typedef unsigned long DWORD; | ||||
#endif // !DWORD | #endif // !DWORD | ||||
// Request the high performance GPU on Windows by default if no system override is specified. | // Request the high performance GPU on Windows by default if no system override is specified. | ||||
// See: | // See: | ||||
// - https://github.com/supertuxkart/stk-code/pull/4693/commits/0a99c667ef513b2ce0f5755729a6e05df8aac48a | // - https://github.com/supertuxkart/stk-code/pull/4693/commits/0a99c667ef513b2ce0f5755729a6e05df8aac48a | ||||
// - https://docs.nvidia.com/gameworks/content/technologies/desktop/optimus.htm | // - https://docs.nvidia.com/gameworks/content/technologies/desktop/optimus.htm | ||||
// - https://gpuopen.com/learn/amdpowerxpressrequesthighperformance/ | // - https://gpuopen.com/learn/amdpowerxpressrequesthighperformance/ | ||||
extern "C" | extern "C" | ||||
{ | { | ||||
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; | __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; | ||||
__declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; | __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; | ||||
} | } | ||||
#endif | #endif | ||||
#include <chrono> | #include <chrono> | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | case SDL_HOTKEYPRESS: | ||||
} | } | ||||
else if (hotkey == "togglefullscreen") | else if (hotkey == "togglefullscreen") | ||||
{ | { | ||||
g_VideoMode.ToggleFullscreen(); | g_VideoMode.ToggleFullscreen(); | ||||
return IN_HANDLED; | return IN_HANDLED; | ||||
} | } | ||||
else if (hotkey == "profile2.toggle") | else if (hotkey == "profile2.toggle") | ||||
{ | { | ||||
g_Profiler2.Toggle(); | g_Profiler2->Toggle(); | ||||
return IN_HANDLED; | return IN_HANDLED; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
return IN_PASS; | return IN_PASS; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | static void RendererIncrementalLoad() | ||||
do { | do { | ||||
more = g_Renderer.GetTextureManager().MakeProgress(); | more = g_Renderer.GetTextureManager().MakeProgress(); | ||||
} | } | ||||
while (more && timer_Time() - startTime < maxTime); | while (more && timer_Time() - startTime < maxTime); | ||||
} | } | ||||
static void Frame() | static void Frame() | ||||
{ | { | ||||
g_Profiler2.RecordFrameStart(); | g_Profiler2->RecordFrameStart(); | ||||
PROFILE2("frame"); | PROFILE2("frame"); | ||||
g_Profiler2.IncrementFrameNumber(); | g_Profiler2->IncrementFrameNumber(); | ||||
PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber()); | PROFILE2_ATTR("%d", g_Profiler2->GetFrameNumber()); | ||||
// get elapsed time | // get elapsed time | ||||
const double time = timer_Time(); | const double time = timer_Time(); | ||||
g_frequencyFilter->Update(time); | g_frequencyFilter->Update(time); | ||||
// .. old method - "exact" but contains jumps | // .. old method - "exact" but contains jumps | ||||
#if 0 | #if 0 | ||||
static double last_time; | static double last_time; | ||||
const double time = timer_Time(); | const double time = timer_Time(); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | #endif | ||||
g_Profiler.Frame(); | g_Profiler.Frame(); | ||||
LimitFPS(); | LimitFPS(); | ||||
} | } | ||||
static void NonVisualFrame() | static void NonVisualFrame() | ||||
{ | { | ||||
g_Profiler2.RecordFrameStart(); | g_Profiler2->RecordFrameStart(); | ||||
PROFILE2("frame"); | PROFILE2("frame"); | ||||
g_Profiler2.IncrementFrameNumber(); | g_Profiler2->IncrementFrameNumber(); | ||||
PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber()); | PROFILE2_ATTR("%d", g_Profiler2->GetFrameNumber()); | ||||
if (g_NetClient) | if (g_NetClient) | ||||
g_NetClient->Poll(); | g_NetClient->Poll(); | ||||
static u32 turn = 0; | static u32 turn = 0; | ||||
if (g_Game && g_Game->IsGameStarted() && g_Game->GetTurnManager()) | if (g_Game && g_Game->IsGameStarted() && g_Game->GetTurnManager()) | ||||
if (g_Game->GetTurnManager()->Update(DEFAULT_TURN_LENGTH, 1)) | if (g_Game->GetTurnManager()->Update(DEFAULT_TURN_LENGTH, 1)) | ||||
debug_printf("Turn %u (%u)...\n", turn++, DEFAULT_TURN_LENGTH); | debug_printf("Turn %u (%u)...\n", turn++, DEFAULT_TURN_LENGTH); | ||||
▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | std::cerr << "********************************************************\n" | ||||
<< "permissions and opens your system to vulnerabilities. \n" | << "permissions and opens your system to vulnerabilities. \n" | ||||
<< "(You received this message because you were either \n" | << "(You received this message because you were either \n" | ||||
<<" logged in as root or used e.g. the 'sudo' command.) \n" | <<" logged in as root or used e.g. the 'sudo' command.) \n" | ||||
<< "********************************************************\n\n"; | << "********************************************************\n\n"; | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
#endif // OS_UNIX | #endif // OS_UNIX | ||||
EarlyInit(); // must come at beginning of main | EarliestInit(); | ||||
Freagarach: (Comment is wrong now?) | |||||
RunGameOrAtlas(argc, const_cast<const char**>(argv)); | // initialise profiler early so it can profile startup, | ||||
// but after timer_Init() | |||||
CProfiler2 profiler; | |||||
Done Inline Actionsthe caller is responsible for seting g_Profiler2. if it would be done in the constructor it would be a singleton again, as i understand it. phosit: the caller is responsible for seting `g_Profiler2`. if it would be done in the constructor it… | |||||
Not Done Inline ActionsIt's still a singleton, just without wrappers. And your code is less safety, nobody zeroes g_Profiler2 and checks that g_Profiler2 won't be used before CProfiler2 constructor or after CProfiler2 destructor. vladislavbelov: It's still a singleton, just without wrappers. And your code is less safety, nobody zeroes… | |||||
EarlyInit(); | |||||
// Shut down profiler initialised by EarlyInit | RunGameOrAtlas(argc, const_cast<const char**>(argv)); | ||||
g_Profiler2.Shutdown(); | |||||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||||
} | } |
Wildfire Games · Phabricator
(Comment is wrong now?)