Skip to content

Commit

Permalink
framework: Add benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel303 committed Aug 9, 2022
1 parent 00f5312 commit a5ca484
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
35 changes: 23 additions & 12 deletions framework/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#include "rte.h"

#include "Base64.h" // for decoding chibi resource paths
#include "Benchmark.h"
#include "Csv.h" // for decoding chibi resource paths
#include "Path.h"
#include "StringEx.h"
Expand Down Expand Up @@ -777,28 +778,38 @@ bool Framework::init(int sx, int sy)
}
#endif

// initialize built-in shaders

fassert(globals.builtinShaders == nullptr);
globals.builtinShaders = new BuiltinShaders();
{
// initialize built-in shaders

Benchmark bm("framework: initialize builtin shaders");

fassert(globals.builtinShaders == nullptr);
globals.builtinShaders = new BuiltinShaders();
}

#if USE_FREETYPE
// initialize FreeType

fassert(globals.freeType == nullptr);
if (FT_Init_FreeType(&globals.freeType) != 0)
{
logError("failed to initialize FreeType");
if (initErrorHandler)
initErrorHandler(INIT_ERROR_FREETYPE);
return false;
// initialize FreeType

Benchmark bm("framework: initialize FreeType");

fassert(globals.freeType == nullptr);
if (FT_Init_FreeType(&globals.freeType) != 0)
{
logError("failed to initialize FreeType");
if (initErrorHandler)
initErrorHandler(INIT_ERROR_FREETYPE);
return false;
}
}
#endif

// initialize sound player

if (enableSound)
{
Benchmark bm("framework: initialize sound");

#if FRAMEWORK_USE_SOUNDPLAYER_USING_AUDIOSTREAM
fassert(g_audioOutput == nullptr);
g_audioOutput = new AudioOutput_Native();
Expand Down
9 changes: 8 additions & 1 deletion framework/gx-metal/metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
#import "internal.h"
#import "metal.h"
#import "metalView.h"
#import "StringEx.h" // strcpy_s
#import "texture.h"
#import "window_data.h"

#import "Benchmark.h"
#import "StringEx.h" // strcpy_s

#import <map>
#import <Metal/Metal.h>
#import <SDL2/SDL_syswm.h>
Expand Down Expand Up @@ -119,6 +122,8 @@ void metal_init()
{
@autoreleasepool
{
Benchmark bm("framework: initialize Metal");

device = MTLCreateSystemDefaultDevice();

queue = [device newCommandQueue];
Expand Down Expand Up @@ -1854,6 +1859,8 @@ static float scale255(const float v)

void gxInitialize()
{
Benchmark bm("framework: initialize GX");

memset(&renderState, 0, sizeof(renderState));
renderState.blendMode = BLEND_ALPHA;
renderState.colorWriteMask = 0xf;
Expand Down

0 comments on commit a5ca484

Please sign in to comment.