Change profile to compile time, but still allow enable or disabled

This commit is contained in:
Hayden K 2019-03-12 10:36:35 -04:00
parent 6cce79cfe6
commit 9793e1cfd9
4 changed files with 30 additions and 17 deletions

View File

@ -1100,7 +1100,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
glActiveTextureARB(activeTexture); glActiveTextureARB(activeTexture);
profiler_push(__func__); PROFILER_PUSH(__func__);
PolyList* activeList = _glActivePolyList(); PolyList* activeList = _glActivePolyList();
@ -1117,19 +1117,19 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
* we use this startOffset to reset those pointers after clipping */ * we use this startOffset to reset those pointers after clipping */
uint32_t startOffset = start - (ClipVertex*) activeList->vector.data; uint32_t startOffset = start - (ClipVertex*) activeList->vector.data;
profiler_checkpoint("allocate"); PROFILER_CHECKPOINT("allocate");
generate(start, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting); generate(start, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting);
profiler_checkpoint("generate"); PROFILER_CHECKPOINT("generate");
light(start, spaceNeeded); light(start, spaceNeeded);
profiler_checkpoint("light"); PROFILER_CHECKPOINT("light");
transform(start, spaceNeeded); transform(start, spaceNeeded);
profiler_checkpoint("transform"); PROFILER_CHECKPOINT("transform");
if(_glIsClippingEnabled()) { if(_glIsClippingEnabled()) {
@ -1169,15 +1169,15 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
} }
profiler_checkpoint("clip"); PROFILER_CHECKPOINT("clip");
divide(start, spaceNeeded); divide(start, spaceNeeded);
profiler_checkpoint("divide"); PROFILER_CHECKPOINT("divide");
push(header, start, spaceNeeded, _glActivePolyList(), 0); push(header, start, spaceNeeded, _glActivePolyList(), 0);
profiler_checkpoint("push"); PROFILER_CHECKPOINT("push");
/* /*
Now, if multitexturing is enabled, we want to send exactly the same vertices again, except: Now, if multitexturing is enabled, we want to send exactly the same vertices again, except:
- We want to enable blending, and send them to the TR list - We want to enable blending, and send them to the TR list
@ -1188,7 +1188,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
if(!doMultitexture) { if(!doMultitexture) {
/* Multitexture actively disabled */ /* Multitexture actively disabled */
profiler_pop(); PROFILER_POP();
return; return;
} }
@ -1196,7 +1196,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
if(!texture1 || ((ENABLED_VERTEX_ATTRIBUTES & ST_ENABLED_FLAG) != ST_ENABLED_FLAG)) { if(!texture1 || ((ENABLED_VERTEX_ATTRIBUTES & ST_ENABLED_FLAG) != ST_ENABLED_FLAG)) {
/* Multitexture implicitly disabled */ /* Multitexture implicitly disabled */
profiler_pop(); PROFILER_POP();
return; return;
} }

View File

@ -124,7 +124,7 @@ void APIENTRY glKosSwapBuffers() {
TRACE(); TRACE();
profiler_push(__func__); PROFILER_PUSH(__func__);
pvr_wait_ready(); pvr_wait_ready();
@ -149,8 +149,8 @@ void APIENTRY glKosSwapBuffers() {
aligned_vector_clear(&PT_LIST.vector); aligned_vector_clear(&PT_LIST.vector);
aligned_vector_clear(&TR_LIST.vector); aligned_vector_clear(&TR_LIST.vector);
profiler_checkpoint("scene"); PROFILER_CHECKPOINT("scene");
profiler_pop(); PROFILER_POP();
if(frame_count++ > 100) { if(frame_count++ > 100) {
profiler_print_stats(); profiler_print_stats();

View File

@ -1,9 +1,11 @@
#include <kos.h> #include <kos.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "profiler.h" #include "profiler.h"
#ifdef PROFILER_COMPILE
#include "../containers/aligned_vector.h" #include "../containers/aligned_vector.h"
#define MAX_PATH 256 #define MAX_PATH 256
@ -24,7 +26,7 @@ typedef struct {
static RootProfiler* root = NULL; static RootProfiler* root = NULL;
static char PROFILER_ENABLED = 0; static char PROFILER_ENABLED = PROFILER_COMPILE;
void profiler_enable() { void profiler_enable() {
PROFILER_ENABLED = 1; PROFILER_ENABLED = 1;
@ -141,3 +143,4 @@ void profiler_print_stats() {
fprintf(stderr, "%-60s%-20f%-20f%u\n", result->name, avg, ms, result->total_calls); fprintf(stderr, "%-60s%-20f%-20f%u\n", result->name, avg, ms, result->total_calls);
} }
} }
#endif

View File

@ -2,6 +2,14 @@
#include <stdint.h> #include <stdint.h>
#define PROFILER_COMPILE 1
#ifdef PROFILER_COMPILE
#define PROFILER_PUSH(S) profiler_push(S)
#define PROFILER_CHECKPOINT(P) profiler_checkpoint(P)
#define PROFILER_POP() profiler_pop()
void profiler_enable();
void profiler_disable();
typedef struct { typedef struct {
char name[64]; char name[64];
uint64_t start_time_in_us; uint64_t start_time_in_us;
@ -13,6 +21,8 @@ void profiler_checkpoint(const char* name);
void profiler_pop(); void profiler_pop();
void profiler_print_stats(); void profiler_print_stats();
#else
void profiler_enable(); #define PROFILER_PUSH(S)
void profiler_disable(); #define PROFILER_CHECKPOINT(P)
#define PROFILER_POP()
#endif