mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
progs/perf: add first attempt at a swapbuffers rate test
This is pretty ugly as the original framework assumed you'd set a single window size at startup and keep it throughout, but for swapbuffers you want to test the rate at various window sizes. With luck a nicer solution can be found, but this at least lays out a marker.
This commit is contained in:
parent
94a020cfe6
commit
a7b2659f02
9 changed files with 207 additions and 14 deletions
|
|
@ -16,6 +16,7 @@ LDLIBS = $(LIBS)
|
|||
PROG_SOURCES = \
|
||||
drawoverhead.c \
|
||||
fill.c \
|
||||
swapbuffers.c \
|
||||
teximage.c \
|
||||
vbo.c \
|
||||
vertexrate.c \
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ progs = [
|
|||
'drawoverhead',
|
||||
'fill',
|
||||
'teximage',
|
||||
'swapbuffers',
|
||||
'vbo',
|
||||
'vertexrate',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ DrawStateChange(unsigned count)
|
|||
glFinish();
|
||||
}
|
||||
|
||||
void
|
||||
PerfNextRound(void)
|
||||
{
|
||||
}
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
static int Win;
|
||||
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
|
||||
|
||||
/** Return time in seconds */
|
||||
|
|
@ -153,13 +152,23 @@ PerfShaderProgram(const char *vertShader, const char *fragShader)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
PerfReshapeWindow( unsigned w, unsigned h )
|
||||
{
|
||||
if (glutGet(GLUT_SCREEN_WIDTH) < w ||
|
||||
glutGet(GLUT_SCREEN_HEIGHT) < h)
|
||||
return 0;
|
||||
|
||||
glutReshapeWindow( w, h );
|
||||
glutPostRedisplay();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
Xrot += 3.0;
|
||||
Yrot += 4.0;
|
||||
Zrot += 2.0;
|
||||
glutPostRedisplay();
|
||||
PerfNextRound();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -193,13 +202,6 @@ Key(unsigned char key, int x, int y)
|
|||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 'z':
|
||||
Zrot -= step;
|
||||
break;
|
||||
|
|
@ -251,8 +253,7 @@ main(int argc, char *argv[])
|
|||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Draw);
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
glutIdleFunc(Idle);
|
||||
PerfInit();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -46,12 +46,18 @@ PerfCheckerTexture(GLsizei width, GLsizei height);
|
|||
extern GLuint
|
||||
PerfShaderProgram(const char *vertShader, const char *fragShader);
|
||||
|
||||
extern int
|
||||
PerfReshapeWindow( unsigned w, unsigned h );
|
||||
|
||||
|
||||
/** Test programs must implement these functions **/
|
||||
|
||||
extern void
|
||||
PerfInit(void);
|
||||
|
||||
extern void
|
||||
PerfNextRound(void);
|
||||
|
||||
extern void
|
||||
PerfDraw(void);
|
||||
|
||||
|
|
|
|||
167
progs/perf/swapbuffers.c
Normal file
167
progs/perf/swapbuffers.c
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Measure drawing overhead
|
||||
*
|
||||
* This is the first in a series of simple performance benchmarks.
|
||||
* The code in this file should be as simple as possible to make it
|
||||
* easily portable to other APIs.
|
||||
*
|
||||
* All the window-system stuff should be contained in glmain.c (or TBDmain.c).
|
||||
* All the re-usable, generic code should be in common.c (XXX not done yet).
|
||||
*
|
||||
* Brian Paul
|
||||
* 15 Sep 2009
|
||||
*/
|
||||
|
||||
#include "glmain.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
int WinWidth = 100, WinHeight = 100;
|
||||
int real_WinWidth, real_WinHeight; /* don't know whats going on here */
|
||||
|
||||
static GLuint VBO;
|
||||
|
||||
struct vertex
|
||||
{
|
||||
GLfloat x, y;
|
||||
};
|
||||
|
||||
static const struct vertex vertices[4] = {
|
||||
{ -1.0, -1.0 },
|
||||
{ 1.0, -1.0 },
|
||||
{ 1.0, 1.0 },
|
||||
{ -1.0, 1.0 }
|
||||
};
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfInit(void)
|
||||
{
|
||||
/* setup VBO w/ vertex data */
|
||||
glGenBuffersARB(1, &VBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
|
||||
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), (void *) 0);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
/* misc GL state */
|
||||
glAlphaFunc(GL_ALWAYS, 0.0);
|
||||
}
|
||||
|
||||
static void
|
||||
SwapNaked(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SwapClear(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SwapClearPoint(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glDrawArrays(GL_POINTS, 0, 4);
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const struct {
|
||||
unsigned w;
|
||||
unsigned h;
|
||||
} sizes[] = {
|
||||
{ 320, 240 },
|
||||
{ 640, 480 },
|
||||
{ 1024, 768 },
|
||||
{ 1200, 1024 },
|
||||
{ 1600, 1200 }
|
||||
};
|
||||
|
||||
void
|
||||
PerfNextRound(void)
|
||||
{
|
||||
static unsigned i;
|
||||
|
||||
if (i < sizeof(sizes) / sizeof(sizes[0])) {
|
||||
perf_printf("Reshape %dx%d\n", sizes[i].w, sizes[i].h);
|
||||
PerfReshapeWindow( sizes[i].w, sizes[i].h );
|
||||
real_WinWidth = sizes[i].w;
|
||||
real_WinHeight = sizes[i].h;
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfDraw(void)
|
||||
{
|
||||
double rate0;
|
||||
|
||||
rate0 = PerfMeasureRate(SwapNaked);
|
||||
perf_printf(" Swapbuffers (Bare) %dx%d: %s swaps/second",
|
||||
real_WinWidth, real_WinHeight,
|
||||
PerfHumanFloat(rate0));
|
||||
perf_printf(" %s pixels/second\n",
|
||||
PerfHumanFloat(rate0 * real_WinWidth * real_WinHeight));
|
||||
|
||||
|
||||
|
||||
rate0 = PerfMeasureRate(SwapClear);
|
||||
perf_printf(" Swapbuffers + Clear %dx%d: %s swaps/second",
|
||||
real_WinWidth, real_WinHeight,
|
||||
PerfHumanFloat(rate0));
|
||||
perf_printf(" %s pixels/second\n",
|
||||
PerfHumanFloat(rate0 * real_WinWidth * real_WinHeight));
|
||||
|
||||
|
||||
rate0 = PerfMeasureRate(SwapClearPoint);
|
||||
perf_printf(" Swapbuffers + Clear + DrawPoint %dx%d: %s swaps/second",
|
||||
real_WinWidth, real_WinHeight,
|
||||
PerfHumanFloat(rate0));
|
||||
perf_printf(" %s pixels/second\n",
|
||||
PerfHumanFloat(rate0 * real_WinWidth * real_WinHeight));
|
||||
}
|
||||
|
||||
|
|
@ -155,6 +155,10 @@ static const struct {
|
|||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
void
|
||||
PerfNextRound(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ static const GLsizei Sizes[] = {
|
|||
0 /* end of list */
|
||||
};
|
||||
|
||||
void
|
||||
PerfNextRound(void)
|
||||
{
|
||||
}
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
|
|
|
|||
|
|
@ -228,6 +228,11 @@ DrawRangeElementsBO(unsigned count)
|
|||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
void
|
||||
PerfNextRound(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue