'vpglsl/SConscript',
'fp/SConscript',
'wgl/SConscript',
+ 'perf/SConscript',
])
--- /dev/null
+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',
+ ]
+ )
+
#include "common.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.
subiters *= 2;
} while (t1 - t0 < 0.1 * minDuration);
}
- /*printf("initial subIters = %u\n", subiters);*/
+ /*perf_printf("initial subIters = %u\n", subiters);*/
while (1) {
const double t0 = PerfGetTime();
rate = iters / (t1 - t0);
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);
/* Try and speed the search up by skipping a few steps:
}
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;
}
PerfMeasureRate(PerfRateFunc f);
+extern void
+perf_printf(const char *format, ...);
+
+
#endif /* COMMON_H */
double rate0, rate1, rate2, overhead;\r
\r
rate0 = PerfMeasureRate(DrawNoStateChange);\r
- printf(" Draw only: %.1f draws/second\n", rate0);\r
+ perf_printf(" Draw only: %.1f draws/second\n", rate0);\r
+ \r
\r
rate1 = PerfMeasureRate(DrawNopStateChange);\r
overhead = 1000.0 * (1.0 / rate1 - 1.0 / rate0);\r
- printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",\r
- rate1, overhead);\r
+ perf_printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",\r
+ rate1, overhead);\r
\r
rate2 = PerfMeasureRate(DrawStateChange);\r
overhead = 1000.0 * (1.0 / rate2 - 1.0 / rate0);\r
- printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",\r
- rate2, overhead);\r
+ perf_printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",\r
+ rate2, overhead);\r
\r
exit(0);\r
}\r
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
-#include <stdio.h>
#include <stdlib.h>
#include <math.h>
{ 0.0, 0.0, 0.5, 0.5 },\r
};\r
\r
-\r
+#if 0\r
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))\r
+#else\r
+#define VOFFSET(F) ((void *) &((struct vertex *)NULL)->F)\r
+#endif\r
\r
/** Called from test harness/main */\r
void\r
\r
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);\r
\r
- printf(" glTex%sImage2D(%s %d x %d): "\r
- "%.1f images/sec, %.1f MB/sec\n",\r
- (subImage ? "Sub" : ""),\r
- SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);\r
+ perf_printf(" glTex%sImage2D(%s %d x %d): "\r
+ "%.1f images/sec, %.1f MB/sec\n",\r
+ (subImage ? "Sub" : ""),\r
+ SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);\r
\r
free(TexImage);\r
}\r
\r
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);\r
\r
- printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",\r
- (sub ? "Sub" : ""), VBOSize, mbPerSec);\r
+ perf_printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",\r
+ (sub ? "Sub" : ""), VBOSize, mbPerSec);\r
\r
free(VBOData);\r
}\r
\r
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\r
\r
- printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);\r
+ perf_printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);\r
\r
rate = PerfMeasureRate(DrawImmediate);\r
rate *= NumVerts;\r
- printf(" Immediate mode: %.1f verts/sec\n", rate);\r
+ perf_printf(" Immediate mode: %.1f verts/sec\n", rate);\r
\r
rate = PerfMeasureRate(DrawArraysMem);\r
rate *= NumVerts;\r
- printf(" glDrawArrays: %.1f verts/sec\n", rate);\r
+ perf_printf(" glDrawArrays: %.1f verts/sec\n", rate);\r
\r
rate = PerfMeasureRate(DrawArraysVBO);\r
rate *= NumVerts;\r
- printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);\r
+ perf_printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);\r
\r
rate = PerfMeasureRate(DrawElementsMem);\r
rate *= NumVerts;\r
- printf(" glDrawElements: %.1f verts/sec\n", rate);\r
+ perf_printf(" glDrawElements: %.1f verts/sec\n", rate);\r
\r
rate = PerfMeasureRate(DrawElementsBO);\r
rate *= NumVerts;\r
- printf(" VBO glDrawElements: %.1f verts/sec\n", rate);\r
+ perf_printf(" VBO glDrawElements: %.1f verts/sec\n", rate);\r
\r
rate = PerfMeasureRate(DrawRangeElementsMem);\r
rate *= NumVerts;\r
- printf(" glDrawRangeElements: %.1f verts/sec\n", rate);\r
+ perf_printf(" glDrawRangeElements: %.1f verts/sec\n", rate);\r
\r
rate = PerfMeasureRate(DrawRangeElementsBO);\r
rate *= NumVerts;\r
- printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);\r
+ perf_printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);\r
\r
exit(0);\r
}\r