Remove BenchGfx

This commit is contained in:
ζeh Matt 2023-06-26 22:14:11 +03:00
parent edabd97c8a
commit d61ce4e38c
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
6 changed files with 0 additions and 157 deletions

View file

@ -1,30 +0,0 @@
/*****************************************************************************
* Copyright (c) 2014-2023 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../interface/Screenshot.h"
#include "CommandLine.hpp"
static exitcode_t HandleBenchGfx(CommandLineArgEnumerator* argEnumerator);
const CommandLineCommand CommandLine::BenchGfxCommands[]{
// Main commands
DefineCommand("", "<file> [iterations count]", nullptr, HandleBenchGfx), CommandTableEnd
};
static exitcode_t HandleBenchGfx(CommandLineArgEnumerator* argEnumerator)
{
const char** argv = const_cast<const char**>(argEnumerator->GetArguments()) + argEnumerator->GetIndex();
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
int32_t result = CommandLineForGfxbench(argv, argc);
if (result < 0)
{
return EXITCODE_FAIL;
}
return EXITCODE_OK;
}

View file

@ -116,7 +116,6 @@ namespace CommandLine
extern const CommandLineCommand RootCommands[];
extern const CommandLineCommand ScreenshotCommands[];
extern const CommandLineCommand SpriteCommands[];
extern const CommandLineCommand BenchGfxCommands[];
extern const CommandLineCommand SimulateCommands[];
extern const CommandLineCommand ParkInfoCommands[];

View file

@ -140,7 +140,6 @@ const CommandLineCommand CommandLine::RootCommands[]
// Sub-commands
DefineSubCommand("screenshot", CommandLine::ScreenshotCommands ),
DefineSubCommand("sprite", CommandLine::SpriteCommands ),
DefineSubCommand("benchgfx", CommandLine::BenchGfxCommands ),
DefineSubCommand("simulate", CommandLine::SimulateCommands ),
DefineSubCommand("parkinfo", CommandLine::ParkInfoCommands ),
CommandTableEnd

View file

@ -390,129 +390,6 @@ void ScreenshotGiant()
ReleaseDPI(dpi);
}
// TODO: Move this at some point into a more appropriate place.
template<typename FN> static inline double MeasureFunctionTime(const FN& fn)
{
const auto startTime = std::chrono::high_resolution_clock::now();
fn();
const auto endTime = std::chrono::high_resolution_clock::now();
return std::chrono::duration<double>(endTime - startTime).count();
}
static void BenchgfxRenderScreenshots(const char* inputPath, std::unique_ptr<IContext>& context, uint32_t iterationCount)
{
if (!context->LoadParkFromFile(inputPath))
{
return;
}
gIntroState = IntroState::None;
gScreenFlags = SCREEN_FLAGS_PLAYING;
// Create Viewport and DPI for every rotation and zoom.
// We iterate from the default zoom level to the max zoomed out zoom level, then run GetGiantViewport once for each
// rotation.
constexpr int32_t NUM_ROTATIONS = 4;
constexpr auto NUM_ZOOM_LEVELS = static_cast<int8_t>(ZoomLevel::max());
std::array<DrawPixelInfo, NUM_ROTATIONS * NUM_ZOOM_LEVELS> dpis;
std::array<Viewport, NUM_ROTATIONS * NUM_ZOOM_LEVELS> viewports;
for (ZoomLevel zoom{ 0 }; zoom < ZoomLevel::max(); zoom++)
{
int32_t zoomIndex{ static_cast<int8_t>(zoom) };
for (int32_t rotation = 0; rotation < NUM_ROTATIONS; rotation++)
{
auto& viewport = viewports[zoomIndex * NUM_ZOOM_LEVELS + rotation];
auto& dpi = dpis[zoomIndex * NUM_ZOOM_LEVELS + rotation];
viewport = GetGiantViewport(rotation, zoom);
dpi = CreateDPI(viewport);
}
}
const uint32_t totalRenderCount = iterationCount * NUM_ROTATIONS * NUM_ZOOM_LEVELS;
try
{
double totalTime = 0.0;
std::array<double, NUM_ZOOM_LEVELS> zoomAverages;
// Render at every zoom.
for (int32_t zoom = 0; zoom < NUM_ZOOM_LEVELS; zoom++)
{
double zoomLevelTime = 0.0;
// Render at every rotation.
for (int32_t rotation = 0; rotation < NUM_ROTATIONS; rotation++)
{
// N iterations.
for (uint32_t i = 0; i < iterationCount; i++)
{
auto& dpi = dpis[zoom * NUM_ZOOM_LEVELS + rotation];
auto& viewport = viewports[zoom * NUM_ZOOM_LEVELS + rotation];
double elapsed = MeasureFunctionTime([&viewport, &dpi]() { RenderViewport(nullptr, viewport, dpi); });
totalTime += elapsed;
zoomLevelTime += elapsed;
}
}
zoomAverages[zoom] = zoomLevelTime / static_cast<double>(NUM_ROTATIONS * iterationCount);
}
const double average = totalTime / static_cast<double>(totalRenderCount);
const auto engineStringId = DrawingEngineStringIds[EnumValue(DrawingEngine::Software)];
const auto engineName = FormatStringID(engineStringId, nullptr);
std::printf("Engine: %s\n", engineName.c_str());
std::printf("Render Count: %u\n", totalRenderCount);
for (ZoomLevel zoom{ 0 }; zoom < ZoomLevel::max(); zoom++)
{
int32_t zoomIndex{ static_cast<int8_t>(zoom) };
const auto zoomAverage = zoomAverages[zoomIndex];
std::printf("Zoom[%d] average: %.06fs, %.f FPS\n", zoomIndex, zoomAverage, 1.0 / zoomAverage);
}
std::printf("Total average: %.06fs, %.f FPS\n", average, 1.0 / average);
std::printf("Time: %.05fs\n", totalTime);
}
catch (const std::exception& e)
{
Console::Error::WriteLine("%s", e.what());
}
for (auto& dpi : dpis)
ReleaseDPI(dpi);
}
int32_t CommandLineForGfxbench(const char** argv, int32_t argc)
{
if (argc != 1 && argc != 2)
{
printf("Usage: openrct2 benchgfx <file> [<iteration_count>]\n");
return -1;
}
int32_t iterationCount = 5;
if (argc == 2)
{
iterationCount = atoi(argv[1]);
}
const char* inputPath = argv[0];
gOpenRCT2Headless = true;
std::unique_ptr<IContext> context(CreateContext());
if (context->Initialise())
{
DrawingEngineInit();
BenchgfxRenderScreenshots(inputPath, context, iterationCount);
DrawingEngineDispose();
}
return 1;
}
static void ApplyOptions(const ScreenshotOptions* options, Viewport& viewport)
{
if (options->weather != WeatherType::Sunny && options->weather != WeatherType::Count)

View file

@ -59,6 +59,5 @@ std::string ScreenshotDumpPNG32bpp(int32_t width, int32_t height, const void* pi
void ScreenshotGiant();
int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOptions* options);
int32_t CommandLineForGfxbench(const char** argv, int32_t argc);
void CaptureImage(const CaptureOptions& options);

View file

@ -690,7 +690,6 @@
<ClCompile Include="audio\DummyAudioContext.cpp" />
<ClCompile Include="Cheats.cpp" />
<ClCompile Include="CommandLineSprite.cpp" />
<ClCompile Include="command_line\BenchGfxCommmands.cpp" />
<ClCompile Include="command_line\CommandLine.cpp" />
<ClCompile Include="command_line\ConvertCommand.cpp" />
<ClCompile Include="command_line\ParkInfoCommands.cpp" />