Implement Benchm,arking System for BitmapPrinter
This commit is contained in:
parent
1ee4f6849e
commit
8f2c877197
43
.vscode/settings.json
vendored
Normal file
43
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"numeric": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp"
|
||||
}
|
||||
}
|
4
BuildAndInstall.sh
Executable file
4
BuildAndInstall.sh
Executable file
@ -0,0 +1,4 @@
|
||||
export DEVKITARM=/opt/devkitpro/devkitARM/
|
||||
export DEVKITPRO=/opt/devkitpro/
|
||||
make
|
||||
make install
|
@ -433,10 +433,20 @@ namespace RenderD7
|
||||
void SavePng(std::string name);
|
||||
|
||||
void CreateScreen(C3D_RenderTarget *target);
|
||||
void DrawScreen(int framerate);
|
||||
void DrawScreenDirectF(int framerate);
|
||||
void DrawScreenDirect();
|
||||
void DrawScreenF(int framerate);
|
||||
void DrawScreen();
|
||||
void UpdateScreenF(int framerate);
|
||||
void UpdateScreen();
|
||||
void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255);
|
||||
void ClearBlank();
|
||||
RenderD7::Image GetImage();
|
||||
/// Test to Find out The Best Settings for BitmapPrinter
|
||||
void Benchmark();
|
||||
/// Setup the Benchmark
|
||||
/// \param framerate The Fps of the ScreenUpdates
|
||||
void SetupBenchmark(int framerate);
|
||||
private:
|
||||
int frame = 0;
|
||||
RenderD7::Image renderframe;
|
||||
@ -444,5 +454,21 @@ namespace RenderD7
|
||||
C3D_RenderTarget* targetr;
|
||||
BMP bitmap = NULL;
|
||||
BMP blank = NULL;
|
||||
//Benchmark Stuff;
|
||||
bool benchmark = false;
|
||||
bool setupbenchmark;
|
||||
float frametime = 0;
|
||||
uint64_t lastTime = 0;
|
||||
float dtt = 0.f;
|
||||
float timer = 0;
|
||||
float mhdtt = 0;
|
||||
|
||||
float fpsClock = 0.f;
|
||||
int frameCounter = 0, fps = 0;
|
||||
|
||||
std::vector<float> hdttt;
|
||||
std::vector<int> fpscountc;
|
||||
int renderedframes = 0;
|
||||
int testfps = 60;
|
||||
};
|
||||
} /// RenderD7
|
||||
|
@ -1627,7 +1627,7 @@ void RenderD7::BitmapPrinter::DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a)
|
||||
}
|
||||
void RenderD7::BitmapPrinter::DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a)
|
||||
{
|
||||
unsigned error = bitmap.draw_rectangle(x, bitmap.bmp_info_header.height - w - y, w, h, b, g, r, a, line_w);
|
||||
unsigned error = bitmap.draw_rectangle(x, bitmap.bmp_info_header.height - y - h, w, h, b, g, r, a, line_w);
|
||||
if (error)
|
||||
{
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter->Rect", "Error Code: " + std::to_string(error)));
|
||||
@ -1636,7 +1636,7 @@ void RenderD7::BitmapPrinter::DrawRect(int x, int y, int w, int h, u8 line_w, u8
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a)
|
||||
{
|
||||
unsigned error = bitmap.fill_region(x, bitmap.bmp_info_header.height - w - y, w, h, b, g, r, a);
|
||||
unsigned error = bitmap.fill_region(x, bitmap.bmp_info_header.height - h - y, w, h, b, g, r, a);
|
||||
if (error)
|
||||
{
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter->RectF", "Error Code: " + std::to_string(error)));
|
||||
@ -1684,26 +1684,33 @@ void RenderD7::BitmapPrinter::CreateScreen(C3D_RenderTarget *target)
|
||||
renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
|
||||
|
||||
}
|
||||
void RenderD7::BitmapPrinter::DrawScreen(int framerate)
|
||||
void RenderD7::BitmapPrinter::DrawScreenDirectF(int framerate)
|
||||
{
|
||||
if (isscreen)
|
||||
{
|
||||
if(frame == (60/framerate)){
|
||||
RenderD7::OnScreen(targetr);
|
||||
RenderD7::Image *img = new RenderD7::Image();
|
||||
img->Unload();
|
||||
//img->LoadFromBitmap(bitmap);
|
||||
renderframe.Unload();
|
||||
renderframe.LoadFromBitmap(bitmap);
|
||||
renderframe.img = img->Get();
|
||||
img->Unload();
|
||||
delete img;
|
||||
frame = 0;
|
||||
}
|
||||
|
||||
renderframe.Draw(0, 0);
|
||||
frame++;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawScreenDirect()
|
||||
{
|
||||
if (isscreen)
|
||||
{
|
||||
RenderD7::OnScreen(targetr);
|
||||
renderframe.Unload();
|
||||
renderframe.LoadFromBitmap(bitmap);
|
||||
renderframe.Draw(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
RenderD7::Image RenderD7::BitmapPrinter::GetImage()
|
||||
{
|
||||
RenderD7::Image img;
|
||||
@ -1727,4 +1734,120 @@ void RenderD7::BitmapPrinter::Clear(u8 b, u8 g, u8 r, u8 a)
|
||||
void RenderD7::BitmapPrinter::ClearBlank()
|
||||
{
|
||||
bitmap = blank;
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawScreenF(int framerate)
|
||||
{
|
||||
if (isscreen)
|
||||
{
|
||||
if(frame == (60/framerate)){
|
||||
RenderD7::OnScreen(targetr);
|
||||
frame = 0;
|
||||
}
|
||||
|
||||
renderframe.Draw(0, 0);
|
||||
frame++;
|
||||
}
|
||||
}
|
||||
void RenderD7::BitmapPrinter::DrawScreen()
|
||||
{
|
||||
if (isscreen)
|
||||
{
|
||||
RenderD7::OnScreen(targetr);
|
||||
renderframe.Draw(0, 0);
|
||||
}
|
||||
}
|
||||
void RenderD7::BitmapPrinter::UpdateScreenF(int framerate)
|
||||
{
|
||||
if (isscreen)
|
||||
{
|
||||
if(frame == (60/framerate)){
|
||||
renderframe.Unload();
|
||||
renderframe.LoadFromBitmap(bitmap);
|
||||
frame = 0;
|
||||
}
|
||||
frame++;
|
||||
}
|
||||
}
|
||||
void RenderD7::BitmapPrinter::UpdateScreen()
|
||||
{
|
||||
if (isscreen)
|
||||
{
|
||||
renderframe.Unload();
|
||||
renderframe.LoadFromBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
#define TICKS_PER_MSEC 268111.856
|
||||
|
||||
void RenderD7::BitmapPrinter::Benchmark()
|
||||
{
|
||||
if(setupbenchmark)
|
||||
{
|
||||
frametime = 0;
|
||||
renderedframes = 0;
|
||||
timer = 0;
|
||||
setupbenchmark = false;
|
||||
lastTime = svcGetSystemTick();
|
||||
}
|
||||
if(benchmark)
|
||||
{
|
||||
if(timer >= 60)
|
||||
{
|
||||
std::string renderedf = std::to_string(renderedframes);
|
||||
std::string avgdtt = std::to_string(mhdtt);
|
||||
float alldtt = 0;
|
||||
for (size_t i = 0; i < hdttt.size(); i++)
|
||||
{
|
||||
alldtt += hdttt[i];
|
||||
}
|
||||
float allfps = 0;
|
||||
for (size_t f = 0; f < fpscountc.size(); f++)
|
||||
{
|
||||
allfps += fpscountc[f];
|
||||
}
|
||||
|
||||
|
||||
std::string avgcpu = std::to_string((alldtt/(float)hdttt.size()));
|
||||
std::string avgfps = std::to_string((allfps/(int)fpscountc.size()));
|
||||
|
||||
std::string resultt = "Frames Rendered: " + renderedf + "\nMax Cpu Time: " + avgdtt + "\nAvg Cpu Time: " + avgcpu + "\nAvg Fps: " + avgfps;
|
||||
RenderD7::Error::DisplayError("Result", resultt, 30);
|
||||
benchmark = false;
|
||||
}
|
||||
uint64_t currentTime = svcGetSystemTick();
|
||||
dtt = ((float)(currentTime / (float)TICKS_PER_MSEC) - (float)(lastTime / (float)TICKS_PER_MSEC)) / 1000.f;
|
||||
lastTime = currentTime;
|
||||
last_time = currentTime;
|
||||
frameCounter++;
|
||||
fpsClock += dtt;
|
||||
if (fpsClock >= 1.f) {
|
||||
fps = frameCounter;
|
||||
frameCounter = 0;
|
||||
fpsClock = 0.f;
|
||||
}
|
||||
|
||||
this->ClearBlank();
|
||||
this->DrawRectFilled(0, 0, this->bitmap.bmp_info_header.width, this->bitmap.bmp_info_header.width, 255, 255, 255, 255);
|
||||
this->DrawRect(5, 5, this->bitmap.bmp_info_header.width - 10, this->bitmap.bmp_info_header.height - 10, 5, 0, 0, 0, 0);
|
||||
this->UpdateScreenF(testfps);
|
||||
this->DrawScreen();
|
||||
renderedframes++;
|
||||
timer+= 1*dtt;
|
||||
float hdtt = C3D_GetProcessingTime();
|
||||
hdttt.push_back(hdtt);
|
||||
if(mhdtt < hdtt)
|
||||
{
|
||||
mhdtt = C3D_GetProcessingTime();
|
||||
}
|
||||
RenderD7::DrawText(0, 0, 0.5f, RenderD7::Color::Hex("#ff0000"), "Time: " + std::to_string(timer));
|
||||
RenderD7::DrawText(0, 20, 0.5f, RenderD7::Color::Hex("#ff0000"), "Fps: " + std::to_string(fps));
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::SetupBenchmark(int framerate)
|
||||
{
|
||||
benchmark = true;
|
||||
setupbenchmark = true;
|
||||
this->testfps = framerate;
|
||||
}
|
Loading…
Reference in New Issue
Block a user