progs/perf: add scons support, get working under mingw
This commit is contained in:
@@ -10,4 +10,5 @@ SConscript([
|
|||||||
'vpglsl/SConscript',
|
'vpglsl/SConscript',
|
||||||
'fp/SConscript',
|
'fp/SConscript',
|
||||||
'wgl/SConscript',
|
'wgl/SConscript',
|
||||||
|
'perf/SConscript',
|
||||||
])
|
])
|
||||||
|
26
progs/perf/SConscript
Normal file
26
progs/perf/SConscript
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Import('env')
|
||||||
|
|
||||||
|
if not env['GLUT']:
|
||||||
|
Return()
|
||||||
|
|
||||||
|
env = env.Clone()
|
||||||
|
|
||||||
|
env.Prepend(LIBS = ['$GLUT_LIB'])
|
||||||
|
|
||||||
|
progs = [
|
||||||
|
'drawoverhead',
|
||||||
|
'teximage',
|
||||||
|
'vbo',
|
||||||
|
'vertexrate',
|
||||||
|
]
|
||||||
|
|
||||||
|
for prog in progs:
|
||||||
|
env.Program(
|
||||||
|
target = prog,
|
||||||
|
source = [
|
||||||
|
prog + '.c',
|
||||||
|
'common.c',
|
||||||
|
'glmain.c',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
@@ -26,6 +26,28 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "glmain.h"
|
#include "glmain.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Need to add a fflush windows console with mingw, otherwise nothing
|
||||||
|
* shows up until program exit. May want to add logging here.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
perf_printf(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
vfprintf(stdout, format, ap);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run function 'f' for enough iterations to reach a steady state.
|
* Run function 'f' for enough iterations to reach a steady state.
|
||||||
@@ -52,7 +74,7 @@ PerfMeasureRate(PerfRateFunc f)
|
|||||||
subiters *= 2;
|
subiters *= 2;
|
||||||
} while (t1 - t0 < 0.1 * minDuration);
|
} while (t1 - t0 < 0.1 * minDuration);
|
||||||
}
|
}
|
||||||
/*printf("initial subIters = %u\n", subiters);*/
|
/*perf_printf("initial subIters = %u\n", subiters);*/
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
const double t0 = PerfGetTime();
|
const double t0 = PerfGetTime();
|
||||||
@@ -68,7 +90,7 @@ PerfMeasureRate(PerfRateFunc f)
|
|||||||
rate = iters / (t1 - t0);
|
rate = iters / (t1 - t0);
|
||||||
|
|
||||||
if (0)
|
if (0)
|
||||||
printf("prevRate %f rate %f ratio %f iters %u\n",
|
perf_printf("prevRate %f rate %f ratio %f iters %u\n",
|
||||||
prevRate, rate, rate/prevRate, iters);
|
prevRate, rate, rate/prevRate, iters);
|
||||||
|
|
||||||
/* Try and speed the search up by skipping a few steps:
|
/* Try and speed the search up by skipping a few steps:
|
||||||
@@ -86,7 +108,7 @@ PerfMeasureRate(PerfRateFunc f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0)
|
if (0)
|
||||||
printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
|
perf_printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,5 +31,9 @@ extern double
|
|||||||
PerfMeasureRate(PerfRateFunc f);
|
PerfMeasureRate(PerfRateFunc f);
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
perf_printf(const char *format, ...);
|
||||||
|
|
||||||
|
|
||||||
#endif /* COMMON_H */
|
#endif /* COMMON_H */
|
||||||
|
|
||||||
|
@@ -116,17 +116,18 @@ PerfDraw(void)
|
|||||||
double rate0, rate1, rate2, overhead;
|
double rate0, rate1, rate2, overhead;
|
||||||
|
|
||||||
rate0 = PerfMeasureRate(DrawNoStateChange);
|
rate0 = PerfMeasureRate(DrawNoStateChange);
|
||||||
printf(" Draw only: %.1f draws/second\n", rate0);
|
perf_printf(" Draw only: %.1f draws/second\n", rate0);
|
||||||
|
|
||||||
|
|
||||||
rate1 = PerfMeasureRate(DrawNopStateChange);
|
rate1 = PerfMeasureRate(DrawNopStateChange);
|
||||||
overhead = 1000.0 * (1.0 / rate1 - 1.0 / rate0);
|
overhead = 1000.0 * (1.0 / rate1 - 1.0 / rate0);
|
||||||
printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",
|
perf_printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",
|
||||||
rate1, overhead);
|
rate1, overhead);
|
||||||
|
|
||||||
rate2 = PerfMeasureRate(DrawStateChange);
|
rate2 = PerfMeasureRate(DrawStateChange);
|
||||||
overhead = 1000.0 * (1.0 / rate2 - 1.0 / rate0);
|
overhead = 1000.0 * (1.0 / rate2 - 1.0 / rate0);
|
||||||
printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",
|
perf_printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",
|
||||||
rate2, overhead);
|
rate2, overhead);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@@ -50,8 +50,11 @@ static const struct vertex vertices[1] = {
|
|||||||
{ 0.0, 0.0, 0.5, 0.5 },
|
{ 0.0, 0.0, 0.5, 0.5 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
|
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
|
||||||
|
#else
|
||||||
|
#define VOFFSET(F) ((void *) &((struct vertex *)NULL)->F)
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Called from test harness/main */
|
/** Called from test harness/main */
|
||||||
void
|
void
|
||||||
@@ -196,10 +199,10 @@ PerfDraw(void)
|
|||||||
|
|
||||||
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);
|
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);
|
||||||
|
|
||||||
printf(" glTex%sImage2D(%s %d x %d): "
|
perf_printf(" glTex%sImage2D(%s %d x %d): "
|
||||||
"%.1f images/sec, %.1f MB/sec\n",
|
"%.1f images/sec, %.1f MB/sec\n",
|
||||||
(subImage ? "Sub" : ""),
|
(subImage ? "Sub" : ""),
|
||||||
SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);
|
SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);
|
||||||
|
|
||||||
free(TexImage);
|
free(TexImage);
|
||||||
}
|
}
|
||||||
|
@@ -127,8 +127,8 @@ PerfDraw(void)
|
|||||||
|
|
||||||
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
|
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
|
||||||
|
|
||||||
printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",
|
perf_printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",
|
||||||
(sub ? "Sub" : ""), VBOSize, mbPerSec);
|
(sub ? "Sub" : ""), VBOSize, mbPerSec);
|
||||||
|
|
||||||
free(VBOData);
|
free(VBOData);
|
||||||
}
|
}
|
||||||
|
@@ -237,35 +237,35 @@ PerfDraw(void)
|
|||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);
|
perf_printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawImmediate);
|
rate = PerfMeasureRate(DrawImmediate);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" Immediate mode: %.1f verts/sec\n", rate);
|
perf_printf(" Immediate mode: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawArraysMem);
|
rate = PerfMeasureRate(DrawArraysMem);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" glDrawArrays: %.1f verts/sec\n", rate);
|
perf_printf(" glDrawArrays: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawArraysVBO);
|
rate = PerfMeasureRate(DrawArraysVBO);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);
|
perf_printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawElementsMem);
|
rate = PerfMeasureRate(DrawElementsMem);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" glDrawElements: %.1f verts/sec\n", rate);
|
perf_printf(" glDrawElements: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawElementsBO);
|
rate = PerfMeasureRate(DrawElementsBO);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" VBO glDrawElements: %.1f verts/sec\n", rate);
|
perf_printf(" VBO glDrawElements: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawRangeElementsMem);
|
rate = PerfMeasureRate(DrawRangeElementsMem);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" glDrawRangeElements: %.1f verts/sec\n", rate);
|
perf_printf(" glDrawRangeElements: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
rate = PerfMeasureRate(DrawRangeElementsBO);
|
rate = PerfMeasureRate(DrawRangeElementsBO);
|
||||||
rate *= NumVerts;
|
rate *= NumVerts;
|
||||||
printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);
|
perf_printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user